TutorialLinAlgExComputeSolveError.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <Eigen/Dense>
3 
4 using Eigen::MatrixXd;
5 
6 int main()
7 {
8  MatrixXd A = MatrixXd::Random(100,100);
9  MatrixXd b = MatrixXd::Random(100,50);
10  MatrixXd x = A.fullPivLu().solve(b);
11  double relative_error = (A*x - b).norm() / b.norm(); // norm() is L2 norm
12  std::cout << "The relative error is:\n" << relative_error << std::endl;
13 }
Array< int, 3, 1 > b
MatrixXcf A
Matrix< double, Dynamic, Dynamic > MatrixXd
Dynamic×Dynamic matrix of type double.
Definition: Matrix.h:502