diff options
Diffstat (limited to 'eigen/doc/snippets/JacobiSVD_basic.cpp')
-rw-r--r-- | eigen/doc/snippets/JacobiSVD_basic.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/eigen/doc/snippets/JacobiSVD_basic.cpp b/eigen/doc/snippets/JacobiSVD_basic.cpp new file mode 100644 index 0000000..ab24b9b --- /dev/null +++ b/eigen/doc/snippets/JacobiSVD_basic.cpp @@ -0,0 +1,9 @@ +MatrixXf m = MatrixXf::Random(3,2); +cout << "Here is the matrix m:" << endl << m << endl; +JacobiSVD<MatrixXf> svd(m, ComputeThinU | ComputeThinV); +cout << "Its singular values are:" << endl << svd.singularValues() << endl; +cout << "Its left singular vectors are the columns of the thin U matrix:" << endl << svd.matrixU() << endl; +cout << "Its right singular vectors are the columns of the thin V matrix:" << endl << svd.matrixV() << endl; +Vector3f rhs(1, 0, 0); +cout << "Now consider this rhs vector:" << endl << rhs << endl; +cout << "A least-squares solution of m*x = rhs is:" << endl << svd.solve(rhs) << endl; |