\(\newcommand{\W}[1]{ \; #1 \; }\) \(\newcommand{\R}[1]{ {\rm #1} }\) \(\newcommand{\B}[1]{ {\bf #1} }\) \(\newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} }\) \(\newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} }\) \(\newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} }\) \(\newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }\)
base_std_math¶
View page sourceBase Type Requirements for Standard Math Functions¶
Purpose¶
These definitions are required for the user’s code to use the type
AD
< Base > :
Unary Standard Math¶
The type Base must support the following functions unary standard math functions (in the CppAD namespace):
Syntax |
Result |
y = |
absolute value |
y = |
inverse cosine |
y = |
inverse hyperbolic cosine |
y = |
inverse sine |
y = |
inverse hyperbolic sin |
y = |
inverse tangent |
y = |
inverse hyperbolic tangent |
y = |
cosine |
y = |
hyperbolic cosine |
y = |
error function |
y = |
complementary error function |
y = |
exponential |
y = |
exponential of x minus one |
y = |
absolute value |
y = |
natural logarithm |
y = |
logarithm of one plus x |
y = |
sine |
y = |
hyperbolic sine |
y = |
square root |
y = |
tangent |
where the arguments and return value have the prototypes
const
Base & xFor example, base_alloc ,
CPPAD_STANDARD_MATH_UNARY¶
The macro invocation, within the CppAD namespace,
CPPAD_STANDARD_MATH_UNARY
( Base , Fun )
defines the syntax
y =
CppAD::
Fun ( x )
This macro uses the functions std::
Fun which
must be defined and have the same prototype as CppAD::
Fun .
For example,
float .
sign¶
The type Base must support the syntax
y =
CppAD::sign
( x )
which computes
where x and y have the same prototype as above.
For example, see
base_alloc .
Note that, if ordered comparisons are not defined for the type Base ,
the code sign
function should generate an assert if it is used; see
complex invalid unary math .
pow¶
The type Base must support the syntax
z =
CppAD::pow
( x , y )
which computes \(z = x^y\). The arguments x and y have prototypes
const
Base & xconst
Base & yand the return value z has prototype
Base z
For example, see base_alloc .
isnan¶
If Base defines the isnan
function,
you may also have to provide a definition in the CppAD namespace
(to avoid a function ambiguity).
For example, see
base_complex .