blob: 6c21bafc29621a3c6f27b249555e699b280a483d [file] [log] [blame]
Benoit Jacob8f0e80f2010-10-14 10:14:43 -04001MatrixXf m = MatrixXf::Random(3,2);
2cout << "Here is the matrix m:" << endl << m << endl;
Arthureef33942021-11-29 20:50:46 +00003JacobiSVD<MatrixXf, ComputeThinU | ComputeThinV> svd(m);
Benoit Jacob8f0e80f2010-10-14 10:14:43 -04004cout << "Its singular values are:" << endl << svd.singularValues() << endl;
5cout << "Its left singular vectors are the columns of the thin U matrix:" << endl << svd.matrixU() << endl;
6cout << "Its right singular vectors are the columns of the thin V matrix:" << endl << svd.matrixV() << endl;
7Vector3f rhs(1, 0, 0);
8cout << "Now consider this rhs vector:" << endl << rhs << endl;
9cout << "A least-squares solution of m*x = rhs is:" << endl << svd.solve(rhs) << endl;