\(\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}} }\)
atomic_four_rev_depend¶
View page sourceAtomic Function Reverse Dependency¶
Syntax¶
You can define one or the other of the following callbacks, but you should not define both.
Preferred¶
rev_depend
( call_id ,Deprecated 2022-05-10¶
rev_depend
( call_id ,Prototype¶
template <class Base>
bool atomic_four<Base>::rev_depend(
size_t call_id ,
const vector<bool>& ident_zero_x ,
vector<bool>& depend_x ,
const vector<bool>& depend_y )
Dependency Analysis¶
This calculation is sometimes referred to as a reverse dependency analysis.
Implementation¶
This function must be defined if afun is used to define an ADFun object f , and f.optimize() is used.
Base¶
See Base .
vector¶
is the CppAD_vector template class.
call_id¶
See call_id .
ident_zero_x¶
This can sometimes be used to create more efficient dependency (fewer true values in depend_x ). If you do not see a way to do this, you can just ignore it. This argument has size equal to the number of arguments to this atomic function; i.e. the size of ax . If ident_zero_x [ j ] is true, the argument ax [ j ] is a constant parameter that is identically zero. An identically zero value times any other value can be treated as being identically zero.
depend_x¶
This vector has size equal to the number of arguments for this atomic function;
i.e. n = ax . size
() (see ax ).
The input values of the elements of depend_x
are not specified (must not matter).
Upon return, for \(j = 0 , \ldots , n-1\),
depend_x [ j ] is true if the values of interest depend
on the value of ax [ j ] in the corresponding atomic function call.
Optimize¶
Parameters and variables, that the values of interest do not depend on, may get removed by optimization . The corresponding values in taylor_x (after optimization has removed them) are currently zero, but perhaps these should be changed back to nan.
depend_y¶
This vector has size equal to the number of results for this atomic function;
i.e. m = ay . size
() (see ay ).
For \(i = 0 , \ldots , m-1\),
depend_y [ i ] is true if the values of interest depend
on the value of ay [ i ] in the corresponding atomic function call.
ok¶
If this calculation succeeded, ok is true. Otherwise, it is false.
Example¶
The following is an example rev_depend
definition taken from
atomic_four_norm_sq.cpp :
bool rev_depend(
size_t call_id ,
CppAD::vector<bool>& depend_x ,
const CppAD::vector<bool>& depend_y ) override
{ size_t n = depend_x.size();
# ifndef NDEBUG
size_t m = depend_y.size();
assert( call_id == 0 );
assert( m == 1 );
# endif
for(size_t j = 0; j < n; ++j)
depend_x[j] = depend_y[0];
//
return true;
}