2008-08-12 05:26:37 +08:00
|
|
|
typedef Matrix<double, 5, 3> Matrix5x3;
|
|
|
|
typedef Matrix<double, 5, 5> Matrix5x5;
|
|
|
|
Matrix5x3 m = Matrix5x3::Random();
|
|
|
|
cout << "Here is the matrix m:" << endl << m << endl;
|
2009-10-29 06:19:29 +08:00
|
|
|
Eigen::FullPivLU<Matrix5x3> lu(m);
|
2008-08-12 05:26:37 +08:00
|
|
|
cout << "Here is, up to permutations, its LU decomposition matrix:"
|
|
|
|
<< endl << lu.matrixLU() << endl;
|
2009-01-26 00:33:06 +08:00
|
|
|
cout << "Here is the L part:" << endl;
|
2008-08-12 05:26:37 +08:00
|
|
|
Matrix5x5 l = Matrix5x5::Identity();
|
2010-01-14 00:51:09 +08:00
|
|
|
l.block<5,3>(0,0).part<StrictlyLower>() = lu.matrixLU();
|
2008-08-12 05:26:37 +08:00
|
|
|
cout << l << endl;
|
2009-01-26 00:33:06 +08:00
|
|
|
cout << "Here is the U part:" << endl;
|
2010-01-14 00:51:09 +08:00
|
|
|
Matrix5x3 u = lu.matrixLU().part<Upper>();
|
2009-01-26 00:33:06 +08:00
|
|
|
cout << u << endl;
|
2008-08-12 05:26:37 +08:00
|
|
|
cout << "Let us now reconstruct the original matrix m:" << endl;
|
2009-11-17 06:05:12 +08:00
|
|
|
cout << lu.permutationP().inverse() * l * u * lu.permutationQ().inverse() << endl;
|