mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 19:59:05 +08:00
bug #1528: better use numeric_limits::min() instead of 1/highest() that with underflow.
This commit is contained in:
parent
8d0ffe3655
commit
c5b56f1fb2
@ -569,13 +569,14 @@ void LDLT<_MatrixType,_UpLo>::_solve_impl(const RhsType &rhs, DstType &dst) cons
|
|||||||
// more precisely, use pseudo-inverse of D (see bug 241)
|
// more precisely, use pseudo-inverse of D (see bug 241)
|
||||||
using std::abs;
|
using std::abs;
|
||||||
const typename Diagonal<const MatrixType>::RealReturnType vecD(vectorD());
|
const typename Diagonal<const MatrixType>::RealReturnType vecD(vectorD());
|
||||||
// In some previous versions, tolerance was set to the max of 1/highest and the maximal diagonal entry * epsilon
|
// In some previous versions, tolerance was set to the max of 1/highest (or rather numeric_limits::min())
|
||||||
// as motivated by LAPACK's xGELSS:
|
// and the maximal diagonal entry * epsilon as motivated by LAPACK's xGELSS:
|
||||||
// RealScalar tolerance = numext::maxi(vecD.array().abs().maxCoeff() * NumTraits<RealScalar>::epsilon(),RealScalar(1) / NumTraits<RealScalar>::highest());
|
// RealScalar tolerance = numext::maxi(vecD.array().abs().maxCoeff() * NumTraits<RealScalar>::epsilon(),RealScalar(1) / NumTraits<RealScalar>::highest());
|
||||||
// However, LDLT is not rank revealing, and so adjusting the tolerance wrt to the highest
|
// However, LDLT is not rank revealing, and so adjusting the tolerance wrt to the highest
|
||||||
// diagonal element is not well justified and leads to numerical issues in some cases.
|
// diagonal element is not well justified and leads to numerical issues in some cases.
|
||||||
// Moreover, Lapack's xSYTRS routines use 0 for the tolerance.
|
// Moreover, Lapack's xSYTRS routines use 0 for the tolerance.
|
||||||
RealScalar tolerance = RealScalar(1) / NumTraits<RealScalar>::highest();
|
// Using numeric_limits::min() gives us more robustness to denormals.
|
||||||
|
RealScalar tolerance = (std::numeric_limits<RealScalar>::min)();
|
||||||
|
|
||||||
for (Index i = 0; i < vecD.size(); ++i)
|
for (Index i = 0; i < vecD.size(); ++i)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user