Closed benmwebb closed 2 years ago
The new relevant code in Eigen is
// IEEE IEC 6059 special cases.
if ((numext::isinf)(x) || (numext::isinf)(y))
return NumTraits<RealScalar>::infinity();
if ((numext::isnan)(x) || (numext::isnan)(y))
return NumTraits<RealScalar>::quiet_NaN();
So CppAD would also need an overload for isinf(const CppAD::AD<RealScalar>&)
and isnan(const CppAD::AD<RealScalar>&)
in order to compile. I'll see if I can concoct a PR.
@benmwebb I am busy with other things right now. Perhaps you would like to clone the current master and make a try at what you want here.
I think this is going to require additions to the following file: https://github.com/coin-or/CppAD/blob/master/include/cppad/example/cppad_eigen.hpp
The easiest cases to do in general are probably those that are already in the CppAD::numeric_limits; see https://coin-or.github.io/CppAD/doc/numeric_limits.htm.
To extend this to any base type one would have to add to the base type requirements; see https://coin-or.github.io/CppAD/doc/base_limits.htm
@bradbell OK, I made a PR which fixes this issue for me, and did my best to add suitable test cases; all tests pass on my machine.
Trying to build this simple (and contrived) test program with latest CppAD and Eigen 3.4.0 (e.g. as packaged in Fedora 36) fails (it worked in Fedora 35, which ships Eigen 3.3.9):
Compilation fails with
This appears to be because
NumTraits<RealScalar>::infinity()
andNumTraits<RealScalar>::quiet_NaN()
in thepositive_real_hypot()
function inEigen/src/Core/MathFunctionsImpl.h
as of commit bde674164.Eigen::NumTraits
incppad/example/cppad_eigen.hpp
does not defineinfinity()
orquiet_NaN()
.