CppADCodeGen 2.4.3
A C++ Algorithmic Differentiation Package with Source Code Generation
Loading...
Searching...
No Matches
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
19namespace CppAD {
20
21template<class Base>
22class vector;
23
24template<class Base>
25class AD;
26
27template<class Base, class RecBase>
28class ADFun;
29
30namespace cg {
31
32/***************************************************************************
33 * Atomics
34 **************************************************************************/
35template<class Base>
36class BaseAbstractAtomicFun;
37
38template<class Base>
39class CGAbstractAtomicFun;
40
41template<class Base>
42class CGAtomicFun;
43
44template<class Base>
45class AtomicUseInfo;
46
47/***************************************************************************
48 * Core
49 **************************************************************************/
50template<class Base>
51class CodeHandler;
52
53template<class Base>
54class CodeHandlerVectorSync;
55
56template<class Base, class T>
57class CodeHandlerVector;
58
59template<class Base>
60class CG;
61
62template<class Base>
63struct OperationPathNode;
64
65template<class Base>
66class PathNodeEdges;
67
68template<class Base>
69class BidirGraph;
70
71template<class Base>
72class ScopePathElement;
73
74/***************************************************************************
75 * Nodes
76 **************************************************************************/
77template<class Base>
78class OperationNode;
79
80template<class Base>
81class IndexOperationNode;
82
83template<class Base>
84class IndexAssignOperationNode;
85
86template<class Base>
87class LoopStartOperationNode;
88
89template<class Base>
90class LoopEndOperationNode;
91
92/***************************************************************************
93 * Loops
94 **************************************************************************/
95template<class Base>
96class EquationPattern;
97
98template<class Base>
99class DependentPatternMatcher;
100
101template<class Base>
102class Loop;
103
104template<class Base>
105class LoopFreeModel;
106
107template<class Base>
108class LoopModel;
109
110template<class Base>
112
113class IndexPattern;
118
119/***************************************************************************
120 * Languages
121 **************************************************************************/
122template<class Base>
124
125template<class Base>
126class LanguageC;
127
128template<class Base>
130
131template<class Base>
133
134template<class Base>
136
137/***************************************************************************
138 * Models
139 **************************************************************************/
140template<class Base>
141class GenericModel;
142
143template<class Base>
145
146template<class Base>
148
149/***************************************************************************
150 * Dynamic model compilation
151 **************************************************************************/
152
153template<class Base>
154class CCompiler;
155
156template<class Base>
157class DynamicLib;
158
159template<class Base>
160class ModelCSourceGen;
161
162template<class Base>
164
165#if CPPAD_CG_SYSTEM_LINUX
166template<class Base>
167class LinuxDynamicLibModel;
168
169template<class Base>
170class LinuxDynamicLib;
171#endif
172
173/***************************************************************************
174 * Index reduction classes
175 **************************************************************************/
176template<class Base>
177class Enode;
178
179template<class Base>
180class Vnode;
181
182template<class ScalarIn, class ScalarOut, class ActiveOut>
183class Evaluator;
184
185/***************************************************************************
186 * Utilities
187 **************************************************************************/
188
189template<class Base>
191
192template<class Base>
193class SmartListPointer;
194
195template<class Key, class Value>
197
198template<class Type>
199class ArrayView;
200
201template<class Base>
202inline void print(const Base& v);
203
204template<class Key, class Value>
205inline void print(const std::map<Key, Value>& m);
206
207template<class Base>
208inline void print(const std::set<Base>& s);
209
210template<class Base>
211inline void print(const std::set<Base*>& s);
212
213template<class Base>
214inline void print(const std::vector<Base>& v);
215
219template<class Base>
220CG<Base> operator+(const CG<Base>& left, const CG<Base>& right);
221
222template<class Base>
223CG<Base> operator-(const CG<Base>& left, const CG<Base>& right);
224
225template<class Base>
226CG<Base> operator*(const CG<Base>& left, const CG<Base>& right);
227
228template<class Base>
229CG<Base> operator/(const CG<Base>& left, const CG<Base>& right);
230
234template<class Base>
235bool operator==(const CG<Base>& left, const CG<Base>& right);
236
237template<class Base>
238bool operator!=(const CG<Base>& left, const CG<Base>& right);
239
240template<class Base>
241bool operator<(const CG<Base>& left, const CG<Base>& right);
242
243template<class Base>
244bool operator<=(const CG<Base>& left, const CG<Base>& right);
245
246template<class Base>
247bool operator>(const CG<Base>& left, const CG<Base>& right);
248
249template<class Base>
250bool operator>=(const CG<Base>& left, const CG<Base>& right);
251
252template<class Base>
253bool operator!=(const CG<Base>& left, double right);
254
255template<class Base>
256bool operator==(const CG<Base>& left, const Base& right);
257
258template<class Base>
259bool operator==(const Base& left, const CG<Base>& right);
260
261template<class Base>
262bool operator!=(const CG<Base>& left, Base right);
263
264template<class Base>
265bool operator!=(const Base& left, const CG<Base>& right);
266
267/***************************************************************************
268 * Index reduction functions
269 **************************************************************************/
270
271template<class Base>
272inline std::ostream& operator<<(std::ostream& os, const Enode<Base>& i);
273
274template<class Base>
275inline std::ostream& operator<<(std::ostream& os, const Vnode<Base>& j);
276
277/***************************************************************************
278 * Enums
279 **************************************************************************/
280
284enum class Verbosity {
285 None, Low, High
286};
287
291enum class JacobianADMode {
292 Forward, Reverse, Automatic
293};
294
298enum class IndexPatternType {
299 Linear, // y = (x / dx) * dy + b
300 Sectioned, // several index patterns
301 Random1D,
302 Random2D,
303 Plane2D // y = f(x) + f(z)
304};
305
306} // END cg namespace
307
308/***************************************************************************
309 *
310 **************************************************************************/
311// order determining functions, see ordered.hpp
312template<class Base>
313bool GreaterThanZero(const cg::CG<Base>& x);
314
315template<class Base>
316bool GreaterThanOrZero(const cg::CG<Base>& x);
317
318template<class Base>
319bool LessThanZero(const cg::CG<Base>& x);
320
321template<class Base>
322bool LessThanOrZero(const cg::CG<Base>& x);
323
324template<class Base>
325bool abs_geq(const cg::CG<Base>& x, const cg::CG<Base>& y);
326
327// The identical property functions, see identical.hpp
331template<class Base>
332inline bool IdenticalPar(const cg::CG<Base>& x);
333
337template<class Base>
338bool IdenticalZero(const cg::CG<Base>& x);
339
343template<class Base>
344bool IdenticalOne(const cg::CG<Base>& x);
345
346template<class Base>
347bool IdenticalEqualPar(const cg::CG<Base>& x, const cg::CG<Base>& y);
348
349// EqualOpSeq function
350template<class Base>
351bool EqualOpSeq(const cg::CG<Base>& u, const cg::CG<Base>& v);
352
353// NearEqual function
354template<class Base>
355bool NearEqual(const cg::CG<Base>& x, const cg::CG<Base>& y, const Base& r, const Base& a);
356
357template<class Base>
358bool NearEqual(const Base& x, const cg::CG<Base>& y, const Base& r, const Base& a);
359
360template<class Base>
361bool NearEqual(const cg::CG<Base>& x, const Base& y, const Base& r, const Base& a);
362
363template <class Base>
364inline bool isnan(const cg::CG<Base>& s);
365
366template <class Base>
367int Integer(const cg::CG<Base>& x);
368
369template<class Base>
370cg::CG<Base> CondExp(cg::CGOpCode op,
371 const cg::CG<Base>& left, const cg::CG<Base>& right,
372 const cg::CG<Base>& trueCase, const cg::CG<Base>& falseCase,
373 bool (*compare)(const Base&, const Base&));
374
378template<class Base>
379inline cg::CG<Base> sign(const cg::CG<Base>& x);
380
381// power function
382template<class Base>
383inline cg::CG<Base> pow(const cg::CG<Base>& x, const cg::CG<Base>& y);
384template <class Base>
385inline cg::CG<Base> pow(const Base& x, const cg::CG<Base>& y);
386template <class Base>
387inline cg::CG<Base> pow(const cg::CG<Base>& x, const Base& y);
388
389// absolute value
390template<class Base>
391inline cg::CG<Base> abs(const cg::CG<Base>& x);
392
393template<class Base>
394inline cg::CG<Base> fabs(const cg::CG<Base>& x);
395
396// inverse cosine
397template<class Base>
398inline cg::CG<Base> acos(const cg::CG<Base>& x);
399
400// inverse sine
401template<class Base>
402inline cg::CG<Base> asin(const cg::CG<Base>& x);
403
404// inverse tangent
405template<class Base>
406inline cg::CG<Base> atan(const cg::CG<Base>& x);
407
408// cosine
409template<class Base>
410inline cg::CG<Base> cos(const cg::CG<Base>& x);
411
412// hyperbolic cosine
413template<class Base>
414inline cg::CG<Base> cosh(const cg::CG<Base>& x);
415
416// exponential
417template<class Base>
418inline cg::CG<Base> exp(const cg::CG<Base>& x);
419
420// natural logarithm
421template<class Base>
422inline cg::CG<Base> log(const cg::CG<Base>& x);
423
424// sine
425template<class Base>
426inline cg::CG<Base> sin(const cg::CG<Base>& x);
427
428// hyperbolic sine
429template<class Base>
430inline cg::CG<Base> sinh(const cg::CG<Base>& x);
431
432// square root
433template<class Base>
434inline cg::CG<Base> sqrt(const cg::CG<Base>& x);
435
436// tangent
437template<class Base>
438inline cg::CG<Base> tan(const cg::CG<Base>& x);
439
440// hyperbolic tangent
441template<class Base>
442inline cg::CG<Base> tanh(const cg::CG<Base>& x);
443
444#if CPPAD_USE_CPLUSPLUS_2011
448// error function
449template<class Base>
450inline cg::CG<Base> erf(const cg::CG<Base>& x);
451
452// complementary error function
453template<class Base>
454inline cg::CG<Base> erfc(const cg::CG<Base>& var);
455
456// inverse hyperbolic sin
457template<class Base>
458inline cg::CG<Base> asinh(const cg::CG<Base>& x);
459
460// inverse hyperbolic cosine
461template<class Base>
462inline cg::CG<Base> acosh(const cg::CG<Base>& x);
463
464// inverse hyperbolic tangent
465template<class Base>
466inline cg::CG<Base> atanh(const cg::CG<Base>& x);
467
468// exponential of x minus one
469template<class Base>
470inline cg::CG<Base> expm1(const cg::CG<Base>& x);
471
472// logarithm of one plus x
473template<class Base>
474inline cg::CG<Base> log1p(const cg::CG<Base>& x);
475#endif
476
477} // END CppAD namespace
478
482#include <cppad/cg/declare_cg_loops.hpp>
483
484#endif
485
bool GreaterThanZero(const cg::CG< Base > &x)
Definition ordered.hpp:21
bool IdenticalOne(const cg::CG< Base > &x)
Definition identical.hpp:45
bool IdenticalZero(const cg::CG< Base > &x)
Definition identical.hpp:37
cg::CG< Base > sign(const cg::CG< Base > &x)
cg::CG< Base > pow(const cg::CG< Base > &x, const cg::CG< Base > &y)
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 &))