Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_rad.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Sacado Package
4 //
5 // Copyright 2006 NTESS and the Sacado contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9 
10 // RAD package (Reverse Automatic Differentiation) --
11 // a package specialized for function and gradient evaluations.
12 // Written in 2004 by David M. Gay at Sandia National Labs, Albuquerque, NM.
13 
14 #ifndef SACADO_RAD_H
15 #define SACADO_RAD_H
16 
17 #include <stddef.h>
18 #include <Sacado_cmath.hpp>
19 
20 #include "Sacado_ConfigDefs.h"
21 
22 #if defined(RAD_DEBUG_BLOCKKEEP) && !defined(HAVE_SACADO_UNINIT)
23 #undef RAD_DEBUG_BLOCKKEEP
24 #endif
25 
26 namespace Sacado {
27 namespace Radnt { // nontemplated RAD
28 
29 // -DRAD_NO_USING_STDCC is needed, e.g., with Sun CC 5.7
30 #ifndef RAD_NO_USING_STDCC
31  // Bring math functions into scope
32  using std::exp;
33  using std::log;
34  using std::log10;
35  using std::sqrt;
36  using std::cos;
37  using std::sin;
38  using std::tan;
39  using std::acos;
40  using std::asin;
41  using std::atan;
42  using std::cosh;
43  using std::sinh;
44  using std::tanh;
45  using std::abs;
46  using std::fabs;
47  using std::atan2;
48  using std::pow;
49 #endif
50 
51  class ADvar;
52  class ADvari;
53  class ADvar1;
54  class ADvar2;
55  class ConstADvar;
56  class Derp;
57  class IndepADvar;
58 
59  extern ADvari& ADf1(double f, double g, const ADvari &x);
60  extern ADvari& ADf2(double f, double gx, double gy, const ADvari &x, const ADvari &y);
61  extern ADvari& ADfn(double f, int n, const ADvar *x, const double *g);
62 
63  struct
64 ADmemblock { // We get memory in ADmemblock chunks and never give it back,
65  // but reuse it once computations start anew after call(s) on
66  // ADcontext::Gradcomp() or ADcontext::Weighted_Gradcomp().
68  double memblk[1000];
69  };
70 
71  class
72 ADcontext { // A singleton class: one instance in radops.c
73  ADmemblock *Busy, *Free;
74  char *Mbase;
75  size_t Mleft;
77  void *new_ADmemblock(size_t);
78  public:
79  ADcontext();
80  void *Memalloc(size_t len);
81  static void Gradcomp(int);
82  static inline void Gradcomp() { Gradcomp(1); }
83  static void Weighted_Gradcomp(int, ADvar**, double*);
84  };
85 
86 inline void *ADcontext::Memalloc(size_t len) {
87  if (Mleft >= len)
88  return Mbase + (Mleft -= len);
89  return new_ADmemblock(len);
90  }
91 
92  class
93 CADcontext: public ADcontext {
94  protected:
96  public:
97  friend class ADvar;
98  CADcontext(): ADcontext() { fpval_implies_const = false; }
99  static const double One, negOne;
100  };
101 
102  class
103 Derp { // one derivative-propagation operation
104  public:
105  friend class ADvarn;
106  static Derp *LastDerp;
108  const double *a;
109  const ADvari *b;
110  const ADvari *c;
111  void *operator new(size_t);
112  void operator delete(void*) {} /*Should never be called.*/
113  inline Derp(){};
114  Derp(const ADvari *);
115  Derp(const double *, const ADvari *);
116  Derp(const double *, const ADvari *, const ADvari *);
117  /* c->aval += a * b->aval; */
118  };
119 
120 inline Derp::Derp(const ADvari *c1): c(c1) {
121  next = LastDerp;
122  LastDerp = this;
123  }
124 
125 inline Derp::Derp(const double *a1, const ADvari *c1): a(a1), c(c1) {
126  next = LastDerp;
127  LastDerp = this;
128  }
129 
130 inline Derp::Derp(const double *a1, const ADvari *b1, const ADvari *c1): a(a1), b(b1), c(c1) {
131  next = LastDerp;
132  LastDerp = this;
133  }
134 
135  class
136 ADvari { // implementation of an ADvar
137  public:
138  double Val; // result of this operation
139  mutable double aval; // adjoint -- partial of final result w.r.t. this Val
140  void *operator new(size_t len) { return ADvari::adc.Memalloc(len); }
141  void operator delete(void*) {} /*Should never be called.*/
142  inline ADvari(double t): Val(t), aval(0.) {}
143  inline ADvari(double t, double ta): Val(t), aval(ta) {}
144  inline ADvari(): Val(0.), aval(0.) {}
145  static ADcontext adc;
146 #ifdef RAD_AUTO_AD_Const
147  friend class ADcontext;
148  friend class ADvar1;
149  friend class ADvar;
150  friend class ConstADvar;
151  friend class IndepADvar;
152  private:
153  ADvari *Next;
154  static ADvari *First_ADvari, **Last_ADvari;
155  protected:
156  IndepADvar *padv;
157  public:
158  ADvari(const IndepADvar *, double);
159 #endif
160 #define F friend
161 #define R ADvari&
162 #define Ai const ADvari&
163 #define T1(r,f) F r f(Ai);
164 #define T2(r,f) \
165 F r f(Ai,Ai); \
166 F r f(double,Ai); \
167 F r f(Ai,double);
168  T1(R,operator+)
169  T2(R,operator+)
170  T1(R,operator-)
171  T2(R,operator-)
172  T2(R,operator*)
173  T2(R,operator/)
174  T1(R,abs)
175  T1(R,acos)
176  T1(R,acosh)
177  T1(R,asin)
178  T1(R,asinh)
179  T1(R,atan)
180  T1(R,atanh)
181  T2(R,atan2)
182  T2(R,max)
183  T2(R,min)
184  T1(R,cos)
185  T1(R,cosh)
186  T1(R,exp)
187  T1(R,log)
188  T1(R,log10)
189  T2(R,pow)
190  T1(R,sin)
191  T1(R,sinh)
192  T1(R,sqrt)
193  T1(R,tan)
194  T1(R,tanh)
195  T1(R,fabs)
196  T1(R,copy)
197  T2(int,operator<)
198  T2(int,operator<=)
199  T2(int,operator==)
200  T2(int,operator!=)
201  T2(int,operator>=)
202  T2(int,operator>)
203 #undef T2
204 #undef T1
205 #undef Ai
206 #undef R
207 #undef F
208 
209  friend ADvari& ADf1(double f, double g, const ADvari &x);
210  friend ADvari& ADf2(double f, double gx, double gy, const ADvari &x, const ADvari &y);
211  friend ADvari& ADfn(double f, int n, const ADvar *x, const double *g);
212  };
213 
214  inline void* Derp::operator new(size_t len) { return ADvari::adc.Memalloc(len); }
215 
216 
217  class
218 ADvar1: public ADvari { // simplest unary ops
219  public:
221  ADvar1(double val1): ADvari(val1) {}
222  ADvar1(double val1, const ADvari *c1): d(c1) { Val = val1; }
223  ADvar1(double val1, const double *a1, const ADvari *c1): d(a1,this,c1) { Val = val1; }
224 #ifdef RAD_AUTO_AD_Const
225  ADvar1(const IndepADvar *, const IndepADvar &);
226  ADvar1(const IndepADvar *, const ADvari &);
227 #endif
228  };
229 
230  class
231 ConstADvari: public ADvari {
232  private:
234  ConstADvari() {}; // prevent construction without value (?)
235  static ConstADvari *lastcad;
236  public:
237  static CADcontext cadc;
238  inline void *operator new(size_t len) { return ConstADvari::cadc.Memalloc(len); }
239  inline ConstADvari(double t): ADvari(t) { prevcad = lastcad; lastcad = this; }
240  static void aval_reset(void);
241  };
242 
243  class
245 {
246  private:
247  inline IndepADvar& operator=(const IndepADvar &x) {
248  /* private to prevent assignment */
249 #ifdef RAD_AUTO_AD_Const
250  if (cv)
251  cv->padv = 0;
252  cv = new ADvar1(this,x);
253  return *this;
254 #else
255 #ifdef RAD_EQ_ALIAS
256  cv = x.cv;
257  return *this;
258 #else
259  return ADvar_operatoreq(this,*x.cv);
260 #endif
261 #endif /* RAD_AUTO_AD_Const */
262  }
263  protected:
264  static void AD_Const(const IndepADvar&);
266  public:
267  typedef double value_type;
268  friend class ADvar;
269  friend class ADvar1;
270  friend class ADvarn;
271  friend class ADcontext;
272  IndepADvar(double);
273  IndepADvar(int);
274  IndepADvar(long);
275  IndepADvar& operator=(double);
276 #ifdef RAD_AUTO_AD_Const
277  inline IndepADvar(const IndepADvar &x) { cv = x.cv ? new ADvar1(this, x) : 0; };
278  inline IndepADvar() { cv = 0; }
279  inline ~IndepADvar() {
280  if (cv)
281  cv->padv = 0;
282  }
283 #else
284  inline IndepADvar() {
285 #ifndef RAD_EQ_ALIAS
286  cv = 0;
287 #endif
288  }
289  inline ~IndepADvar() {}
290  friend IndepADvar& ADvar_operatoreq(IndepADvar*, const ADvari&);
291 #endif
292 
293  friend void AD_Const(const IndepADvar&);
294 
295  inline operator ADvari&() { return *cv; }
296  inline operator ADvari&() const { return *(ADvari*)cv; }
297 
298  inline double val() const { return cv->Val; }
299  inline double adj() const { return cv->aval; }
300  static inline void Gradcomp(int wantgrad)
301  { ADcontext::Gradcomp(wantgrad); }
302  static inline void Gradcomp()
303  { ADcontext::Gradcomp(1); }
304  static inline void aval_reset() { ConstADvari::aval_reset(); }
305  static inline void Weighted_Gradcomp(int n, ADvar **v, double *w)
306  { ADcontext::Weighted_Gradcomp(n, v, w); }
307 
308 
309 #define Ai const ADvari&
310 #define AI const IndepADvar&
311 #define T2(r,f) \
312  r f(AI,AI);\
313  r f(Ai,AI);\
314  r f(AI,Ai);\
315  r f(double,AI);\
316  r f(AI,double);
317 #define T1(f) friend ADvari& f(AI);
318 
319 #define F friend ADvari&
320 T2(F, operator+)
321 T2(F, operator-)
322 T2(F, operator*)
323 T2(F, operator/)
324 T2(F, atan2)
325 T2(F, max)
326 T2(F, min)
327 T2(F, pow)
328 #undef F
329 #define F friend int
330 T2(F, operator<)
331 T2(F, operator<=)
332 T2(F, operator==)
333 T2(F, operator!=)
334 T2(F, operator>=)
335 T2(F, operator>)
336 
337 T1(operator+)
338 T1(operator-)
339 T1(abs)
340 T1(acos)
341 T1(acosh)
342 T1(asin)
343 T1(asinh)
344 T1(atan)
345 T1(atanh)
346 T1(cos)
347 T1(cosh)
348 T1(exp)
349 T1(log)
350 T1(log10)
351 T1(sin)
352 T1(sinh)
353 T1(sqrt)
354 T1(tan)
355 T1(tanh)
356 T1(fabs)
357 T1(copy)
358 
359 #undef T1
360 #undef T2
361 #undef F
362 #undef Ai
363 #undef AI
364 
365  };
366 
367  class
368 ADvar: public IndepADvar { // an "active" variable
369  void ADvar_ctr(double d);
370  public:
371  inline ADvar() { /* cv = 0; */ }
372  inline ADvar(double d) { ADvar_ctr(d); }
373  inline ADvar(int i) { ADvar_ctr((double)i); }
374  inline ADvar(long i) { ADvar_ctr((double)i); }
375  inline ~ADvar() {}
376 #ifdef RAD_AUTO_AD_Const
377  friend class ADvar1;
378  inline ADvar(const IndepADvar &x) { cv = x.cv ? new ADvar1(this, x) : 0; }
379  inline ADvar(ADvari &x) { cv = &x; x.padv = this; }
380  inline ADvar& operator=(const IndepADvar &x) {
381  if (cv)
382  cv->padv = 0;
383  cv = new ADvar1(this,x);
384  return *this;
385  }
386  inline ADvar& operator=(const ADvari &x) {
387  if (cv)
388  cv->padv = 0;
389  cv = new ADvar1(this, x);
390  return *this;
391  }
392 #else
393  friend ADvar& ADvar_operatoreq(ADvar*, const ADvari&);
394 #ifdef RAD_EQ_ALIAS
395  /* allow aliasing v and w after "v = w;" */
396  inline ADvar(const IndepADvar &x) { cv = x.cv; }
397  inline ADvar(const ADvari &x) { cv = (ADvari*)&x; }
398  inline ADvar& operator=(const ADvari &x) { cv = (ADvari*)&x; return *this; }
399  inline ADvar& operator=(const IndepADvar &x) { cv = (ADvari*)x.cv; return *this; }
400 #else
401  ADvar(const IndepADvar &x) { cv = x.cv ? new ADvar1(x.cv->Val, &CADcontext::One, x.cv) : 0; }
402  ADvar(const ADvari &x) { cv = new ADvar1(x.Val, &CADcontext::One, &x); }
403  inline ADvar& operator=(const ADvari &x) { return ADvar_operatoreq(this,x); }
404  inline ADvar& operator=(const IndepADvar &x) { return ADvar_operatoreq(this,*x.cv); }
405 #endif /* RAD_EQ_ALIAS */
406 #endif /* RAD_AUTO_AD_Const */
407  ADvar& operator=(double);
408  ADvar& operator+=(const ADvari&);
409  ADvar& operator+=(double);
410  ADvar& operator-=(const ADvari&);
411  ADvar& operator-=(double);
412  ADvar& operator*=(const ADvari&);
413  ADvar& operator*=(double);
414  ADvar& operator/=(const ADvari&);
415  ADvar& operator/=(double);
416  inline static bool get_fpval_implies_const(void)
418  inline static void set_fpval_implies_const(bool newval)
420  inline static bool setget_fpval_implies_const(bool newval) {
423  return oldval;
424  }
425  static inline void Gradcomp(int wantgrad)
426  { ADcontext::Gradcomp(wantgrad); }
427  static inline void Gradcomp()
428  { ADcontext::Gradcomp(1); }
429  static inline void aval_reset() { ConstADvari::aval_reset(); }
430  static inline void Weighted_Gradcomp(int n, ADvar **v, double *w)
431  { ADcontext::Weighted_Gradcomp(n, v, w); }
432  };
433 
434  inline void AD_Const(const IndepADvar&v) { IndepADvar::AD_Const(v); }
435 
436  class
437 ConstADvar: public ADvar {
438  private: // disable op=
439  ConstADvar& operator+=(const ADvari&);
440  ConstADvar& operator+=(double);
441  ConstADvar& operator-=(const ADvari&);
442  ConstADvar& operator-=(double);
443  ConstADvar& operator*=(const ADvari&);
444  ConstADvar& operator*=(double);
445  ConstADvar& operator/=(const ADvari&);
446  ConstADvar& operator/=(double);
447  void ConstADvar_ctr(double);
448  public:
449  inline ConstADvar(double d) { ConstADvar_ctr(d); }
450  inline ConstADvar(int i) { ConstADvar_ctr((double)i); }
451  inline ConstADvar(long i) { ConstADvar_ctr((double)i); }
452  ConstADvar(const ADvari &x);
453 #ifdef RAD_AUTO_AD_Const
454  ConstADvar(const IndepADvar &x) { cv = new ADvar1(this,x); }
455 #endif
456  inline ~ConstADvar(){}
457 #ifdef RAD_NO_CONST_UPDATE
458  private:
459 #endif
460  ConstADvar();
461  inline ConstADvar& operator=(double d) { cv->Val = d; return *this; }
462  inline ConstADvar& operator=(const IndepADvar& d) { cv->Val = d.val(); return *this; }
463  };
464 
465  class
466 ADvar1s: public ADvar1 { // unary ops with partial "a"
467  public:
468  double a;
469  ADvar1s(double val1, double a1, const ADvari *c1): ADvar1(val1,&a,c1), a(a1) {}
470  };
471 
472  class
473 ADvar2: public ADvari { // basic binary ops
474  public:
475  Derp dL, dR;
476  ADvar2(double val1): ADvari(val1) {}
477  ADvar2(double val1, const ADvari *Lcv, const double *Lc, const ADvari *Rcv,
478  const double *Rc): ADvari(val1) {
479  dR.next = Derp::LastDerp;
480  dL.next = &dR;
481  Derp::LastDerp = &dL;
482  dL.a = Lc;
483  dL.c = Lcv;
484  dR.a = Rc;
485  dR.c = Rcv;
486  dL.b = dR.b = this;
487  }
488  };
489 
490  class
491 ADvar2q: public ADvar2 { // binary ops with partials "a", "b"
492  public:
493  double a, b;
494  ADvar2q(double val1, double Lp, double Rp, const ADvari *Lcv, const ADvari *Rcv):
495  ADvar2(val1), a(Lp), b(Rp) {
496  dR.next = Derp::LastDerp;
497  dL.next = &dR;
498  Derp::LastDerp = &dL;
499  dL.a = &a;
500  dL.c = Lcv;
501  dR.a = &b;
502  dR.c = Rcv;
503  dL.b = dR.b = this;
504  }
505  };
506 
507  class
508 ADvarn: public ADvari { // n-ary ops with partials "a"
509  public:
510  int n;
511  double *a;
513  ADvarn(double val1, int n1, const ADvar *x, const double *g);
514  };
515 
516 inline ADvari &operator+(ADvari &T) { return T; }
517 inline ADvari &operator+(const ADvari &T) { return (ADvari&) T; }
518 
519 inline int operator<(const ADvari &L, const ADvari &R) { return L.Val < R.Val; }
520 inline int operator<(const ADvari &L, double R) { return L.Val < R; }
521 inline int operator<(double L, const ADvari &R) { return L < R.Val; }
522 
523 inline int operator<=(const ADvari &L, const ADvari &R) { return L.Val <= R.Val; }
524 inline int operator<=(const ADvari &L, double R) { return L.Val <= R; }
525 inline int operator<=(double L, const ADvari &R) { return L <= R.Val; }
526 
527 inline int operator==(const ADvari &L, const ADvari &R) { return L.Val == R.Val; }
528 inline int operator==(const ADvari &L, double R) { return L.Val == R; }
529 inline int operator==(double L, const ADvari &R) { return L == R.Val; }
530 
531 inline int operator!=(const ADvari &L, const ADvari &R) { return L.Val != R.Val; }
532 inline int operator!=(const ADvari &L, double R) { return L.Val != R; }
533 inline int operator!=(double L, const ADvari &R) { return L != R.Val; }
534 
535 inline int operator>=(const ADvari &L, const ADvari &R) { return L.Val >= R.Val; }
536 inline int operator>=(const ADvari &L, double R) { return L.Val >= R; }
537 inline int operator>=(double L, const ADvari &R) { return L >= R.Val; }
538 
539 inline int operator>(const ADvari &L, const ADvari &R) { return L.Val > R.Val; }
540 inline int operator>(const ADvari &L, double R) { return L.Val > R; }
541 inline int operator>(double L, const ADvari &R) { return L > R.Val; }
542 
543 inline ADvari& copy(const IndepADvar &x)
544 { return *(new ADvar1(x.cv->Val, &CADcontext::One, x.cv)); }
545 
546 inline ADvari& copy(const ADvari &x)
547 { return *(new ADvar1(x.Val, &CADcontext::One, &x)); }
548 
549 inline ADvari& abs(const ADvari &x)
550 { return fabs(x); }
551 
552 #define A (ADvari*)
553 #define T inline
554 #define F ADvari&
555 #define Ai const ADvari&
556 #define AI const IndepADvar&
557 #define D double
558 #define T2(r,f) \
559  T r f(Ai L, AI R) { return f(L, *A R.cv); }\
560  T r f(AI L, Ai R) { return f(*A L.cv, R); }\
561  T r f(AI L, AI R) { return f(*A L.cv, *A R.cv); }\
562  T r f(AI L, D R) { return f(*A L.cv, R); }\
563  T r f(D L, AI R) { return f(L, *A R.cv); }
564 
565 T2(F, operator+)
566 T2(F, operator-)
567 T2(F, operator*)
568 T2(F, operator/)
569 T2(F, atan2)
570 T2(F, pow)
571 T2(F, max)
572 T2(F, min)
573 T2(int, operator<)
574 T2(int, operator<=)
575 T2(int, operator==)
576 T2(int, operator!=)
577 T2(int, operator>=)
578 T2(int, operator>)
579 
580 #undef T2
581 #undef D
582 
583 #define T1(f)\
584  T F f(AI x) { return f(*A x.cv); }
585 
586 T1(operator+)
587 T1(operator-)
588 T1(abs)
589 T1(acos)
590 T1(acosh)
591 T1(asin)
592 T1(asinh)
593 T1(atan)
594 T1(atanh)
595 T1(cos)
596 T1(cosh)
597 T1(exp)
598 T1(log)
599 T1(log10)
600 T1(sin)
601 T1(sinh)
602 T1(sqrt)
603 T1(tan)
604 T1(tanh)
605 T1(fabs)
606 
607 #undef T1
608 #undef AI
609 #undef Ai
610 #undef F
611 #undef T
612 #undef A
613 
614 } // namespace Radnt
615 } // namespace Sacado
616 #endif /* SACADO_RAD_H */
void f()
asin(expr.val())
ADvar1(double val1, const ADvari *c1)
Definition: Sacado_rad.hpp:222
cosh(expr.val())
ADvar & operator=(const IndepADvar &x)
Definition: Sacado_rad.hpp:404
ADvari & asin(const ADvari &v)
static void AD_Const(const IndepADvar &)
ADvari & sin(const ADvari &v)
abs(expr.val())
static void Weighted_Gradcomp(int n, ADvar **v, double *w)
Definition: Sacado_rad.hpp:430
ConstADvar & operator=(const IndepADvar &d)
Definition: Sacado_rad.hpp:462
ADvari & max(const ADvari &L, const ADvari &R)
void * new_ADmemblock(size_t)
void * Memalloc(size_t len)
Definition: Sacado_rad.hpp:86
ADvari & acosh(const ADvari &v)
static bool setget_fpval_implies_const(bool newval)
Definition: Sacado_rad.hpp:420
ADvar & operator=(const ADvari &x)
Definition: Sacado_rad.hpp:403
ADvari & abs(const ADvari &x)
Definition: Sacado_rad.hpp:549
ADvari & log(const ADvari &v)
atan(expr.val())
ADvar(const IndepADvar &x)
Definition: Sacado_rad.hpp:401
ADvari & log10(const ADvari &v)
#define R
Definition: Sacado_rad.hpp:161
const double * a
Definition: Sacado_rad.hpp:108
ADvari & asinh(const ADvari &v)
ADvari & atanh(const ADvari &v)
static void Weighted_Gradcomp(int, ADvar **, double *)
ADvar1s(double val1, double a1, const ADvari *c1)
Definition: Sacado_rad.hpp:469
#define T
Definition: Sacado_rad.hpp:553
tanh(expr.val())
static bool get_fpval_implies_const(void)
Definition: Sacado_rad.hpp:416
expr expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c *expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 c
ADvari & fabs(const ADvari &v)
ADvari & atan(const ADvari &v)
#define T2(r, f)
Definition: Sacado_rad.hpp:558
static const double One
Definition: Sacado_rad.hpp:99
ADvar2q(double val1, double Lp, double Rp, const ADvari *Lcv, const ADvari *Rcv)
Definition: Sacado_rad.hpp:494
const ADvari * b
Definition: Sacado_rad.hpp:109
ADvari & cosh(const ADvari &v)
ConstADvar & operator=(double d)
Definition: Sacado_rad.hpp:461
sqrt(expr.val())
sinh(expr.val())
tan(expr.val())
ADvari & tan(const ADvari &v)
#define T1(r, f)
Definition: Sacado_rad.hpp:583
void g()
static void aval_reset(void)
ADvari & tanh(const ADvari &v)
IndepADvar & operator=(const IndepADvar &x)
Definition: Sacado_rad.hpp:247
ADvari & operator+(ADvari &T)
Definition: Sacado_rad.hpp:516
atan2(expr1.val(), expr2.val())
const ADvari * c
Definition: Sacado_rad.hpp:110
ADvari & cos(const ADvari &v)
sin(expr.val())
ADvari & ADfn(double f, int n, const ADvar *x, const double *g)
static void Gradcomp()
Definition: Sacado_rad.hpp:82
ADvari & sqrt(const ADvari &v)
int operator==(const ADvari &L, const ADvari &R)
Definition: Sacado_rad.hpp:527
static CADcontext cadc
Definition: Sacado_rad.hpp:237
log(expr.val())
ADvari & acos(const ADvari &v)
ADvar & ADvar_operatoreq(ADvar *This, const ADvari &x)
int operator!=(const ADvari &L, const ADvari &R)
Definition: Sacado_rad.hpp:531
int operator>(const ADvari &L, const ADvari &R)
Definition: Sacado_rad.hpp:539
static void Gradcomp(int wantgrad)
Definition: Sacado_rad.hpp:425
ADvar(const ADvari &x)
Definition: Sacado_rad.hpp:402
acos(expr.val())
static void set_fpval_implies_const(bool newval)
Definition: Sacado_rad.hpp:418
SACADO_INLINE_FUNCTION mpl::enable_if_c< ExprLevel< Expr< T1 > >::value==ExprLevel< Expr< T2 > >::value, Expr< PowerOp< Expr< T1 >, Expr< T2 > > > >::type pow(const Expr< T1 > &expr1, const Expr< T2 > &expr2)
static void aval_reset()
Definition: Sacado_rad.hpp:429
static Derp * LastDerp
Definition: Sacado_rad.hpp:106
void AD_Const(const IndepADvar &v)
Definition: Sacado_rad.hpp:434
ADvari & ADf1(double f, double g, const ADvari &x)
static ADcontext adc
Definition: Sacado_rad.hpp:145
exp(expr.val())
int operator<(const ADvari &L, const ADvari &R)
Definition: Sacado_rad.hpp:519
static void Weighted_Gradcomp(int n, ADvar **v, double *w)
Definition: Sacado_rad.hpp:305
int operator<=(const ADvari &L, const ADvari &R)
Definition: Sacado_rad.hpp:523
static void Gradcomp(int wantgrad)
Definition: Sacado_rad.hpp:300
fabs(expr.val())
int operator>=(const ADvari &L, const ADvari &R)
Definition: Sacado_rad.hpp:535
ADvar1(double val1, const double *a1, const ADvari *c1)
Definition: Sacado_rad.hpp:223
ADvari & exp(const ADvari &v)
ADvari(double t, double ta)
Definition: Sacado_rad.hpp:143
ADvari & copy(const IndepADvar &x)
Definition: Sacado_rad.hpp:543
int n
static void Gradcomp()
Definition: Sacado_rad.hpp:427
log10(expr.val())
cos(expr.val())
ADvari & atan2(const ADvari &L, const ADvari &R)
ADvar2(double val1, const ADvari *Lcv, const double *Lc, const ADvari *Rcv, const double *Rc)
Definition: Sacado_rad.hpp:477
ADvari & pow(const ADvari &L, const ADvari &R)
ADvari & ADf2(double f, double gx, double gy, const ADvari &x, const ADvari &y)
ADvari & min(const ADvari &L, const ADvari &R)
const double y
ADvari & sinh(const ADvari &v)