xref: /aosp_15_r20/external/eigen/doc/examples/TutorialLinAlgSVDSolve.cpp (revision bf2c37156dfe67e5dfebd6d394bad8b2ab5804d4)
1*bf2c3715SXin Li #include <iostream>
2*bf2c3715SXin Li #include <Eigen/Dense>
3*bf2c3715SXin Li 
4*bf2c3715SXin Li using namespace std;
5*bf2c3715SXin Li using namespace Eigen;
6*bf2c3715SXin Li 
main()7*bf2c3715SXin Li int main()
8*bf2c3715SXin Li {
9*bf2c3715SXin Li    MatrixXf A = MatrixXf::Random(3, 2);
10*bf2c3715SXin Li    cout << "Here is the matrix A:\n" << A << endl;
11*bf2c3715SXin Li    VectorXf b = VectorXf::Random(3);
12*bf2c3715SXin Li    cout << "Here is the right hand side b:\n" << b << endl;
13*bf2c3715SXin Li    cout << "The least-squares solution is:\n"
14*bf2c3715SXin Li         << A.bdcSvd(ComputeThinU | ComputeThinV).solve(b) << endl;
15*bf2c3715SXin Li }
16