CppAD: A C++ Algorithmic Differentiation Package
20171217
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
base_hash.hpp
Go to the documentation of this file.
1
// $Id$
2
# ifndef CPPAD_CORE_BASE_HASH_HPP
3
# define CPPAD_CORE_BASE_HASH_HPP
4
/* --------------------------------------------------------------------------
5
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell
6
7
CppAD is distributed under multiple licenses. This distribution is under
8
the terms of the
9
Eclipse Public License Version 1.0.
10
11
A copy of this license is included in the COPYING file of this distribution.
12
Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
13
-------------------------------------------------------------------------- */
14
/*
15
$begin base_hash$$
16
$spell
17
alloc
18
Cpp
19
adouble
20
valgrind
21
const
22
inline
23
$$
24
25
$section Base Type Requirements for Hash Coding Values$$
26
27
$head Syntax$$
28
$icode%code% = hash_code(%x%)%$$
29
30
$head Purpose$$
31
CppAD uses a table of $icode Base$$ type values when recording
32
$codei%AD<%Base%>%$$ operations.
33
A hashing function is used to reduce number of values stored in this table;
34
for example, it is not necessary to store the value 3.0 every
35
time it is used as a $cref/parameter/parvar/$$.
36
37
$head Default$$
38
The default hashing function works with the set of bits that correspond
39
to a $icode Base$$ value.
40
In most cases this works well, but in some cases
41
it does not. For example, in the
42
$cref base_adolc.hpp$$ case, an $code adouble$$ value can have
43
fields that are not initialized and $code valgrind$$ reported an error
44
when these are used to form the hash code.
45
46
$head x$$
47
This argument has prototype
48
$codei%
49
const %Base%& %x
50
%$$
51
It is the value we are forming a hash code for.
52
53
$head code$$
54
The return value $icode code$$ has prototype
55
$codei%
56
unsigned short %code%
57
%$$
58
It is the hash code corresponding to $icode x$$. This intention is the
59
commonly used values will have different hash codes.
60
The hash code must satisfy
61
$codei%
62
%code% < CPPAD_HASH_TABLE_SIZE
63
%$$
64
so that it is a valid index into the hash code table.
65
66
$head inline$$
67
If you define this function, it should declare it to be $code inline$$,
68
so that you do not get multiple definitions from different compilation units.
69
70
$head Example$$
71
See the $code base_alloc$$ $cref/hash_code/base_alloc.hpp/hash_code/$$
72
and the $code adouble$$ $cref/hash_code/base_adolc.hpp/hash_code/$$.
73
74
$end
75
*/
76
77
/*!
78
\def CPPAD_HASH_TABLE_SIZE
79
the codes retruned by hash_code are between zero and CPPAD_HASH_TABLE_SIZE
80
minus one.
81
*/
82
# define CPPAD_HASH_TABLE_SIZE 10000
83
84
# endif
cppad
core
base_hash.hpp
Generated by
1.8.5