Prev Next

@(@\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}} }@)@This is cppad-20221105 documentation. Here is a link to its current documentation .
AD<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 
Basex
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(xy)
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
base_memberRequired Base Class Member Functions
base_cond_expBase Type Requirements for Conditional Expressions
base_identicalBase Type Requirements for Identically Equal Comparisons
base_orderedBase Type Requirements for Ordered Comparisons
base_std_mathBase Type Requirements for Standard Math Functions
base_limitsBase Type Requirements for Numeric Limits
base_to_stringExtending to_string To Another Floating Point Type
base_hashBase Type Requirements for Hash Coding Values
base_exampleExample AD Base Types That are not AD<OtherBase>

Input File: include/cppad/base_require.hpp