Skip to content

Commit c5b56f1

Browse files
committed
bug #1528: better use numeric_limits::min() instead of 1/highest() that with underflow.
1 parent 8d0ffe3 commit c5b56f1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Eigen/src/Cholesky/LDLT.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,14 @@ void LDLT<_MatrixType,_UpLo>::_solve_impl(const RhsType &rhs, DstType &dst) cons
569569
// more precisely, use pseudo-inverse of D (see bug 241)
570570
using std::abs;
571571
const typename Diagonal<const MatrixType>::RealReturnType vecD(vectorD());
572-
// In some previous versions, tolerance was set to the max of 1/highest and the maximal diagonal entry * epsilon
573-
// as motivated by LAPACK's xGELSS:
572+
// In some previous versions, tolerance was set to the max of 1/highest (or rather numeric_limits::min())
573+
// and the maximal diagonal entry * epsilon as motivated by LAPACK's xGELSS:
574574
// RealScalar tolerance = numext::maxi(vecD.array().abs().maxCoeff() * NumTraits<RealScalar>::epsilon(),RealScalar(1) / NumTraits<RealScalar>::highest());
575575
// However, LDLT is not rank revealing, and so adjusting the tolerance wrt to the highest
576576
// diagonal element is not well justified and leads to numerical issues in some cases.
577577
// Moreover, Lapack's xSYTRS routines use 0 for the tolerance.
578-
RealScalar tolerance = RealScalar(1) / NumTraits<RealScalar>::highest();
578+
// Using numeric_limits::min() gives us more robustness to denormals.
579+
RealScalar tolerance = (std::numeric_limits<RealScalar>::min)();
579580

580581
for (Index i = 0; i < vecD.size(); ++i)
581582
{

0 commit comments

Comments
 (0)