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.

23 lines
622 B

  1. #include <iostream>
  2. #include <Eigen/Dense>
  3. using namespace std;
  4. using namespace Eigen;
  5. int main()
  6. {
  7. Matrix2f A, b;
  8. LLT<Matrix2f> llt;
  9. A << 2, -1, -1, 3;
  10. b << 1, 2, 3, 1;
  11. cout << "Here is the matrix A:\n" << A << endl;
  12. cout << "Here is the right hand side b:\n" << b << endl;
  13. cout << "Computing LLT decomposition..." << endl;
  14. llt.compute(A);
  15. cout << "The solution is:\n" << llt.solve(b) << endl;
  16. A(1,1)++;
  17. cout << "The matrix A is now:\n" << A << endl;
  18. cout << "Computing LLT decomposition..." << endl;
  19. llt.compute(A);
  20. cout << "The solution is now:\n" << llt.solve(b) << endl;
  21. }