TutorialLinAlgExComputeSolveError.cpp File Reference

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 6 of file TutorialLinAlgExComputeSolveError.cpp.

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