vxl-users

 [Vxl-users] vnl_matrix_inverse class returns svd result instead of inverse of the matrix. From: Shoujie He - 2008-07-10 19:34:57 Attachments: Message as HTML ```Hello everyone, I expected the inversed matrix of A from vcl_cerr << vnl_matrix_inverse(A) But the output (overloaded << operator) gives me U, W, and V, the singular value decomposition result plus rank. Is it intended for vnl_matrix_inverse template class? Shoujie ```
 Re: [Vxl-users] vnl_matrix_inverse class returns svd result instead of inverse of the matrix. From: Peter Vanroose - 2008-07-11 07:36:14 ```> I expected the inversed matrix of A from > vcl_cerr << vnl_matrix_inverse(A); > But the output (overloaded << operator) gives me U, W, and V, > the singular value decomposition result plus rank. > Is it intended for vnl_matrix_inverse template class? This is maybe a bit unexpected, but indeed "works as designed". A short word of explanation: - the vnl_matrix_inverse class derives from vnl_svd. This explains the above behaviour, since you are calling the "<<" operator of vnl_svd. - wherever you use a vnl_matrix_inverse in a vnl_matrix context, it behaves really as the inverse itself, not (U,W,V), since in that case vnl_svd's inverse() method is called automatically. Example: vnl_matrix inv = vnl_matrix_inverse(A); vcl_cerr << inv; - this is even more the case when using vnl_matrix_inverse(A) directly in a multiplication, as in x = vnl_matrix_inverse(A) * b; (for b either matrix or vector) which is actually implemented as x = vnl_svd(A).solve(b); This explains the choice for vnl_matrix_inverse as a *class* derived from vnl_svd instead of just a *function* using vnl_svd. So it's a "convenience class", for code readablility purposes. - When your matrix is "small", i.e., 2x2, 3x3, or 4x4, you should consider using the much faster *function* vnl_inverse(A) which does not use vnl_svd (and hence does not need lib vnl_algo). This holds for both vnl_matrix & vnl_matrix_fixed with n<=4. -- Peter. __________________________________________________________ Låna pengar utan säkerhet. Jämför vilkor online hos Kelkoo. http://www.kelkoo.se/c-100390123-lan-utan-sakerhet.html?partnerId=96915014 ```