mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Complete LU documentation
This commit is contained in:
12
doc/snippets/class_LU_1.cpp
Normal file
12
doc/snippets/class_LU_1.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
Matrix3d m = Matrix3d::Random();
|
||||
cout << "Here is the matrix m:" << endl << m << endl;
|
||||
Eigen::LU<Matrix3d> lu(m);
|
||||
cout << "Here is, up to permutations, its LU decomposition matrix:"
|
||||
<< endl << lu.matrixLU() << endl;
|
||||
cout << "Let us now reconstruct the original matrix m from it:" << endl;
|
||||
Matrix3d x = lu.matrixL() * lu.matrixU();
|
||||
Matrix3d y;
|
||||
for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++)
|
||||
y(i, lu.permutationQ()[j]) = x(lu.permutationP()[i], j);
|
||||
cout << y << endl;
|
||||
assert(y.isApprox(m));
|
||||
Reference in New Issue
Block a user