Prev
Next
Index->
contents
reference
index
search
external
Up->
CppAD
AD
ADValued
atomic
atomic_four
atomic_four_define
atomic_four_for_type
atomic_four_for_type
Headings->
Syntax
Prototype
Dependency Analysis
Usage
Implementation
vector
Base
call_id
ad_type
type_x
type_y
ok
Example
@(@\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
.
Atomic Function Forward Type Calculation
Syntax
ok = afun .for_type( call_id , type_x , type_y )
Prototype
template < class Base >
bool atomic_four< Base>:: for_type (
size_t call_id ,
const vector< ad_type_enum>& type_x ,
vector< ad_type_enum>& type_y )
Dependency Analysis
This calculation is sometimes referred to as a forward dependency analysis.
Usage
This syntax and prototype are used a
call
to an atomic function.
Implementation
This virtual function must be defined by the
atomic_user
derived class.
vector
is the CppAD_vector
template class.
Base
See Base
.
call_id
See call_id
.
ad_type
The type CppAD::ad_type_enum
is used to specify if an AD object is a
constant parameter
dynamic parameter
or variable
.
It has the following possible values:
ad_type_enum
Meaning
identical_zero_enum
identically zero
constant_enum
constant parameter
dynamic_enum
dynamic parameter
variable_enum
variable
In addition,
identical_zero_enum < constant_enum < dynamic_enum < variable_enum
A value that is identically zero is also a constant parameter.
In CppAD, multiplication of a variable by a value that is identically zero
is sometimes treated like Absolute Zero Multiplication .
This avoids having to record the operation.
type_x
This vector has size equal to the number of arguments in the
atomic function call; i.e., the size of
ax
which we denote by
n
.
For
j =0, ... , n -1
,
type_x [ j ]
is the type of
ax [ j ]
.
type_y
This vector has size equal to the number of results in the
atomic function call; i.e., the size of
ay
which we denote by
m
.
The input values of the elements of
type_y
are not specified (must not matter).
Upon return, for @(@
i = 0 , \ldots , m-1
@)@ ,
type_y [ i ]
is set to one of the following values:
It is identical_zero_enum
if
ay [ i ]
is
identically zero
.
It is constant_enum
if
ay [ i ]
only depends on
the arguments that are constants.
It is dynamic_enum
if
ay [ i ]
depends on
a dynamic parameter and does not depend on any variables.
It is variable_enum
if
ay [ i ]
depends on
a variable.
ok
If this calculation succeeded,
ok
is true.
Otherwise, it is false.
Example
The following is an example for_type
definition taken from
atomic_four_norm_sq.cpp
:
bool for_type (
size_t call_id ,
const CppAD:: vector< CppAD:: ad_type_enum>& type_x ,
CppAD:: vector< CppAD:: ad_type_enum>& type_y ) override
{ assert ( call_id == 0 ); // default value
assert ( type_y. size () == 1 ); // m
//
// type_y
size_t n = type_x. size ();
type_y[ 0 ] = CppAD:: constant_enum;
for ( size_t j = 0 ; j < n; ++ j)
type_y[ 0 ] = std:: max ( type_y[ 0 ], type_x[ j]);
return true ;
}
Input File: include/cppad/core/atomic/four/for_type.hpp