CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
base_require.hpp
Go to the documentation of this file.
1 // $Id: base_require.hpp 3845 2016-11-19 01:50:47Z bradbell $
2 # ifndef CPPAD_BASE_REQUIRE_HPP
3 # define CPPAD_BASE_REQUIRE_HPP
4 
5 /* --------------------------------------------------------------------------
6 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell
7 
8 CppAD is distributed under multiple licenses. This distribution is under
9 the terms of the
10  Eclipse Public License Version 1.0.
11 
12 A copy of this license is included in the COPYING file of this distribution.
13 Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
14 -------------------------------------------------------------------------- */
15 
16 /*
17 $begin base_require$$
18 $spell
19  azmul
20  ostream
21  alloc
22  eps
23  std
24  Lt
25  Le
26  Eq
27  Ge
28  Gt
29  cppad.hpp
30  namespace
31  optimizations
32  bool
33  const
34  CppAD
35  enum
36  Lt
37  Le
38  Eq
39  Ge
40  Gt
41  inline
42  Op
43  std
44  CondExp
45 $$
46 
47 $section AD<Base> Requirements for a CppAD Base Type$$
48 
49 $head Syntax$$
50 $code # include <cppad/base_require.hpp>$$
51 
52 $head Purpose$$
53 This section lists the requirements for the type
54 $icode Base$$ so that the type $codei%AD<%Base%>%$$ can be used.
55 
56 $head API Warning$$
57 Defining a CppAD $icode Base$$ type is an advanced use of CppAD.
58 This part of the CppAD API changes with time. The most common change
59 is adding more requirements.
60 Search for $code base_require$$ in the
61 current $cref whats_new$$ section for these changes.
62 
63 $head Standard Base Types$$
64 In the case where $icode Base$$ is
65 $code float$$,
66 $code double$$,
67 $code std::complex<float>$$,
68 $code std::complex<double>$$,
69 or $codei%AD<%Other%>%$$,
70 these requirements are provided by including the file
71 $code cppad/cppad.hpp$$.
72 
73 $head Include Order$$
74 If you are linking a non-standard base type to CppAD,
75 you must first include the file $code cppad/base_require.hpp$$,
76 then provide the specifications below,
77 and then include the file $code cppad/cppad.hpp$$.
78 
79 $head Numeric Type$$
80 The type $icode Base$$ must support all the operations for a
81 $cref NumericType$$.
82 
83 $head Output Operator$$
84 The type $icode Base$$ must support the syntax
85 $codei%
86  %os% << %x%
87 %$$
88 where $icode os$$ is an $code std::ostream&$$
89 and $icode x$$ is a $code const base_alloc&$$.
90 For example, see
91 $cref/base_alloc/base_alloc.hpp/Output Operator/$$.
92 
93 $head Integer$$
94 The type $icode Base$$ must support the syntax
95 $codei%
96  %i% = CppAD::Integer(%x%)
97 %$$
98 which converts $icode x$$ to an $code int$$.
99 The argument $icode x$$ has prototype
100 $codei%
101  const %Base%& %x%
102 %$$
103 and the return value $icode i$$ has prototype
104 $codei%
105  int %i%
106 %$$
107 
108 $subhead Suggestion$$
109 In many cases, the $icode Base$$ version of the $code Integer$$ function
110 can be defined by
111 $codei%
112 namespace CppAD {
113  inline int Integer(const %Base%& x)
114  { return static_cast<int>(x); }
115 }
116 %$$
117 For example, see
118 $cref/base_float/base_float.hpp/Integer/$$ and
119 $cref/base_alloc/base_alloc.hpp/Integer/$$.
120 
121 $head Absolute Zero, azmul$$
122 The type $icode Base$$ must support the syntax
123 $codei%
124  %z% = azmul(%x%, %y%)
125 %$$
126 see; $cref azmul$$.
127 The following preprocessor macro invocation suffices
128 (for most $icode Base$$ types):
129 $codei%
130 namespace CppAD {
131  CPPAD_AZMUL(%Base%)
132 }
133 %$$
134 where the macro is defined by
135 $srccode%cpp% */
136 # define CPPAD_AZMUL(Base) \
137  inline Base azmul(const Base& x, const Base& y) \
138  { Base zero(0.0); \
139  if( x == zero ) \
140  return zero; \
141  return x * y; \
142  }
143 /* %$$
144 
145 $childtable%
146  omh/base_require/base_member.omh%
147  cppad/core/base_cond_exp.hpp%
148  omh/base_require/base_identical.omh%
149  omh/base_require/base_ordered.omh%
150  cppad/core/base_std_math.hpp%
151  cppad/core/base_limits.hpp%
152  cppad/core/base_to_string.hpp%
153  cppad/core/base_hash.hpp%
154  omh/base_require/base_example.omh
155 %$$
156 
157 $end
158 */
159 
160 // definitions that must come before base implementations
162 # include <cppad/core/define.hpp>
163 # include <cppad/core/cppad_assert.hpp>
164 # include <cppad/local/declare_ad.hpp>
165 
166 // grouping documentation by feature
169 # include <cppad/core/base_limits.hpp>
171 # include <cppad/core/base_hash.hpp>
172 
173 // must define template class numeric_limits before the base cases
175 # include <cppad/core/epsilon.hpp> // deprecated
176 
177 // base cases that come with CppAD
178 # include <cppad/core/base_float.hpp>
179 # include <cppad/core/base_double.hpp>
180 # include <cppad/core/base_complex.hpp>
181 
182 // deprecated base type
183 # include <cppad/core/zdouble.hpp>
184 
185 # endif
Define processor symbols and macros that are used by CppAD.
Define the CppAD error checking macros (all of which begin with CPPAD_ASSERT_)
CondExp operations that aid in meeting Base type requirements.
CppAD forward declarations; i.e., before definition.
Define a class like double but with an absolute zero.
Defintions that aid meeting Base type requirements for standard math functions.
File that defines CppAD numeric_limits for AD types.