CppADCodeGen  2.3.0
A C++ Algorithmic Differentiation Package with Source Code Generation
declare_cg.hpp
1 #ifndef CPPAD_CG_DECLARE_CG_INCLUDED
2 #define CPPAD_CG_DECLARE_CG_INCLUDED
3 /* --------------------------------------------------------------------------
4  * CppADCodeGen: C++ Algorithmic Differentiation with Source Code Generation:
5  * Copyright (C) 2012 Ciengis
6  *
7  * CppADCodeGen is distributed under multiple licenses:
8  *
9  * - Eclipse Public License Version 1.0 (EPL1), and
10  * - GNU General Public License Version 3 (GPL3).
11  *
12  * EPL1 terms and conditions can be found in the file "epl-v10.txt", while
13  * terms and conditions for the GPL3 can be found in the file "gpl3.txt".
14  * ----------------------------------------------------------------------------
15  * Author: Joao Leal
16  */
17 
18 // forward declarations
19 namespace CppAD {
20 
21 template<class Base>
22 class vector;
23 
24 template<class Base>
25 class AD;
26 
27 template<class Base>
28 class ADFun;
29 
30 namespace cg {
31 
32 /***************************************************************************
33  * Atomics
34  **************************************************************************/
35 template<class Base>
36 class BaseAbstractAtomicFun;
37 
38 template<class Base>
39 class CGAbstractAtomicFun;
40 
41 template<class Base>
42 class CGAtomicFun;
43 
44 template<class Base>
45 class AtomicUseInfo;
46 
47 /***************************************************************************
48  * Core
49  **************************************************************************/
50 template<class Base>
51 class CodeHandler;
52 
53 template<class Base>
54 class CodeHandlerVectorSync;
55 
56 template<class Base, class T>
57 class CodeHandlerVector;
58 
59 template<class Base>
60 class CG;
61 
62 template<class Base>
64 
65 template<class Base>
66 class PathNodeEdges;
67 
68 template<class Base>
69 class BidirGraph;
70 
71 template<class Base>
73 
74 /***************************************************************************
75  * Nodes
76  **************************************************************************/
77 template<class Base>
78 class OperationNode;
79 
80 template<class Base>
82 
83 template<class Base>
85 
86 template<class Base>
88 
89 template<class Base>
91 
92 /***************************************************************************
93  * Loops
94  **************************************************************************/
95 template<class Base>
97 
98 template<class Base>
100 
101 template<class Base>
102 class Loop;
103 
104 template<class Base>
106 
107 template<class Base>
108 class LoopModel;
109 
110 template<class Base>
112 
113 class IndexPattern;
114 class LinearIndexPattern;
115 class Plane2DIndexPattern;
116 class RandomIndexPattern;
118 
119 /***************************************************************************
120  * Languages
121  **************************************************************************/
122 
123 template<class Base>
124 class LanguageC;
125 
126 template<class Base>
128 
129 template<class Base>
131 
132 template<class Base>
134 
135 /***************************************************************************
136  * Models
137  **************************************************************************/
138 template<class Base>
140 
141 template<class Base>
143 
144 template<class Base>
146 
147 /***************************************************************************
148  * Dynamic model compilation
149  **************************************************************************/
150 
151 template<class Base>
152 class CCompiler;
153 
154 template<class Base>
156 
157 template<class Base>
159 
160 template<class Base>
162 
163 #if CPPAD_CG_SYSTEM_LINUX
164 template<class Base>
165 class LinuxDynamicLibModel;
166 
167 template<class Base>
168 class LinuxDynamicLib;
169 #endif
170 
171 /***************************************************************************
172  * Index reduction classes
173  **************************************************************************/
174 template<class Base>
175 class Enode;
176 
177 template<class Base>
178 class Vnode;
179 
180 template<class ScalarIn, class ScalarOut, class ActiveOut>
181 class Evaluator;
182 
183 /***************************************************************************
184  * Utilities
185  **************************************************************************/
186 
187 template<class Base>
189 
190 template<class Base>
192 
193 template<class Key, class Value>
195 
196 template<class Type>
197 class ArrayView;
198 
199 template<class Base>
200 inline void print(const Base& v);
201 
202 template<class Key, class Value>
203 inline void print(const std::map<Key, Value>& m);
204 
205 template<class Base>
206 inline void print(const std::set<Base>& s);
207 
208 template<class Base>
209 inline void print(const std::set<Base*>& s);
210 
211 template<class Base>
212 inline void print(const std::vector<Base>& v);
213 
217 template<class Base>
218 CG<Base> operator+(const CG<Base>& left, const CG<Base>& right);
219 
220 template<class Base>
221 CG<Base> operator-(const CG<Base>& left, const CG<Base>& right);
222 
223 template<class Base>
224 CG<Base> operator*(const CG<Base>& left, const CG<Base>& right);
225 
226 template<class Base>
227 CG<Base> operator/(const CG<Base>& left, const CG<Base>& right);
228 
232 template<class Base>
233 bool operator==(const CG<Base>& left, const CG<Base>& right);
234 
235 template<class Base>
236 bool operator!=(const CG<Base>& left, const CG<Base>& right);
237 
238 template<class Base>
239 bool operator<(const CG<Base>& left, const CG<Base>& right);
240 
241 template<class Base>
242 bool operator<=(const CG<Base>& left, const CG<Base>& right);
243 
244 template<class Base>
245 bool operator>(const CG<Base>& left, const CG<Base>& right);
246 
247 template<class Base>
248 bool operator>=(const CG<Base>& left, const CG<Base>& right);
249 
250 template<class Base>
251 bool operator!=(const CG<Base>& left, double right);
252 
253 template<class Base>
254 bool operator==(const CG<Base>& left, const Base& right);
255 
256 template<class Base>
257 bool operator==(const Base& left, const CG<Base>& right);
258 
259 template<class Base>
260 bool operator!=(const CG<Base>& left, Base right);
261 
262 template<class Base>
263 bool operator!=(const Base& left, const CG<Base>& right);
264 
265 /***************************************************************************
266  * Index reduction functions
267  **************************************************************************/
268 
269 template<class Base>
270 inline std::ostream& operator<<(std::ostream& os, const Enode<Base>& i);
271 
272 template<class Base>
273 inline std::ostream& operator<<(std::ostream& os, const Vnode<Base>& j);
274 
275 /***************************************************************************
276  * Enums
277  **************************************************************************/
278 
282 enum class Verbosity {
283  None, Low, High
284 };
285 
289 enum class JacobianADMode {
290  Forward, Reverse, Automatic
291 };
292 
296 enum class IndexPatternType {
297  Linear, // y = (x / dx) * dy + b
298  Sectioned, // several index patterns
299  Random1D,
300  Random2D,
301  Plane2D // y = f(x) + f(z)
302 };
303 
304 } // END cg namespace
305 
306 /***************************************************************************
307  *
308  **************************************************************************/
309 // order determining functions, see ordered.hpp
310 template<class Base>
311 bool GreaterThanZero(const cg::CG<Base>& x);
312 
313 template<class Base>
314 bool GreaterThanOrZero(const cg::CG<Base>& x);
315 
316 template<class Base>
317 bool LessThanZero(const cg::CG<Base>& x);
318 
319 template<class Base>
320 bool LessThanOrZero(const cg::CG<Base>& x);
321 
322 template<class Base>
323 bool abs_geq(const cg::CG<Base>& x, const cg::CG<Base>& y);
324 
325 // The identical property functions, see identical.hpp
329 template<class Base>
330 inline bool IdenticalPar(const cg::CG<Base>& x);
331 
335 template<class Base>
336 bool IdenticalZero(const cg::CG<Base>& x);
337 
341 template<class Base>
342 bool IdenticalOne(const cg::CG<Base>& x);
343 
344 template<class Base>
345 bool IdenticalEqualPar(const cg::CG<Base>& x, const cg::CG<Base>& y);
346 
347 // EqualOpSeq function
348 template<class Base>
349 bool EqualOpSeq(const cg::CG<Base>& u, const cg::CG<Base>& v);
350 
351 // NearEqual function
352 template<class Base>
353 bool NearEqual(const cg::CG<Base>& x, const cg::CG<Base>& y, const Base& r, const Base& a);
354 
355 template<class Base>
356 bool NearEqual(const Base& x, const cg::CG<Base>& y, const Base& r, const Base& a);
357 
358 template<class Base>
359 bool NearEqual(const cg::CG<Base>& x, const Base& y, const Base& r, const Base& a);
360 
361 template <class Base>
362 inline bool isnan(const cg::CG<Base>& s);
363 
364 template <class Base>
365 int Integer(const cg::CG<Base>& x);
366 
367 template<class Base>
368 cg::CG<Base> CondExp(cg::CGOpCode op,
369  const cg::CG<Base>& left, const cg::CG<Base>& right,
370  const cg::CG<Base>& trueCase, const cg::CG<Base>& falseCase,
371  bool (*compare)(const Base&, const Base&));
372 
376 template<class Base>
377 inline cg::CG<Base> sign(const cg::CG<Base>& x);
378 
379 // power function
380 template<class Base>
381 inline cg::CG<Base> pow(const cg::CG<Base>& x, const cg::CG<Base>& y);
382 template <class Base>
383 inline cg::CG<Base> pow(const Base& x, const cg::CG<Base>& y);
384 template <class Base>
385 inline cg::CG<Base> pow(const cg::CG<Base>& x, const Base& y);
386 
387 // absolute value
388 template<class Base>
389 inline cg::CG<Base> abs(const cg::CG<Base>& x);
390 
391 template<class Base>
392 inline cg::CG<Base> fabs(const cg::CG<Base>& x);
393 
394 // inverse cosine
395 template<class Base>
396 inline cg::CG<Base> acos(const cg::CG<Base>& x);
397 
398 // inverse sine
399 template<class Base>
400 inline cg::CG<Base> asin(const cg::CG<Base>& x);
401 
402 // inverse tangent
403 template<class Base>
404 inline cg::CG<Base> atan(const cg::CG<Base>& x);
405 
406 // cosine
407 template<class Base>
408 inline cg::CG<Base> cos(const cg::CG<Base>& x);
409 
410 // hyperbolic cosine
411 template<class Base>
412 inline cg::CG<Base> cosh(const cg::CG<Base>& x);
413 
414 // exponential
415 template<class Base>
416 inline cg::CG<Base> exp(const cg::CG<Base>& x);
417 
418 // natural logarithm
419 template<class Base>
420 inline cg::CG<Base> log(const cg::CG<Base>& x);
421 
422 // sine
423 template<class Base>
424 inline cg::CG<Base> sin(const cg::CG<Base>& x);
425 
426 // hyperbolic sine
427 template<class Base>
428 inline cg::CG<Base> sinh(const cg::CG<Base>& x);
429 
430 // square root
431 template<class Base>
432 inline cg::CG<Base> sqrt(const cg::CG<Base>& x);
433 
434 // tangent
435 template<class Base>
436 inline cg::CG<Base> tan(const cg::CG<Base>& x);
437 
438 // hyperbolic tangent
439 template<class Base>
440 inline cg::CG<Base> tanh(const cg::CG<Base>& x);
441 
442 #if CPPAD_USE_CPLUSPLUS_2011
443 
446 // error function
447 template<class Base>
448 inline cg::CG<Base> erf(const cg::CG<Base>& x);
449 
450 // inverse hyperbolic sin
451 template<class Base>
452 inline cg::CG<Base> asinh(const cg::CG<Base>& x);
453 
454 // inverse hyperbolic cosine
455 template<class Base>
456 inline cg::CG<Base> acosh(const cg::CG<Base>& x);
457 
458 // inverse hyperbolic tangent
459 template<class Base>
460 inline cg::CG<Base> atanh(const cg::CG<Base>& x);
461 
462 // exponential of x minus one
463 template<class Base>
464 inline cg::CG<Base> expm1(const cg::CG<Base>& x);
465 
466 // logarithm of one plus x
467 template<class Base>
468 inline cg::CG<Base> log1p(const cg::CG<Base>& x);
469 #endif
470 
471 } // END CppAD namespace
472 
476 #include <cppad/cg/declare_cg_loops.hpp>
477 
478 #endif
479 
bool IdenticalPar(const cg::CG< Base > &x)
Definition: identical.hpp:21
cg::CG< Base > CondExp(cg::CGOpCode op, const cg::CG< Base > &left, const cg::CG< Base > &right, const cg::CG< Base > &trueCase, const cg::CG< Base > &falseCase, bool(*compare)(const Base &, const Base &))
Definition: cond_exp_op.hpp:80
bool IdenticalOne(const cg::CG< Base > &x)
Definition: identical.hpp:45
cg::CG< Base > pow(const cg::CG< Base > &x, const cg::CG< Base > &y)
Definition: math_other.hpp:21
bool GreaterThanZero(const cg::CG< Base > &x)
Definition: ordered.hpp:21
bool IdenticalZero(const cg::CG< Base > &x)
Definition: identical.hpp:37
cg::CG< Base > sign(const cg::CG< Base > &x)
Definition: math_other.hpp:74