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.

20 lines
600 B

  1. #include <iostream>
  2. #include <Eigen/Dense>
  3. using namespace std;
  4. using namespace Eigen;
  5. int main()
  6. {
  7. Matrix3f A;
  8. A << 1, 2, 5,
  9. 2, 1, 4,
  10. 3, 0, 3;
  11. cout << "Here is the matrix A:\n" << A << endl;
  12. FullPivLU<Matrix3f> lu_decomp(A);
  13. cout << "The rank of A is " << lu_decomp.rank() << endl;
  14. cout << "Here is a matrix whose columns form a basis of the null-space of A:\n"
  15. << lu_decomp.kernel() << endl;
  16. cout << "Here is a matrix whose columns form a basis of the column-space of A:\n"
  17. << lu_decomp.image(A) << endl; // yes, have to pass the original A
  18. }