mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-27 07:29:52 +08:00
8f0e80fe30
* fix preallocating constructors, allocate U and V of the right size for computation options * complete documentation and internal comments * improve unit test, test inf/nan values
10 lines
614 B
C++
10 lines
614 B
C++
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;
|