\(\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}} }\)
base_hash
Base Type Requirements for Hash Coding Values
Syntax
code = hash_code
( x )
Purpose
CppAD uses a table of Base type values when recording
AD<
Base > operations.
A hashing function is used to reduce number of values stored in this table;
for example, it is not necessary to store the value 3.0 every
time it is used as a Parameter .
Default
The default hashing function works with the set of bits that correspond
to a Base value.
In most cases this works well, but in some cases
it does not. For example, in the
base_adolc.hpp case, an adouble
value can have
fields that are not initialized and valgrind
reported an error
when these are used to form the hash code.
x
This argument has prototype
const
Base
&x
It is the value we are forming a hash code for.
code
The return value code has prototype
unsigned short
code
It is the hash code corresponding to x . This intention is the commonly used values will have different hash codes. The hash code must satisfy
code <
CPPAD_HASH_TABLE_SIZE
so that it is a valid index into the hash code table.
inline
If you define this function, it should declare it to be inline
,
so that you do not get multiple definitions from different compilation units.