CppAD: A C++ Algorithmic Differentiation Package 20110419
template<class Base >
size_t optimize_unary_match ( const CppAD::vector< struct optimize_old_variable > &  tape,
size_t  current,
size_t  npar,
const Base *  par,
const CppAD::vector< size_t > &  hash_table_var,
unsigned short &  code 
)

Check a unary operator for a complete match with a previous operator.

A complete match means that the result of the previous operator can be used inplace of the result for current operator.

Parameters:
tapeis a vector that maps a variable index, in the old operation sequence, to an optimize_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 varialbe 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.
Parameters:
currentis 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.
nparis the number of paraemters corresponding to this operation sequence.
paris 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].
Parameters:
hash_table_varis a vector with size CPPAD_HASH_TABLE_SIZE that maps a hash code to the corresponding variable index in the old operation sequence. All the values in this table must be less than current.
codeThe input value of code does not matter. The output value of code is the hash code corresponding to this operation in the new operation sequence.
Returns:
If the return value is zero, no match was found. If the return value is greater than zero, it is the index of a new variable that can be used to replace the old variable.
Restrictions:
NumArg( tape[current].op ) == 1

Definition at line 300 of file optimize.hpp.

Referenced by optimize().