xref: /aosp_15_r20/external/eigen/doc/snippets/HouseholderQR_solve.cpp (revision bf2c37156dfe67e5dfebd6d394bad8b2ab5804d4)
1*bf2c3715SXin Li typedef Matrix<float,3,3> Matrix3x3;
2*bf2c3715SXin Li Matrix3x3 m = Matrix3x3::Random();
3*bf2c3715SXin Li Matrix3f y = Matrix3f::Random();
4*bf2c3715SXin Li cout << "Here is the matrix m:" << endl << m << endl;
5*bf2c3715SXin Li cout << "Here is the matrix y:" << endl << y << endl;
6*bf2c3715SXin Li Matrix3f x;
7*bf2c3715SXin Li x = m.householderQr().solve(y);
8*bf2c3715SXin Li assert(y.isApprox(m*x));
9*bf2c3715SXin Li cout << "Here is a solution x to the equation mx=y:" << endl << x << endl;
10