mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-15 07:10:37 +08:00
Specializing numeric_limits For AutoDiffScalar
This commit is contained in:
parent
26e8f9171e
commit
2971503fed
@ -683,4 +683,11 @@ template<typename DerType> struct NumTraits<AutoDiffScalar<DerType> >
|
||||
|
||||
}
|
||||
|
||||
namespace std {
|
||||
template <typename T>
|
||||
class numeric_limits<Eigen::AutoDiffScalar<T> >
|
||||
: public numeric_limits<typename T::Scalar> {};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif // EIGEN_AUTODIFF_SCALAR_H
|
||||
|
@ -72,6 +72,19 @@ template<typename Scalar> void check_hyperbolic_functions()
|
||||
VERIFY_IS_APPROX(res3.derivatives().x(), Scalar(0.339540557256150));
|
||||
}
|
||||
|
||||
template <typename Scalar>
|
||||
void check_limits_specialization()
|
||||
{
|
||||
typedef Eigen::Matrix<Scalar, 1, 1> Deriv;
|
||||
typedef Eigen::AutoDiffScalar<Deriv> AD;
|
||||
|
||||
typedef std::numeric_limits<AD> A;
|
||||
typedef std::numeric_limits<Scalar> B;
|
||||
|
||||
bool res = std::is_base_of<B, A>::value;
|
||||
VERIFY_IS_EQUAL(res, true);
|
||||
}
|
||||
|
||||
void test_autodiff_scalar()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
@ -79,5 +92,6 @@ void test_autodiff_scalar()
|
||||
CALL_SUBTEST_2( check_atan2<double>() );
|
||||
CALL_SUBTEST_3( check_hyperbolic_functions<float>() );
|
||||
CALL_SUBTEST_4( check_hyperbolic_functions<double>() );
|
||||
CALL_SUBTEST_5( check_limits_specialization<double>());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user