From 4d4a23cd3e97bbc10d6307b828627c672097c5f5 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Wed, 30 Jun 2010 10:11:55 -0400 Subject: nearly complete page 6 / linear algebra + examples fix the previous/next links --- doc/examples/TutorialLinAlgExComputeSolveError.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 doc/examples/TutorialLinAlgExComputeSolveError.cpp (limited to 'doc/examples/TutorialLinAlgExComputeSolveError.cpp') diff --git a/doc/examples/TutorialLinAlgExComputeSolveError.cpp b/doc/examples/TutorialLinAlgExComputeSolveError.cpp new file mode 100644 index 000000000..f362fb71a --- /dev/null +++ b/doc/examples/TutorialLinAlgExComputeSolveError.cpp @@ -0,0 +1,14 @@ +#include +#include + +using namespace std; +using namespace Eigen; + +int main() +{ + MatrixXd A = MatrixXd::Random(100,100); + MatrixXd b = MatrixXd::Random(100,50); + MatrixXd x = A.fullPivLu().solve(b); + double relative_error = (A*x - b).norm() / b.norm(); // norm() is L2 norm + cout << "The relative error is:\n" << relative_error << endl; +} -- cgit v1.2.3