feature 319: Add update and downdate functionality to LDLT

This commit is contained in:
Tim Holy
2011-12-09 21:04:44 +01:00
parent 37f304a2e6
commit 2d7c3eea53
2 changed files with 139 additions and 2 deletions

View File

@@ -155,7 +155,7 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
m2.noalias() -= symmLo.template selfadjointView<Lower>().llt().solve(matB);
VERIFY_IS_APPROX(m2, m1 - symmLo.template selfadjointView<Lower>().llt().solve(matB));
// Cholesky update/downdate
// LLT update/downdate
{
MatrixType symmLo = symm.template triangularView<Lower>();
MatrixType symmUp = symm.template triangularView<Upper>();
@@ -173,6 +173,23 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
VERIFY_IS_APPROX(symmCpy, cholup.reconstructedMatrix());
}
// LDLT update/downdate
{
MatrixType symmLo = symm.template triangularView<Lower>();
MatrixType symmUp = symm.template triangularView<Upper>();
VectorType vec = VectorType::Random(rows);
MatrixType symmCpy = symm + vec * vec.adjoint();
LDLT<MatrixType,Lower> chollo(symmLo);
chollo.rankUpdate(vec);
VERIFY_IS_APPROX(symmCpy, chollo.reconstructedMatrix());
LDLT<MatrixType,Upper> cholup(symmUp);
cholup.rankUpdate(vec);
VERIFY_IS_APPROX(symmCpy, cholup.reconstructedMatrix());
}
}
template<typename MatrixType> void cholesky_cplx(const MatrixType& m)