Benoit Jacob | 8f0e80f | 2010-10-14 10:14:43 -0400 | [diff] [blame] | 1 | MatrixXf m = MatrixXf::Random(3,2); |
| 2 | cout << "Here is the matrix m:" << endl << m << endl; |
Rasmus Munk Larsen | 085c2fc | 2021-11-30 18:45:54 +0000 | [diff] [blame] | 3 | JacobiSVD<MatrixXf> svd(m, ComputeThinU | ComputeThinV); |
Benoit Jacob | 8f0e80f | 2010-10-14 10:14:43 -0400 | [diff] [blame] | 4 | cout << "Its singular values are:" << endl << svd.singularValues() << endl; |
| 5 | cout << "Its left singular vectors are the columns of the thin U matrix:" << endl << svd.matrixU() << endl; |
| 6 | cout << "Its right singular vectors are the columns of the thin V matrix:" << endl << svd.matrixV() << endl; |
| 7 | Vector3f rhs(1, 0, 0); |
| 8 | cout << "Now consider this rhs vector:" << endl << rhs << endl; |
| 9 | cout << "A least-squares solution of m*x = rhs is:" << endl << svd.solve(rhs) << endl; |