aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cholesky.cpp
diff options
context:
space:
mode:
authorGravatar Hauke Heibel <hauke.heibel@gmail.com>2009-05-22 15:58:20 +0200
committerGravatar Hauke Heibel <hauke.heibel@gmail.com>2009-05-22 15:58:20 +0200
commitc7303a876f8a051855ec9866a4aad1c694b2140d (patch)
treebee484661db5a8d754cb6c273b28a195591b49e8 /test/cholesky.cpp
parent0523b64fe9dd72ba41311e3805e8d3c83e4e750a (diff)
Oops, here the actual LLT and LDLT patch.
Diffstat (limited to 'test/cholesky.cpp')
-rw-r--r--test/cholesky.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/test/cholesky.cpp b/test/cholesky.cpp
index a49625e90..9bcf228d2 100644
--- a/test/cholesky.cpp
+++ b/test/cholesky.cpp
@@ -112,29 +112,25 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
}
-template<typename Derived>
-void doSomeRankPreservingOperations(Eigen::MatrixBase<Derived>& m)
+template<typename MatrixType> void cholesky_verify_assert()
{
- typedef typename Derived::RealScalar RealScalar;
- for(int a = 0; a < 3*(m.rows()+m.cols()); a++)
- {
- RealScalar d = Eigen::ei_random<RealScalar>(-1,1);
- int i = Eigen::ei_random<int>(0,m.rows()-1); // i is a random row number
- int j;
- do {
- j = Eigen::ei_random<int>(0,m.rows()-1);
- } while (i==j); // j is another one (must be different)
- m.row(i) += d * m.row(j);
-
- i = Eigen::ei_random<int>(0,m.cols()-1); // i is a random column number
- do {
- j = Eigen::ei_random<int>(0,m.cols()-1);
- } while (i==j); // j is another one (must be different)
- m.col(i) += d * m.col(j);
- }
+ MatrixType tmp;
+
+ LLT<MatrixType> llt;
+ VERIFY_RAISES_ASSERT(llt.matrixL())
+ VERIFY_RAISES_ASSERT(llt.solve(tmp,&tmp))
+ VERIFY_RAISES_ASSERT(llt.solveInPlace(&tmp))
+
+ LDLT<MatrixType> ldlt;
+ VERIFY_RAISES_ASSERT(ldlt.matrixL())
+ VERIFY_RAISES_ASSERT(ldlt.permutationP())
+ VERIFY_RAISES_ASSERT(ldlt.vectorD())
+ VERIFY_RAISES_ASSERT(ldlt.isPositive())
+ VERIFY_RAISES_ASSERT(ldlt.isNegative())
+ VERIFY_RAISES_ASSERT(ldlt.solve(tmp,&tmp))
+ VERIFY_RAISES_ASSERT(ldlt.solveInPlace(&tmp))
}
-
void test_cholesky()
{
for(int i = 0; i < g_repeat; i++) {
@@ -147,4 +143,9 @@ void test_cholesky()
CALL_SUBTEST( cholesky(MatrixXd(17,17)) );
CALL_SUBTEST( cholesky(MatrixXf(200,200)) );
}
+
+ CALL_SUBTEST( cholesky_verify_assert<Matrix3f>() );
+ CALL_SUBTEST( cholesky_verify_assert<Matrix3d>() );
+ CALL_SUBTEST( cholesky_verify_assert<MatrixXf>() );
+ CALL_SUBTEST( cholesky_verify_assert<MatrixXd>() );
}