Thread: Re: [Lapackpp-devel] Problem finding Null space using LaSVD_IP()
Status: Beta
Brought to you by:
cstim
From: Christian S. <sti...@tu...> - 2006-12-14 20:47:58
|
(Please send your message to "lapackpp-devel", not -owner. Thanks.) Am Donnerstag, 14. Dezember 2006 21:18 schrieb Sonia Singhal: > Hi, > I am using the LAPACKPP on Windows with Visual Studio. I downloaded it a > couple of days back and am using the 2.5.0 version. > > I am using LaSVD_IP() to find the null space of a matrix. My matrix is with > m<n. I was getting wrong answers. > I dumped the U, S, VT matrices generated by the above call and checked it > with Matlab results. > Apparently, the U and V( orVT) matrix columns are fine upto the rank of the > matrix. Beyond that they are all messed up, hence my null space is > incorrect. I'm not so sure you are expecting the right thing here. As you said, the singular vectors for the non-null singular values are as expected. However, the rest of the U and VT matrices, as I understand SVD, are quite ambiguous, given that they only have to span the null space. So as long as these vectors span that space, they can be totally different. As far as I understand it, you would have to check whether the spanned space of all these vectors from lapackpp is identical to the space spanned by the matlab vectors (I don't have a good check for that at hand, but surely one can think of something appropriate). > Has this been observed by someone else ? Am I doing something wrong here ? > the way I set up my matrices is > U - m*m > VT - n*n > S - min(m,n) . I have tried n also as in my case m<n. > A matrix is m*n I think everything is working fine here - you would have gotten clear error messages if any of these matrices were of wrong dimension. Christian |
From: Christian S. <sti...@tu...> - 2006-12-15 09:18:12
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Good to hear. Feel free to ask more questions if something appears to be wrong. By the way you should be able to write std::cout<<U_; as well. Regarding the mailing list address: This is a "mailing list", not a "forum". You have been sending your emails to the address "lapackpp-devel-owner (at) lists.sourceforge.net" which is wrong; the correct email address to send your messages to is lap...@li... (no -owner)! Thanks. Christian Sonia Singhal schrieb: > hi, > > I think I caught my mistake. I didnt make a copy of the matrix before I > checked for the homogenous solution. :( > ~ sonia > > On 12/14/06, *Sonia Singhal * <son...@gm... > <mailto:son...@gm...>> wrote: > > Hi, > > Thanks for the reply. > As for posting it on the forum. I had sent the mail to the forum, I > have no clue how you have received the mail. I initially emailed it > without joining the list and got an error message, maybe thats the > reason you got it. > > As for the problem, even I am not familiar with the algorithms used > for svd and am not sure if the null spaces would be the same, but I > assumed that since MATLAB also uses LAPACK the answers would be the > same. > Even if the answers are not the same and I assume that the NULL > spaces are returned, then multiplying the original matrix A with a > row ( or column ) of VT ( or V ) beyond the rank should be zero. I > did this and I got a very high value when I used Norm_Inf(). Whereas > in MATLAB I get a very small value ( 10^-14). > > Also right now I was making small examples ( 3x4, 3x5 ) and what I > found was for some examples I am getting right answers and for some > they are wrong. By right and wrong I mean comparing both with matlab > and checking if A*VT(r,:) is zero. > > For example : > This code / exmaple gives the correct answers > > //------------------------------------------------------------------------------------------------------ > // Trying SVD > LaGenMatDouble ForSVD(3,5); > ForSVD(0,0) = 1; > ForSVD(0,1) = 2; > ForSVD(0,2) = 3; > ForSVD(0,3) = 4; > ForSVD(0,4) = 2; > ForSVD(1,0) = 2; > ForSVD(1,1) = 3; > ForSVD(1,2) = 9; > ForSVD(1,3) = 2; > ForSVD(1,4) = 0; > ForSVD(2,0) = 4; > ForSVD(2,1) = 5; > ForSVD(2,2) = 8; > ForSVD(2,3) = 7; > ForSVD(2,4) = 4; > LaVectorDouble S_(3); > LaGenMatDouble U_(3,3), VT_(5,5); > LaSVD_IP(ForSVD, S_, U_, VT_); > LaVectorDouble x_(5); > > for(i=0; i<5; ++i){ > x_(i) = VT_(4,i); > } > std::cout << "\tNorm_Inf(A*x)" << Norm_Inf(ForSVD*x_) << > std::endl; > std::cout << "U:" << std::endl; > for(int i=0; i<3; ++i){ > for(int j=0; j<3; ++j){ > std::cout << U_(i,j) << " "; > } > std::cout << std::endl; > } > std::cout << "V:" << std::endl; > for(int i=0; i<5; ++i){ > for(int j=0; j<5; ++j){ > std::cout << VT_(i,j) << " "; > } > std::cout << std::endl; > } > > // > ----------------------------------------------------------------------------------- > and this doesnt. > // > ----------------------------------------------------------------------------------- > > // Trying SVD > LaGenMatDouble ForSVD(3,5); > ForSVD(0,0) = 1; > ForSVD(0,1) = 2; > ForSVD(0,2) = 3; > ForSVD(0,3) = 4; > ForSVD(1,0) = 2; > ForSVD(1,1) = 3; > ForSVD(1,2) = 9; > ForSVD(1,3) = 2; > ForSVD(2,0) = 4; > ForSVD(2,1) = 5; > ForSVD(2,2) = 8; > ForSVD(2,3) = 7; > LaVectorDouble S_(3); > LaGenMatDouble U_(3,3), VT_(4,4); > LaSVD_IP(ForSVD, S_, U_, VT_); > LaVectorDouble x_(5); > > for(i=0; i<5; ++i){ > x_(i) = VT_(4,i); > } > std::cout << "\tNorm_Inf(A*x)" << Norm_Inf(ForSVD*x_) << > std::endl; > std::cout << "U:" << std::endl; > for(int i=0; i<3; ++i){ > for(int j=0; j<3; ++j){ > std::cout << U_(i,j) << " "; > } > std::cout << std::endl; > } > std::cout << "V:" << std::endl; > for(int i=0; i<4; ++i){ > for(int j=0; j<4; ++j){ > std::cout << VT_(i,j) << " "; > } > std::cout << std::endl; > } > // > ------------------------------------------------------------------------------------------------ > Thanks for your time, > ~ Sonia -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.1 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iQCVAwUBRYJoP2XAi+BfhivFAQKzCQP7BvwUeKqGlbLSYrh2rVbWoy7yAFjYD5AT cBVEPecyYR1sX5ZN1Dj3CPRquGB1GcNexlnQfPJ9Tnawc4ZY4djjZa7BtOxXFzJq ZEfXlXbRiR1emMi/ikW5DLvvWPrkUGz9uCeA1MTIppL6xtcyd4Lui9PygAL+rrhq u19NPB9Le8k= =aaop -----END PGP SIGNATURE----- |