fix: issue 2481: LDLT produce wrong results with AutoDiffScalar

This commit is contained in:
Mario Rincon-Nigro
2022-05-25 15:26:10 +00:00
committed by Antonio Sánchez
parent 477eb7f630
commit e99163e732
3 changed files with 30 additions and 2 deletions

View File

@@ -715,6 +715,23 @@ template<typename DerType> struct NumTraits<AutoDiffScalar<DerType> >
};
};
namespace internal {
template<typename DerivativeType>
struct is_identically_zero_impl<AutoDiffScalar<DerivativeType>> {
static inline bool run(const AutoDiffScalar<DerivativeType>& s)
{
const DerivativeType& derivatives = s.derivatives();
for(int i=0; i<derivatives.size(); ++i)
{
if(!numext::is_exactly_zero(derivatives[i]))
{
return false;
}
}
return numext::is_exactly_zero(s.value());
}
};
}
}
namespace std {