blob: d44d8b5f0e10bedc48ad37b1cca5a621f7106da2 [file] [log] [blame]
Benoit Jacobf04c1cb2008-08-11 21:26:37 +00001typedef Matrix<double, 5, 3> Matrix5x3;
2typedef Matrix<double, 5, 5> Matrix5x5;
3Matrix5x3 m = Matrix5x3::Random();
4cout << "Here is the matrix m:" << endl << m << endl;
Benoit Jacob2840ac72009-10-28 18:19:29 -04005Eigen::FullPivLU<Matrix5x3> lu(m);
Benoit Jacobf04c1cb2008-08-11 21:26:37 +00006cout << "Here is, up to permutations, its LU decomposition matrix:"
7 << endl << lu.matrixLU() << endl;
Benoit Jacob414ee1d2009-01-25 16:33:06 +00008cout << "Here is the L part:" << endl;
Benoit Jacobf04c1cb2008-08-11 21:26:37 +00009Matrix5x5 l = Matrix5x5::Identity();
Hauke Heibelc0b2aa02010-01-13 17:51:09 +010010l.block<5,3>(0,0).part<StrictlyLower>() = lu.matrixLU();
Benoit Jacobf04c1cb2008-08-11 21:26:37 +000011cout << l << endl;
Benoit Jacob414ee1d2009-01-25 16:33:06 +000012cout << "Here is the U part:" << endl;
Hauke Heibelc0b2aa02010-01-13 17:51:09 +010013Matrix5x3 u = lu.matrixLU().part<Upper>();
Benoit Jacob414ee1d2009-01-25 16:33:06 +000014cout << u << endl;
Benoit Jacobf04c1cb2008-08-11 21:26:37 +000015cout << "Let us now reconstruct the original matrix m:" << endl;
Benoit Jacobb90744d2009-11-16 17:05:12 -050016cout << lu.permutationP().inverse() * l * u * lu.permutationQ().inverse() << endl;