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.

14 lines
376 B

  1. #include <iostream>
  2. #include <Eigen/Dense>
  3. using namespace std;
  4. using namespace StormEigen;
  5. int main()
  6. {
  7. MatrixXd A = MatrixXd::Random(100,100);
  8. MatrixXd b = MatrixXd::Random(100,50);
  9. MatrixXd x = A.fullPivLu().solve(b);
  10. double relative_error = (A*x - b).norm() / b.norm(); // norm() is L2 norm
  11. cout << "The relative error is:\n" << relative_error << endl;
  12. }