Eigen 3.4.90
doc
examples
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
}
b
Array< int, 3, 1 > b
Definition:
Array_variadic_ctor_cxx11.cpp:2
x
x
Definition:
BiCGSTAB_simple.cpp:7
A
MatrixXcf A
Definition:
ComplexEigenSolver_compute.cpp:1
Dense
main
int main()
Definition:
TutorialLinAlgExComputeSolveError.cpp:6
Eigen::MatrixXd
Matrix< double, Dynamic, Dynamic > MatrixXd
Dynamic×Dynamic matrix of type double.
Definition:
Matrix.h:502