blob: fce7fac0969e06855acd8a12c6cb45b281755e48 [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();
Benoit Jacob5331fa32011-01-24 07:41:47 -050010l.block<5,3>(0,0).triangularView<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;
Benoit Jacob5331fa32011-01-24 07:41:47 -050013Matrix5x3 u = lu.matrixLU().triangularView<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;