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