Go to the documentation of this file.00001 #include <Eigen/Core>
00002 #include <Eigen/LU>
00003 #include <Eigen/QR>
00004 #include <Eigen/Cholesky>
00005 #include <Eigen/Geometry>
00006 #include <Eigen/Jacobi>
00007 #include <Eigen/Eigenvalues>
00008 #include <iostream>
00009
00010 using namespace Eigen;
00011 using namespace std;
00012
00013 int main(int, char**)
00014 {
00015 cout.precision(3);
00016 MatrixXf m = MatrixXf::Random(3,2);
00017 cout << "Here is the matrix m:" << endl << m << endl;
00018 JacobiSVD<MatrixXf> svd(m, ComputeThinU | ComputeThinV);
00019 cout << "Its singular values are:" << endl << svd.singularValues() << endl;
00020 cout << "Its left singular vectors are the columns of the thin U matrix:" << endl << svd.matrixU() << endl;
00021 cout << "Its right singular vectors are the columns of the thin V matrix:" << endl << svd.matrixV() << endl;
00022 Vector3f rhs(1, 0, 0);
00023 cout << "Now consider this rhs vector:" << endl << rhs << endl;
00024 cout << "A least-squares solution of m*x = rhs is:" << endl << svd.solve(rhs) << endl;
00025
00026 return 0;
00027 }