\(\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_require¶
View page sourceAD<Base> Requirements for a CppAD Base Type¶
Syntax¶
# include <cppad/base_require.hpp>
Purpose¶
This section lists the requirements for the type
Base so that the type AD
< Base > can be used.
API Warning¶
Defining a CppAD Base type is an advanced use of CppAD.
This part of the CppAD API changes with time. The most common change
is adding more requirements.
Search for base_require
in the
current whats_new section for these changes.
Standard Base Types¶
In the case where Base is
float
,
double
,
std::complex<float>
,
std::complex<double>
,
or AD
< Other > ,
these requirements are provided by including the file
cppad/cppad.hpp
.
In the documentation, The notation \(\B{R}\) denotes
the field corresponding to the base type.
Multiplication must be commutative for this field,
but it need not be the reals; e.g., the complex numbers.
Include Order¶
If you are linking a non-standard base type to CppAD,
you must first include the file cppad/base_require.hpp
,
then provide the specifications below,
and then include the file cppad/cppad.hpp
.
Numeric Type¶
The type Base must support all the operations for a NumericType .
Output Operator¶
The type Base must support the syntax
os << x
where os is an std::ostream&
and x is a const base_alloc&
.
For example, see
base_alloc .
Integer¶
The type Base must support the syntax
i =
CppAD::Integer
( x )
which converts x to an int
.
The argument x has prototype
const
Base & x
and the return value i has prototype
int
i
Suggestion¶
In many cases, the Base version of the Integer
function
can be defined by
namespace CppAD
{inline int Integer
( const
Base & x
)return static_cast<int>
( x
); }For example, see base_float and base_alloc .
Absolute Zero, azmul¶
The type Base must support the syntax
z =
azmul
( x , y )
see; azmul . The following preprocessor macro invocation suffices (for most Base types):
namespace CppAD
{CPPAD_AZMUL
( Base )where the macro is defined by
# define CPPAD_AZMUL(Base) \
inline Base azmul(const Base& x, const Base& y) \
{ Base zero(0.0); \
if( x == zero ) \
return zero; \
return x * y; \
}
Contents¶
Name |
Title |
---|---|
base_member |
|
base_cond_exp |
|
base_identical |
|
base_ordered |
|
base_std_math |
|
base_limits |
|
base_to_string |
|
base_hash |
|
base_example |