- edited description
svd issue
Hello,
I have a 3x3 matrix A and I am trying to use svd() to compute the svd of A. I write the following code:
DynamicMatrix<double, columnMajor> U;
DynamicVector<double, columnVector> s; // contains m singular values
DynamicMatrix<double, columnMajor> S(3,3); // matrix version of s, need to build it
DynamicMatrix<double, columnMajor> V;
S = 0.; // initialize singular values matrix to zero
svd( A, U, s, V); // Computing the singular values and vectors of gqx
for ( unsigned long int i = 0; i < 3; i++){
S(i,i) = s[i];
}
cout << "--------------------------------------" << endl;
cout << A << endl;
cout << U * S * trans(V) << endl;
cout << "--------------------------------------" << endl;
However, the printed outputs do not agree, but they should. How is this possible? I can’t get back the matrix A from the SVD generated by svd(). Do you have any idea of why this might be happening?
Thank you so much for your help.
Comments (4)
-
reporter -
reporter - edited description
-
- changed status to wontfix
Hi Ildebrando!
Thanks for taking the time to report this potential defect. In this case, the problem seems to be resolved rather easily: please do not transpose the matrix
V
:// ... cout << U * S * V << endl; // ...
Then the output for
A
andU * S * V
are equal.Best regards,
Klaus!
-
reporter OK, thank you very much for your help! It works!
Brando
- Log in to comment