CondExpOp
The type float is a relatively simple type that supports
<, <=, ==, >=, and > operators; see
ordered type
.
Hence its CondExpOp function is defined by
namespace CppAD {inlinefloatCondExpOp(enumCompareOp cop ,constfloat& left ,constfloat& right ,constfloat& exp_if_true ,constfloat& exp_if_false ){returnCondExpTemplate(cop, left, right, exp_if_true, exp_if_false);}}
Ordered
The float type supports ordered comparisons
namespace CppAD {inlineboolGreaterThanZero(constfloat& x){return x >0.f;}inlineboolGreaterThanOrZero(constfloat& x){return x >=0.f;}inlineboolLessThanZero(constfloat& x){return x <0.f;}inlineboolLessThanOrZero(constfloat& x){return x <=0.f;}inlineboolabs_geq(constfloat& x,constfloat& y){return std::fabs(x)>= std::fabs(y);}}
Unary Standard Math
The following macro invocations import the float versions of
the unary standard math functions into the CppAD namespace.
Importing avoids ambiguity errors when using both the
CppAD and std namespaces.
Note this also defines the double
versions of these functions.
sign
The following defines the CppAD::sign function that
is required to use AD<float>:
namespace CppAD {inlinefloatsign(constfloat& x){if( x >0.f )return1.f;if( x ==0.f )return0.f;return-1.f;}}
pow
The following defines a CppAD::pow function that
is required to use AD<float>.
As with the unary standard math functions,
this has the exact same signature as std::pow,
so use it instead of defining another function.
to_string
There is no need to define to_string for float
because it is defined by including cppad/utility/to_string.hpp;
see to_string
.
See base_complex.hpp
for an example where
it is necessary to define to_string for a
Base
type.
Input File: cppad/core/base_float.hpp