aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/lu.cpp
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-11-16 17:05:12 -0500
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-11-16 17:05:12 -0500
commitb90744dc053d176f3ae00f67fbaac7f3b083b55e (patch)
treed2b7f049337f60f8385eaa6de0e3f2fe242db533 /test/lu.cpp
parent76c614f9bd8e80a530a4aa685f1ae7506b64b8dd (diff)
Port FullPivLU to PermutationMatrix
Diffstat (limited to 'test/lu.cpp')
-rw-r--r--test/lu.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/lu.cpp b/test/lu.cpp
index 9dcebbeaa..c2237febf 100644
--- a/test/lu.cpp
+++ b/test/lu.cpp
@@ -24,9 +24,11 @@
#include "main.h"
#include <Eigen/LU>
+using namespace std;
template<typename MatrixType> void lu_non_invertible()
{
+ typedef typename MatrixType::Scalar Scalar;
/* this test covers the following files:
LU.h
*/
@@ -65,7 +67,20 @@ template<typename MatrixType> void lu_non_invertible()
createRandomMatrixOfRank(rank, rows, cols, m1);
FullPivLU<MatrixType> lu(m1);
- std::cout << lu.kernel().rows() << " " << lu.kernel().cols() << std::endl;
+ // FIXME need better way to construct trapezoid matrices. extend triangularView to support rectangular.
+ DynamicMatrixType u(rows,cols);
+ for(int i = 0; i < rows; i++)
+ for(int j = 0; j < cols; j++)
+ u(i,j) = i>j ? Scalar(0) : lu.matrixLU()(i,j);
+ DynamicMatrixType l(rows,rows);
+ for(int i = 0; i < rows; i++)
+ for(int j = 0; j < rows; j++)
+ l(i,j) = (i<j || j>=cols) ? Scalar(0)
+ : i==j ? Scalar(1)
+ : lu.matrixLU()(i,j);
+
+ VERIFY_IS_APPROX(lu.permutationP() * m1 * lu.permutationQ(), l*u);
+
KernelMatrixType m1kernel = lu.kernel();
ImageMatrixType m1image = lu.image(m1);