CppAD: A C++ Algorithmic Differentiation Package  20130102
#define CPPAD_STANDARD_MATH_UNARY_AD (   Name,
  Op 
)
Value:
template <class Base>                                         \
    inline AD<Base> Name(const AD<Base> &x)                       \
    {   return x.Name(); }                                        \
    template <class Base>                                         \
    inline AD<Base> AD<Base>::Name (void) const                   \
    {                                                             \
        AD<Base> result;                                          \
        result.value_ = CppAD::Name(value_);                      \
        CPPAD_ASSERT_UNKNOWN( Parameter(result) );                \
                                                                  \
        if( Variable(*this) )                                     \
        {   CPPAD_ASSERT_UNKNOWN( NumRes(Op) <= 2 );              \
            CPPAD_ASSERT_UNKNOWN( NumArg(Op) == 1 );              \
            ADTape<Base> *tape = tape_this();                     \
            tape->Rec_.PutArg(taddr_);                            \
            result.taddr_ = tape->Rec_.PutOp(Op);                 \
            result.tape_id_    = tape->id_;                            \
        }                                                         \
        return result;                                            \
    }                                                             \
    template <class Base>                                         \
    inline AD<Base> Name(const VecAD_reference<Base> &x)          \
    {   return Name( x.ADBase() ); }

Defines function Name with argument type AD<Base> and tape operation Op.

The macro defines the function x.Name() where x has type AD<Base>. It then uses this funciton to define Name(x) where x has type AD<Base> or VecAD_reference<Base>.

If x is a variable, the tape unary operator Op is used to record the operation and the result is identified as correspoding to this operation; i.e., Name(x).taddr_ idendifies the operation and Name(x).tape_id_ identifies the tape.

This macro is used to define AD<Base> versions of acos, asin, atan, cos, cosh, exp, fabs, log, sin, sinh, sqrt, tan, tanh.

Definition at line 278 of file std_math_ad.hpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines