Benoit Jacob | f04c1cb | 2008-08-11 21:26:37 +0000 | [diff] [blame] | 1 | typedef Matrix<double, 5, 3> Matrix5x3; |
| 2 | typedef Matrix<double, 5, 5> Matrix5x5; |
| 3 | Matrix5x3 m = Matrix5x3::Random(); |
| 4 | cout << "Here is the matrix m:" << endl << m << endl; |
Benoit Jacob | 2840ac7 | 2009-10-28 18:19:29 -0400 | [diff] [blame] | 5 | Eigen::FullPivLU<Matrix5x3> lu(m); |
Benoit Jacob | f04c1cb | 2008-08-11 21:26:37 +0000 | [diff] [blame] | 6 | cout << "Here is, up to permutations, its LU decomposition matrix:" |
| 7 | << endl << lu.matrixLU() << endl; |
Benoit Jacob | 414ee1d | 2009-01-25 16:33:06 +0000 | [diff] [blame] | 8 | cout << "Here is the L part:" << endl; |
Benoit Jacob | f04c1cb | 2008-08-11 21:26:37 +0000 | [diff] [blame] | 9 | Matrix5x5 l = Matrix5x5::Identity(); |
Benoit Jacob | 5331fa3 | 2011-01-24 07:41:47 -0500 | [diff] [blame^] | 10 | l.block<5,3>(0,0).triangularView<StrictlyLower>() = lu.matrixLU(); |
Benoit Jacob | f04c1cb | 2008-08-11 21:26:37 +0000 | [diff] [blame] | 11 | cout << l << endl; |
Benoit Jacob | 414ee1d | 2009-01-25 16:33:06 +0000 | [diff] [blame] | 12 | cout << "Here is the U part:" << endl; |
Benoit Jacob | 5331fa3 | 2011-01-24 07:41:47 -0500 | [diff] [blame^] | 13 | Matrix5x3 u = lu.matrixLU().triangularView<Upper>(); |
Benoit Jacob | 414ee1d | 2009-01-25 16:33:06 +0000 | [diff] [blame] | 14 | cout << u << endl; |
Benoit Jacob | f04c1cb | 2008-08-11 21:26:37 +0000 | [diff] [blame] | 15 | cout << "Let us now reconstruct the original matrix m:" << endl; |
Benoit Jacob | b90744d | 2009-11-16 17:05:12 -0500 | [diff] [blame] | 16 | cout << lu.permutationP().inverse() * l * u * lu.permutationQ().inverse() << endl; |