CppAD: A C++ Algorithmic Differentiation Package 20110419
template<class Base >
unsigned short hash_code ( OpCode  op,
const size_t *  arg,
size_t  npar,
const Base *  par 
)

Specialized hash code for a CppAD operator and its arguments.

Parameters:
opis the operator that we are computing a hash code for. If it is not one of the following operartors, the operator is not hash coded and zero is returned:
  • unary operators: AbsOp, AcosOp, AsinOp, AtanOp, CosOp, CoshOp, DisOp, ExpOp, LogOp, SinOp, SinhOp, SqrtOp
  • binary operators where first argument is a parameter: AddpvOp, DivpvOp, MulpvOp, PowpvOp, SubpvOp,
  • binary operators where second argument is a parameter: DivvpOp, PowvpOp, SubvpOp
  • binary operators where both arguments are parameters: AddvvOp, DivvvOp, MulvvOp, PowvvOp, SubvvOp
Parameters:
argis a vector of length NumArg(op) or 2 (which ever is smaller), containing the corresponding argument indices for this operator.
nparis the number of parameters corresponding to this operation sequence.
paris a vector of length npar containing the parameters for this operation sequence; i.e., given a parameter index of i, the corresponding parameter value is par[i].
Returns:
is a hash code that is between zero and CPPAD_HASH_TABLE_SIZE - 1.
Checked Assertions
op must be one of the operators specified above. In addition,
  • std::numeric_limits<unsigned short>::max() == CPPAD_HASH_TABLE_SIZE - 1
  • sizeof(size_t) is even
  • sizeof(Base) is even
  • sizeof(unsigned short) == 2
  • size_t(op) <= size_t(SubvvOp) < CPPAD_HASH_TABLE_SIZE
  • if the j-th argument for this operation is a parameter, arg[j] < npar.

Definition at line 123 of file hash_code.hpp.