CppAD: A C++ Algorithmic Differentiation Package
20130918
|
struct_size_pair CppAD::optimize::record_csum | ( | const CppAD::vector< struct struct_old_variable > & | tape, |
size_t | current, | ||
size_t | npar, | ||
const Base * | par, | ||
recorder< Base > * | rec, | ||
struct_csum_stacks & | work | ||
) |
Recording a cummulative cummulative summation starting at its highest parrent.
tape | is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. Note that the index for this vector must be greater than or equal zero and less than tape.size() . |
tape[i].op
is the operator in the old operation sequence corresponding to the old variable index i
. Assertion: NumRes(tape[i].op) > 0
.tape[i].arg
for j < NumArg( tape[i].op ), tape[i].arg[j]
is the j-th the argument, in the old operation sequence, corresponding to the old variable index i
. Assertion: tape[i].arg[j] < i
.tape[i].new_var
Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j]
, and j
corresponds to a variable for operator tape[i].op
. It follows that tape[k].new_var
has alread been set to the variable in the new operation sequence corresponding to the old variable index k
. This means that the new_var
value has been set for all the possible arguments that come before current.current | is the index in the old operation sequence for the variable corresponding to the result for the current operator. Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. |
npar | is the number of parameters corresponding to this operation sequence. |
par | is a vector of length npar containing the parameters for this operation sequence; i.e., given a parameter index i , the corresponding parameter value is par[i] . |
rec | is the object that will record the operations. |
work | Is used for computation. On input and output, work.op_stack.empty() , work.add_stack.empty() , and work.sub_stack.empty() , are all true true. These stacks are passed in so that elements can be allocated once and then the elements can be reused with calls to record_csum . |
tape[i].new_var
is not yet defined for any node i
that is csum_connected
to the current node (or that is sum_connected
to a node that is csum_connected
). For example; suppose that index j
corresponds to a variable in the current operator, i = tape[current].arg[j]
, and tape[arg[j]].connect_type == csum_connected
. It then follows that tape[i].new_var == tape.size()
.tape[current].op
must be one of AddpvOp, AddvvOp, SubpvOp, SubvpOp, SubvvOp
.tape[current].connect_type
must be yes_connected
.tape[j].connect_type == csum_connected
for some index j that is a variable operand for the current operation. Definition at line 1104 of file optimize.hpp.
Referenced by optimize_run().