You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
408 B

  1. #include <iostream>
  2. #include <Eigen/Dense>
  3. using namespace std;
  4. using namespace Eigen;
  5. int main()
  6. {
  7. MatrixXf A = MatrixXf::Random(3, 2);
  8. cout << "Here is the matrix A:\n" << A << endl;
  9. VectorXf b = VectorXf::Random(3);
  10. cout << "Here is the right hand side b:\n" << b << endl;
  11. cout << "The least-squares solution is:\n"
  12. << A.jacobiSvd(ComputeThinU | ComputeThinV).solve(b) << endl;
  13. }