Base Type Requirements for Numeric Limits
Keywords: base type requirements numeric limits cppad::numeric_limits cppad_numeric_limits

| Prev | Next |  |  |  |  |  | base_limits |

Base Type Requirements for Numeric Limits
CppAD::numeric_limits
A specialization for CppAD::numeric_limits must be defined in order to use the type `AD<Base>` . CppAD does not use a specialization of `std::numeric_limits<Base>` . Since C++11, using a specialization of `std::numeric_limits<Base>` would require that `Base` be a literal type.
CPPAD_NUMERIC_LIMITS
In most cases, this macro can be used to define the specialization where the numeric limits for the type `Base` are the same as the standard numeric limits for the type `Other` . For most `Base` types, there is a choice of `Other` , for which the following preprocessor macro invocation suffices: `
namespace CppAD {
CPPAD_NUMERIC_LIMITS(Other, Base)
}
` where the macro is defined by `

    # define CPPAD_NUMERIC_LIMITS(Other, Base) \
    template <> class numeric_limits<Base>\
    {\
         public:\
         static Base min(void) \
         {    return static_cast<Base>( std::numeric_limits<Other>::min() ); }\
         static Base max(void) \
         {    return static_cast<Base>( std::numeric_limits<Other>::max() ); }\
         static Base epsilon(void) \
         {    return static_cast<Base>( std::numeric_limits<Other>::epsilon() ); }\
         static Base quiet_NaN(void) \
         {    return static_cast<Base>( std::numeric_limits<Other>::quiet_NaN() ); }\
    };

`

Input File: cppad/local/base_limits.hpp