aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-01-25 16:33:06 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-01-25 16:33:06 +0000
commit414ee1db4b3f1a822261d012a7ce04ef5b884550 (patch)
tree9492c274ea64313d4ee2f0235dcec3cb87c67915 /doc
parent56c7e164f026c2a07ca6d4d3d81fcce2fd0c570e (diff)
Optimization in LU::solve: when rows<=cols, no need to compute the L matrix
Remove matrixL() and matrixU() methods: they were tricky, returning a Part, and matrixL() was useless for non-square LU. Also they were untested. This is the occasion to simplify the docs (class_LU.cpp) removing the most confusing part. I think that it's better to let the user do his own cooking with Part's.
Diffstat (limited to 'doc')
-rw-r--r--doc/snippets/class_LU.cpp (renamed from doc/snippets/class_LU_2.cpp)10
-rw-r--r--doc/snippets/class_LU_1.cpp12
2 files changed, 6 insertions, 16 deletions
diff --git a/doc/snippets/class_LU_2.cpp b/doc/snippets/class_LU.cpp
index 0c72d34a4..9958368f1 100644
--- a/doc/snippets/class_LU_2.cpp
+++ b/doc/snippets/class_LU.cpp
@@ -5,14 +5,16 @@ cout << "Here is the matrix m:" << endl << m << endl;
Eigen::LU<Matrix5x3> lu(m);
cout << "Here is, up to permutations, its LU decomposition matrix:"
<< endl << lu.matrixLU() << endl;
-cout << "Here is the actual L matrix in this decomposition:" << endl;
+cout << "Here is the L part:" << endl;
Matrix5x5 l = Matrix5x5::Identity();
l.block<5,3>(0,0).part<StrictlyLowerTriangular>() = lu.matrixLU();
cout << l << endl;
+cout << "Here is the U part:" << endl;
+Matrix5x3 u = lu.matrixLU().part<UpperTriangular>();
+cout << u << endl;
cout << "Let us now reconstruct the original matrix m:" << endl;
-Matrix5x3 x = l * lu.matrixU();
+Matrix5x3 x = l * u;
Matrix5x3 y;
for(int i = 0; i < 5; 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));
+cout << y << endl; // should be equal to the original matrix m
diff --git a/doc/snippets/class_LU_1.cpp b/doc/snippets/class_LU_1.cpp
deleted file mode 100644
index 50cfc4bf5..000000000
--- a/doc/snippets/class_LU_1.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-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));