diff options
author | Gael Guennebaud <g.gael@free.fr> | 2014-10-20 10:48:40 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2014-10-20 10:48:40 +0200 |
commit | d04f23260def5c61bce01942b4b74eb0c77c54ed (patch) | |
tree | 49918fc66fb8ee78217e482a1cd500d31c365cb9 | |
parent | 8838b0a1fff2cb01fab3a55312a16ae20daead13 (diff) |
Fix bug #894: the sign of LDLT was not re-initialized at each call of compute()
-rw-r--r-- | Eigen/src/Cholesky/LDLT.h | 1 | ||||
-rw-r--r-- | test/cholesky.cpp | 12 |
2 files changed, 8 insertions, 5 deletions
diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h index b4016cd6c..dfc473df1 100644 --- a/Eigen/src/Cholesky/LDLT.h +++ b/Eigen/src/Cholesky/LDLT.h @@ -433,6 +433,7 @@ LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::compute(const MatrixType& a) m_transpositions.resize(size); m_isInitialized = false; m_temporary.resize(size); + m_sign = internal::ZeroSign; internal::ldlt_inplace<UpLo>::unblocked(m_matrix, m_transpositions, m_temporary, m_sign); diff --git a/test/cholesky.cpp b/test/cholesky.cpp index a883192ab..33e32a322 100644 --- a/test/cholesky.cpp +++ b/test/cholesky.cpp @@ -316,33 +316,35 @@ template<typename MatrixType> void cholesky_definiteness(const MatrixType& m) { eigen_assert(m.rows() == 2 && m.cols() == 2); MatrixType mat; + LDLT<MatrixType> ldlt(2); + { mat << 1, 0, 0, -1; - LDLT<MatrixType> ldlt(mat); + ldlt.compute(mat); VERIFY(!ldlt.isNegative()); VERIFY(!ldlt.isPositive()); } { mat << 1, 2, 2, 1; - LDLT<MatrixType> ldlt(mat); + ldlt.compute(mat); VERIFY(!ldlt.isNegative()); VERIFY(!ldlt.isPositive()); } { mat << 0, 0, 0, 0; - LDLT<MatrixType> ldlt(mat); + ldlt.compute(mat); VERIFY(ldlt.isNegative()); VERIFY(ldlt.isPositive()); } { mat << 0, 0, 0, 1; - LDLT<MatrixType> ldlt(mat); + ldlt.compute(mat); VERIFY(!ldlt.isNegative()); VERIFY(ldlt.isPositive()); } { mat << -1, 0, 0, 0; - LDLT<MatrixType> ldlt(mat); + ldlt.compute(mat); VERIFY(ldlt.isNegative()); VERIFY(!ldlt.isPositive()); } |