![]() |
Prev | Next | atomic_four_for_type |
ok = afun.for_type(call_id, type_x, type_y)
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 )
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 |
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.
n
.
For
j =0,...,n-1
,
type_x[j]
is the type of
ax[j]
.
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:
identical_zero_enum
if
ay[i]
is
identically zero
.
constant_enum
if
ay[i]
only depends on
the arguments that are constants.
dynamic_enum
if
ay[i]
depends on
a dynamic parameter and does not depend on any variables.
variable_enum
if
ay[i]
depends on
a variable.
ok
is true.
Otherwise, it is false.
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; }