base_require

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 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

Required Base Class Member Functions

base_cond_exp

Base Type Requirements for Conditional Expressions

base_identical

Base Type Requirements for Identically Equal Comparisons

base_ordered

Base Type Requirements for Ordered Comparisons

base_std_math

Base Type Requirements for Standard Math Functions

base_limits

Base Type Requirements for Numeric Limits

base_to_string

Extending to_string To Another Floating Point Type

base_hash

Base Type Requirements for Hash Coding Values

base_example

Example AD Base Types That are not AD<OtherBase>