CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
template<class Base >
void CppAD::local::optimize::match_op ( const player< Base > *  play,
vector< struct_opt_op_info > &  opt_op_info,
size_t  current,
sparse_list &  hash_table_op 

Search for a previous operator that matches the current one.

If an argument for the current operator is a variable, and the argument has previous match, the previous match for the argument is used when checking for a match for the current operator.

playThis is the old operation sequence.
opt_op_infoMapping from operator index to operator information. The input value of opt_op_info[current].previous is assumed to be zero. If a match if found, the output value of opt_op_info[current].previous is set to the matching operator index, otherwise it is left as is. Note that opt_op_info[current].previous < current.
currentis the index of the current operator which must be an unary or binary operator. Note that NumArg(ErfOp) == 3 but it is effectivey a unary operator and is allowed otherwise NumArg( opt_op_info[current].op) < 3. It is assumed that hash_table_op is initialized as a vector of emtpy sets. After this initialization, the value of current inceases with each call to match_op.
  • This must be a unary or binary operator; hence, NumArg( opt_op_info[current].op ) is one or two. There is one exception, NumRes( ErfOp ) == 3, but arg[0] is the only true arguments (the others are always the same).
  • This must not be a VecAD load or store operation; i.e., LtpvOp, LtvpOp, LtvvOp, StppOp, StpvOp, StvpOp, StvvOp. It also must not be an independent variable operator InvOp.
hash_table_opis a vector of sets, hash_table_op.n_set() == CPPAD_HASH_TABLE_SIZE and hash_table_op.end() == opt_op_info.size(). If i_op is an element of set[j], then the operation opt_op_info[i_op] has hash code j, and opt_op_info[i_op] does not match any other element of set[j]. An entry will be added each time match_op is called and a match for the current operator is not found.

Definition at line 69 of file match_op.hpp.

Referenced by get_opt_op_info().