diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h index 8a466e1c7..cdc2da0fb 100644 --- a/Eigen/src/Cholesky/LDLT.h +++ b/Eigen/src/Cholesky/LDLT.h @@ -96,8 +96,7 @@ void LDLT::compute(const MatrixType& a) assert(a.rows()==a.cols()); const int size = a.rows(); m_matrix.resize(size, size); - m_isPositiveDefinite = true; - const RealScalar eps = precision() * a.cwise().abs().maxCoeff(); + m_isPositiveDefinite = true; // always true. This decomposition is not rank-revealing anyway. if (size<=1) { @@ -121,12 +120,6 @@ void LDLT::compute(const MatrixType& a) RealScalar tmp = ei_real(a.coeff(j,j) - (m_matrix.row(j).start(j) * m_matrix.col(j).start(j).conjugate()).coeff(0,0)); m_matrix.coeffRef(j,j) = tmp; - if (tmp < eps) - { - m_isPositiveDefinite = false; - return; - } - int endSize = size-j-1; if (endSize>0) { @@ -136,7 +129,8 @@ void LDLT::compute(const MatrixType& a) m_matrix.row(j).end(endSize) = a.row(j).end(endSize).conjugate() - _temporary.end(endSize).transpose(); - m_matrix.col(j).end(endSize) = m_matrix.row(j).end(endSize) / tmp; + if(tmp != RealScalar(0)) + m_matrix.col(j).end(endSize) = m_matrix.row(j).end(endSize) / tmp; } } } @@ -192,7 +186,7 @@ template inline const LDLT::PlainMatrixType> MatrixBase::ldlt() const { - return LDLT(derived()); + return LDLT(derived()); } #endif // EIGEN_LDLT_H diff --git a/test/cholesky.cpp b/test/cholesky.cpp index 2e3353d21..4f26baa91 100644 --- a/test/cholesky.cpp +++ b/test/cholesky.cpp @@ -100,6 +100,7 @@ template void cholesky(const MatrixType& m) VERIFY_IS_APPROX(symm * matX, matB); } +#if 0 // cholesky is not rank-revealing anyway // test isPositiveDefinite on non definite matrix if (rows>4) { @@ -109,6 +110,7 @@ template void cholesky(const MatrixType& m) LDLT cholnosqrt(symm); VERIFY(!cholnosqrt.isPositiveDefinite()); } +#endif } void test_cholesky()