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.
This commit is contained in:
Gael Guennebaud
2008-10-13 15:53:27 +00:00
parent e2bd8623f8
commit 765219aa51
23 changed files with 608 additions and 183 deletions

View File

@@ -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());
}
}