TutorialLinAlgExComputeSolveError.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <Eigen/Dense>
00003 
00004 using namespace std;
00005 using namespace Eigen;
00006 
00007 int main()
00008 {
00009    MatrixXd A = MatrixXd::Random(100,100);
00010    MatrixXd b = MatrixXd::Random(100,50);
00011    MatrixXd x = A.fullPivLu().solve(b);
00012    double relative_error = (A*x - b).norm() / b.norm(); // norm() is L2 norm
00013    cout << "The relative error is:\n" << relative_error << endl;
00014 }


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:33:27