libeigen/eigen!2509 Closes #2868 Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
13 lines
697 B
C++
13 lines
697 B
C++
// SPDX-FileCopyrightText: The Eigen Authors
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
MatrixXf m = MatrixXf::Random(3, 2);
|
|
cout << "Here is the matrix m:" << endl << m << endl;
|
|
JacobiSVD<MatrixXf, ComputeThinU | ComputeThinV> svd(m);
|
|
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;
|