source: pacpussensors/trunk/Vislab/lib3dv/eigen/Eigen-install/doc/snippets/compile_JacobiSVD_basic.cpp@ 136

Last change on this file since 136 was 136, checked in by ldecherf, 7 years ago

Doc

File size: 786 bytes
Line 
1#include <Eigen/Dense>
2#include <iostream>
3
4using namespace Eigen;
5using namespace std;
6
7int main(int, char**)
8{
9 cout.precision(3);
10 MatrixXf m = MatrixXf::Random(3,2);
11cout << "Here is the matrix m:" << endl << m << endl;
12JacobiSVD<MatrixXf> svd(m, ComputeThinU | ComputeThinV);
13cout << "Its singular values are:" << endl << svd.singularValues() << endl;
14cout << "Its left singular vectors are the columns of the thin U matrix:" << endl << svd.matrixU() << endl;
15cout << "Its right singular vectors are the columns of the thin V matrix:" << endl << svd.matrixV() << endl;
16Vector3f rhs(1, 0, 0);
17cout << "Now consider this rhs vector:" << endl << rhs << endl;
18cout << "A least-squares solution of m*x = rhs is:" << endl << svd.solve(rhs) << endl;
19
20 return 0;
21}
Note: See TracBrowser for help on using the repository browser.