diff options
author | Gael Guennebaud <g.gael@free.fr> | 2008-10-13 15:53:27 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2008-10-13 15:53:27 +0000 |
commit | 765219aa5180c40be86a380524db691a0fd5861b (patch) | |
tree | b3d2cab1eb2c43780a8da9a2e418e1adfd0e7cc3 /test/cholesky.cpp | |
parent | e2bd8623f88c3e7aa1c4a2eaa5dc7ab351219a33 (diff) |
Big API change in Cholesky module:
* rename Cholesky to LLT
* rename CholeskyWithoutSquareRoot to LDLT
* rename MatrixBase::cholesky() to llt()
* rename MatrixBase::choleskyNoSqrt() to ldlt()
* make {LLT,LDLT}::solve() API consistent with other modules
Note that we are going to keep a source compatibility untill the next beta release.
E.g., the "old" Cholesky* classes, etc are still available for some time.
To be clear, Eigen beta2 should be (hopefully) source compatible with beta1,
and so beta2 will contain all the deprecated API of beta1. Those features marked
as deprecated will be removed in beta3 (or in the final 2.0 if there is no beta 3 !).
Also includes various updated in sparse Cholesky.
Diffstat (limited to 'test/cholesky.cpp')
-rw-r--r-- | test/cholesky.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/test/cholesky.cpp b/test/cholesky.cpp index 80614346c..f7eb7800e 100644 --- a/test/cholesky.cpp +++ b/test/cholesky.cpp @@ -33,7 +33,7 @@ template<typename MatrixType> void cholesky(const MatrixType& m) { /* this test covers the following files: - Cholesky.h CholeskyWithoutSquareRoot.h + LLT.h LDLT.h */ int rows = m.rows(); int cols = m.cols(); @@ -44,8 +44,8 @@ template<typename MatrixType> void cholesky(const MatrixType& m) typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType; MatrixType a0 = MatrixType::Random(rows,cols); - VectorType vecB = VectorType::Random(rows); - MatrixType matB = MatrixType::Random(rows,cols); + VectorType vecB = VectorType::Random(rows), vecX(rows); + MatrixType matB = MatrixType::Random(rows,cols), matX(rows,cols); SquareMatrixType symm = a0 * a0.adjoint(); // let's make sure the matrix is not singular or near singular MatrixType a1 = MatrixType::Random(rows,cols); @@ -80,28 +80,32 @@ template<typename MatrixType> void cholesky(const MatrixType& m) #endif { - CholeskyWithoutSquareRoot<SquareMatrixType> cholnosqrt(symm); - VERIFY(cholnosqrt.isPositiveDefinite()); - VERIFY_IS_APPROX(symm, cholnosqrt.matrixL() * cholnosqrt.vectorD().asDiagonal() * cholnosqrt.matrixL().adjoint()); - VERIFY_IS_APPROX(symm * cholnosqrt.solve(vecB), vecB); - VERIFY_IS_APPROX(symm * cholnosqrt.solve(matB), matB); + LDLT<SquareMatrixType> ldlt(symm); + VERIFY(ldlt.isPositiveDefinite()); + VERIFY_IS_APPROX(symm, ldlt.matrixL() * ldlt.vectorD().asDiagonal() * ldlt.matrixL().adjoint()); + ldlt.solve(vecB, &vecX); + VERIFY_IS_APPROX(symm * vecX, vecB); + ldlt.solve(matB, &matX); + VERIFY_IS_APPROX(symm * matX, matB); } { - Cholesky<SquareMatrixType> chol(symm); + LLT<SquareMatrixType> chol(symm); VERIFY(chol.isPositiveDefinite()); VERIFY_IS_APPROX(symm, chol.matrixL() * chol.matrixL().adjoint()); - VERIFY_IS_APPROX(symm * chol.solve(vecB), vecB); - VERIFY_IS_APPROX(symm * chol.solve(matB), matB); + chol.solve(vecB, &vecX); + VERIFY_IS_APPROX(symm * vecX, vecB); + chol.solve(matB, &matX); + VERIFY_IS_APPROX(symm * matX, matB); } // test isPositiveDefinite on non definite matrix if (rows>4) { SquareMatrixType symm = a0.block(0,0,rows,cols-4) * a0.block(0,0,rows,cols-4).adjoint(); - Cholesky<SquareMatrixType> chol(symm); + LLT<SquareMatrixType> chol(symm); VERIFY(!chol.isPositiveDefinite()); - CholeskyWithoutSquareRoot<SquareMatrixType> cholnosqrt(symm); + LDLT<SquareMatrixType> cholnosqrt(symm); VERIFY(!cholnosqrt.isPositiveDefinite()); } } |