source: pacpussensors/trunk/Vislab/lib3dv/eigen/Eigen-install/doc/snippets/compile_class_FullPivLU.cpp@ 136

Last change on this file since 136 was 136, checked in by ldecherf, 7 years ago

Doc

File size: 911 bytes
Line 
1#include <Eigen/Dense>
2#include <iostream>
3
4using namespace Eigen;
5using namespace std;
6
7int main(int, char**)
8{
9 cout.precision(3);
10 typedef Matrix<double, 5, 3> Matrix5x3;
11typedef Matrix<double, 5, 5> Matrix5x5;
12Matrix5x3 m = Matrix5x3::Random();
13cout << "Here is the matrix m:" << endl << m << endl;
14Eigen::FullPivLU<Matrix5x3> lu(m);
15cout << "Here is, up to permutations, its LU decomposition matrix:"
16 << endl << lu.matrixLU() << endl;
17cout << "Here is the L part:" << endl;
18Matrix5x5 l = Matrix5x5::Identity();
19l.block<5,3>(0,0).triangularView<StrictlyLower>() = lu.matrixLU();
20cout << l << endl;
21cout << "Here is the U part:" << endl;
22Matrix5x3 u = lu.matrixLU().triangularView<Upper>();
23cout << u << endl;
24cout << "Let us now reconstruct the original matrix m:" << endl;
25cout << lu.permutationP().inverse() * l * u * lu.permutationQ().inverse() << endl;
26
27 return 0;
28}
Note: See TracBrowser for help on using the repository browser.