CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
comp_op.hpp
Go to the documentation of this file.
1 // $Id: comp_op.hpp 3865 2017-01-19 01:57:55Z bradbell $
2 # ifndef CPPAD_LOCAL_COMP_OP_HPP
3 # define CPPAD_LOCAL_COMP_OP_HPP
4 
5 /* --------------------------------------------------------------------------
6 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE
18 /*!
19 \file comp_op.hpp
20 Zero order forward mode check how many comparisons changed.
21 */
22 
23 // -------------------------------- <= -----------------------------------
24 /*!
25 Zero order forward mode comparison check that left <= right
26 
27 \param count
28 It the condition is not true, ths counter is incremented by one.
29 
30 \param arg
31 parameter[ arg[0] ] is the left operand and
32 taylor[ arg[1] * cap_order + 0 ] is the zero order Taylor coefficient
33 for the right operand.
34 
35 \param parameter
36 vector of parameter values.
37 
38 \param cap_order
39 number of Taylor coefficients allocated for each variable
40 
41 \param taylor
42 vector of taylor coefficients.
43 */
44 template <class Base>
45 inline void forward_lepv_op_0(
46  size_t& count ,
47  const addr_t* arg ,
48  const Base* parameter ,
49  size_t cap_order ,
50  Base* taylor )
51 {
52  // check assumptions
55 
56  // Taylor coefficients corresponding to arguments and result
57  Base x = parameter[ arg[0] ];
58  Base* y = taylor + arg[1] * cap_order;
59 
60  count += GreaterThanZero(x - y[0]);
61 }
62 /*!
63 Zero order forward mode comparison check that left <= right
64 
65 \param count
66 It the condition is not true, ths counter is incremented by one.
67 
68 \param arg
69 taylor[ arg[0] * cap_order + 0 ] is the zero order Taylor coefficient
70 for the left operand and parameter[ arg[1] ] is the right operand
71 
72 \param parameter
73 vector of parameter values.
74 
75 \param cap_order
76 number of Taylor coefficients allocated for each variable
77 
78 \param taylor
79 vector of taylor coefficients.
80 */
81 template <class Base>
82 inline void forward_levp_op_0(
83  size_t& count ,
84  const addr_t* arg ,
85  const Base* parameter ,
86  size_t cap_order ,
87  Base* taylor )
88 {
89  // check assumptions
92 
93  // Taylor coefficients corresponding to arguments and result
94  Base* x = taylor + arg[0] * cap_order;
95  Base y = parameter[ arg[1] ];
96 
97  count += GreaterThanZero(x[0] - y);
98 }
99 /*!
100 Zero order forward mode comparison check that left <= right
101 
102 \param count
103 It the condition is not true, ths counter is incremented by one.
104 
105 \param arg
106 taylor[ arg[0] * cap_order + 0 ] is the zero order Taylor coefficient
107 for the left operand and
108 taylor[ arg[1] * cap_order + 0 ] is the zero order Taylor coefficient
109 for the right operand.
110 
111 \param parameter
112 vector of parameter values.
113 
114 \param cap_order
115 number of Taylor coefficients allocated for each variable
116 
117 \param taylor
118 vector of taylor coefficients.
119 */
120 template <class Base>
121 inline void forward_levv_op_0(
122  size_t& count ,
123  const addr_t* arg ,
124  const Base* parameter ,
125  size_t cap_order ,
126  Base* taylor )
127 {
128  // check assumptions
131 
132  // Taylor coefficients corresponding to arguments and result
133  Base* x = taylor + arg[0] * cap_order;
134  Base* y = taylor + arg[1] * cap_order;
135 
136  count += GreaterThanZero(x[0] - y[0]);
137 }
138 // ------------------------------- < -------------------------------------
139 /*!
140 Zero order forward mode comparison check that left < right
141 
142 \copydetails CppAD::local::forward_lepv_op_0
143 */
144 template <class Base>
145 inline void forward_ltpv_op_0(
146  size_t& count ,
147  const addr_t* arg ,
148  const Base* parameter ,
149  size_t cap_order ,
150  Base* taylor )
151 {
152  // check assumptions
155 
156  // Taylor coefficients corresponding to arguments and result
157  Base x = parameter[ arg[0] ];
158  Base* y = taylor + arg[1] * cap_order;
159 
160  count += GreaterThanOrZero(x - y[0]);
161 }
162 /*!
163 Zero order forward mode comparison check that left < right
164 
165 \copydetails CppAD::local::forward_levp_op_0
166 */
167 template <class Base>
168 inline void forward_ltvp_op_0(
169  size_t& count ,
170  const addr_t* arg ,
171  const Base* parameter ,
172  size_t cap_order ,
173  Base* taylor )
174 {
175  // check assumptions
178 
179  // Taylor coefficients corresponding to arguments and result
180  Base* x = taylor + arg[0] * cap_order;
181  Base y = parameter[ arg[1] ];
182 
183  count += GreaterThanOrZero(x[0] - y);
184 }
185 /*!
186 Zero order forward mode comparison check that left < right
187 
188 \copydetails CppAD::local::forward_levv_op_0
189 */
190 template <class Base>
191 inline void forward_ltvv_op_0(
192  size_t& count ,
193  const addr_t* arg ,
194  const Base* parameter ,
195  size_t cap_order ,
196  Base* taylor )
197 {
198  // check assumptions
201 
202  // Taylor coefficients corresponding to arguments and result
203  Base* x = taylor + arg[0] * cap_order;
204  Base* y = taylor + arg[1] * cap_order;
205 
206  count += GreaterThanOrZero(x[0] - y[0]);
207 }
208 // ------------------------------ == -------------------------------------
209 /*!
210 Zero order forward mode comparison check that left == right
211 
212 \copydetails CppAD::local::forward_lepv_op_0
213 */
214 template <class Base>
215 inline void forward_eqpv_op_0(
216  size_t& count ,
217  const addr_t* arg ,
218  const Base* parameter ,
219  size_t cap_order ,
220  Base* taylor )
221 {
222  // check assumptions
225 
226  // Taylor coefficients corresponding to arguments and result
227  Base x = parameter[ arg[0] ];
228  Base* y = taylor + arg[1] * cap_order;
229 
230  count += (x != y[0]);
231 }
232 /*!
233 Zero order forward mode comparison check that left == right
234 
235 \copydetails CppAD::local::forward_levv_op_0
236 */
237 template <class Base>
238 inline void forward_eqvv_op_0(
239  size_t& count ,
240  const addr_t* arg ,
241  const Base* parameter ,
242  size_t cap_order ,
243  Base* taylor )
244 {
245  // check assumptions
248 
249  // Taylor coefficients corresponding to arguments and result
250  Base* x = taylor + arg[0] * cap_order;
251  Base* y = taylor + arg[1] * cap_order;
252 
253  count += (x[0] != y[0]);
254 }
255 // -------------------------------- != -----------------------------------
256 /*!
257 Zero order forward mode comparison check that left != right
258 
259 \copydetails CppAD::local::forward_lepv_op_0
260 */
261 template <class Base>
262 inline void forward_nepv_op_0(
263  size_t& count ,
264  const addr_t* arg ,
265  const Base* parameter ,
266  size_t cap_order ,
267  Base* taylor )
268 {
269  // check assumptions
272 
273  // Taylor coefficients corresponding to arguments and result
274  Base x = parameter[ arg[0] ];
275  Base* y = taylor + arg[1] * cap_order;
276 
277  count += (x == y[0]);
278 }
279 /*!
280 Zero order forward mode comparison check that left != right
281 
282 \copydetails CppAD::local::forward_levv_op_0
283 */
284 template <class Base>
285 inline void forward_nevv_op_0(
286  size_t& count ,
287  const addr_t* arg ,
288  const Base* parameter ,
289  size_t cap_order ,
290  Base* taylor )
291 {
292  // check assumptions
295 
296  // Taylor coefficients corresponding to arguments and result
297  Base* x = taylor + arg[0] * cap_order;
298  Base* y = taylor + arg[1] * cap_order;
299 
300  count += (x[0] == y[0]);
301 }
302 
303 
304 } } // END_CPPAD_LOCAL_NAMESPACE
305 # endif
void forward_levp_op_0(size_t &count, const addr_t *arg, const Base *parameter, size_t cap_order, Base *taylor)
Zero order forward mode comparison check that left &lt;= right.
Definition: comp_op.hpp:82
void forward_nepv_op_0(size_t &count, const addr_t *arg, const Base *parameter, size_t cap_order, Base *taylor)
Zero order forward mode comparison check that left != right.
Definition: comp_op.hpp:262
CPPAD_TAPE_ADDR_TYPE addr_t
Definition: declare_ad.hpp:44
void forward_nevv_op_0(size_t &count, const addr_t *arg, const Base *parameter, size_t cap_order, Base *taylor)
Zero order forward mode comparison check that left != right.
Definition: comp_op.hpp:285
size_t NumArg(OpCode op)
Number of arguments for a specified operator.
Definition: op_code.hpp:175
bool GreaterThanOrZero(const std::complex< double > &x)
size_t NumRes(OpCode op)
Number of variables resulting from the specified operation.
Definition: op_code.hpp:281
void forward_eqpv_op_0(size_t &count, const addr_t *arg, const Base *parameter, size_t cap_order, Base *taylor)
Zero order forward mode comparison check that left == right.
Definition: comp_op.hpp:215
void forward_eqvv_op_0(size_t &count, const addr_t *arg, const Base *parameter, size_t cap_order, Base *taylor)
Zero order forward mode comparison check that left == right.
Definition: comp_op.hpp:238
void forward_levv_op_0(size_t &count, const addr_t *arg, const Base *parameter, size_t cap_order, Base *taylor)
Zero order forward mode comparison check that left &lt;= right.
Definition: comp_op.hpp:121
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
void forward_ltvp_op_0(size_t &count, const addr_t *arg, const Base *parameter, size_t cap_order, Base *taylor)
Zero order forward mode comparison check that left &lt; right.
Definition: comp_op.hpp:168
void forward_ltpv_op_0(size_t &count, const addr_t *arg, const Base *parameter, size_t cap_order, Base *taylor)
Zero order forward mode comparison check that left &lt; right.
Definition: comp_op.hpp:145
void forward_lepv_op_0(size_t &count, const addr_t *arg, const Base *parameter, size_t cap_order, Base *taylor)
Zero order forward mode comparison check that left &lt;= right.
Definition: comp_op.hpp:45
void forward_ltvv_op_0(size_t &count, const addr_t *arg, const Base *parameter, size_t cap_order, Base *taylor)
Zero order forward mode comparison check that left &lt; right.
Definition: comp_op.hpp:191
bool GreaterThanZero(const std::complex< double > &x)