Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_rad2.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 // Extension of the RAD package (Reverse Automatic Differentiation) --
11 // a package specialized for function and gradient evaluations -- to
12 // Hessian-vector products.
13 // This variant is for Hessian-vector products of "double" variables, and
14 // Sacado::Rad2d::ADvar should be equivalent to Sacado::Rad2::ADvar<double>,
15 // but this nontemplated code may easier to understand. It relies on ops
16 // implemented in Sacado_radops2.cpp.
17 // Written in 2007 by David M. Gay at Sandia National Labs, Albuquerque, NM.
18 
19 #ifndef SACADO_RAD2_H
20 #define SACADO_RAD2_H
21 
22 #include <stddef.h>
23 #include <Sacado_cmath.hpp>
24 
25 #include "Sacado_ConfigDefs.h"
26 
27 #if defined(RAD_DEBUG_BLOCKKEEP) && !defined(HAVE_SACADO_UNINIT)
28 #undef RAD_DEBUG_BLOCKKEEP
29 #endif
30 
31 #ifndef SACADO_NO_NAMESPACE
32 namespace Sacado {
33 namespace Rad2d { // "2" for 2nd derivatives, "d" for "double"
34 #endif
35 
36 // -DNO_USING_STDCC is needed, e.g., with Sun CC 5.7
37 #ifndef RAD_NO_USING_STDCC
38  // Bring math functions into scope
39  using std::exp;
40  using std::log;
41  using std::log10;
42  using std::sqrt;
43  using std::cos;
44  using std::sin;
45  using std::tan;
46  using std::acos;
47  using std::asin;
48  using std::atan;
49  using std::cosh;
50  using std::sinh;
51  using std::tanh;
52  using std::abs;
53  using std::fabs;
54  using std::atan2;
55  using std::pow;
56 #endif //NO_USING_STDCC
57 
58  class ADvar;
59  class ADvari;
60  class ADvar1;
61  class ADvar2;
62  class ConstADvar;
63  class Derp;
64  class IndepADvar;
65 
66  struct
67 ADmemblock { // We get memory in ADmemblock chunks and never give it back,
68  // but reuse it once computations start anew after call(s) on
69  // ADcontext::Gradcomp() or ADcontext::Weighted_Gradcomp().
71  double memblk[2000];
72  };
73 
74  struct
76  enum { Gulp = 1021 };
77  ADvari_block *next, *prev;
79  ADvari *pADvari[Gulp];
80  };
81 
82  class
83 ADcontext { // A singleton class: one instance in radops.c
84  ADmemblock *Busy, *Free;
85  char *Mbase;
86  size_t Mleft;
87  ADvari **Ailimit, **Ainext;
88  ADvari_block *Aibusy, *Aifree;
91  void *new_ADmemblock(size_t);
92  void new_ADvari_block();
93  public:
94  ADcontext();
95  void *Memalloc(size_t len);
96  static void Gradcomp(int);
97  static inline void Gradcomp() { Gradcomp(1); }
98  static void Hvprod(int, ADvar**, double*, double*);
99  static void Weighted_Gradcomp(int, ADvar**, double*);
100  inline void ADvari_record(ADvari *x) {
101  if (Ainext >= Ailimit)
102  new_ADvari_block();
103  *Ainext++ = x;
104  }
105  };
106 
107 inline void *ADcontext::Memalloc(size_t len) {
108  if (Mleft >= len)
109  return Mbase + (Mleft -= len);
110  return new_ADmemblock(len);
111  }
112 
113  class
114 CADcontext: public ADcontext {
115  protected:
117  public:
118  friend class ADvar;
119  CADcontext(): ADcontext() { fpval_implies_const = false; }
120  static const double One, negOne;
121  };
122 
123  class
124 Derp { // one derivative-propagation operation
125  public:
126  friend class ADvarn;
127  static Derp *LastDerp;
129  const double *a;
130  const ADvari *b;
131  mutable ADvari *c;
132  void *operator new(size_t);
133  void operator delete(void*) {} /*Should never be called.*/
134  inline Derp(){};
135  Derp(const ADvari *);
136  Derp(const double *, const ADvari *);
137  Derp(const double *, const ADvari *, const ADvari *);
138  /* c->aval += a * b->aval; */
139  };
140 
141 inline Derp::Derp(const ADvari *c1): c((ADvari*)c1) {
142  next = LastDerp;
143  LastDerp = this;
144  }
145 
146 inline Derp::Derp(const double *a1, const ADvari *c1):
147  a(a1), c((ADvari*)c1) {
148  next = LastDerp;
149  LastDerp = this;
150  }
151 
152 inline Derp::Derp(const double *a1, const ADvari *b1, const ADvari *c1):
153  a(a1), b(b1), c((ADvari*)c1) {
154  next = LastDerp;
155  LastDerp = this;
156  }
157 
170  };
171 
172  extern ADvari& ADf1(double f, double g, double h, const ADvari &x);
173  extern ADvari& ADf2(double f, double gx, double gy, double hxx,
174  double hxy, double hyy, const ADvari &x, const ADvari &y);
175  extern ADvari& ADfn(double f, int n, const ADvar *x, const double *g, const double *h);
176 
177  class
178 ADvari { // implementation of an ADvar
179  public:
180  static ADcontext adc;
182  double Val; // result of this operation
183  mutable double aval; // adjoint -- partial of final result w.r.t. this Val
184  mutable double dO; // deriv of op w.r.t. t in x + t*p
185  mutable double aO; // adjoint (in Hv computation) of op
186  mutable double adO; // adjoint (in Hv computation) of dO
187  void *operator new(size_t len) { return ADvari::adc.Memalloc(len); }
188  void operator delete(void*) {} /*Should never be called.*/
189  inline ADvari(Advari_Opclass oc, double t):
190  opclass(oc), Val(t), aval(0.), dO(0.)
191  { if (oc != Hv_const) ADvari::adc.ADvari_record(this); }
192  inline ADvari(Advari_Opclass oc, double t, double ta):
193  opclass(oc), Val(t), aval(ta), dO(0.)
194  { if (oc != Hv_const) ADvari::adc.ADvari_record(this); }
195  private:
196  inline ADvari(): Val(0.), aval(0.), dO(0.) {} // prevent construction without value (?)
197  public:
198  friend class ConstADvari;
199 #ifdef RAD_AUTO_AD_Const
200  friend class ADcontext;
201  friend class ADvar1;
202  friend class ADvar;
203  friend class ConstADvar;
204  friend class IndepADvar;
205  private:
206  ADvari *Next;
207  static ADvari *First_ADvari, **Last_ADvari;
208  protected:
209  IndepADvar *padv;
210  public:
211  ADvari(const IndepADvar *, double);
212 #endif
213 #define F friend
214 #define R ADvari&
215 #define Ai const ADvari&
216 #define T1(r,f) F r f(Ai);
217 #define T2(r,f) \
218 F r f(Ai,Ai); \
219 F r f(double,Ai); \
220 F r f(Ai,double);
221  T1(R,operator+)
222  T2(R,operator+)
223  T1(R,operator-)
224  T2(R,operator-)
225  T2(R,operator*)
226  T2(R,operator/)
227  T1(R,abs)
228  T1(R,acos)
229  T1(R,acosh)
230  T1(R,asin)
231  T1(R,asinh)
232  T1(R,atan)
233  T1(R,atanh)
234  T2(R,atan2)
235  T2(R,max)
236  T2(R,min)
237  T1(R,cos)
238  T1(R,cosh)
239  T1(R,exp)
240  T1(R,log)
241  T1(R,log10)
242  T2(R,pow)
243  T1(R,sin)
244  T1(R,sinh)
245  T1(R,sqrt)
246  T1(R,tan)
247  T1(R,tanh)
248  T1(R,fabs)
249  T1(R,copy)
250  T2(int,operator<)
251  T2(int,operator<=)
252  T2(int,operator==)
253  T2(int,operator!=)
254  T2(int,operator>=)
255  T2(int,operator>)
256 #undef T2
257 #undef T1
258 #undef Ai
259 #undef R
260 #undef F
261 
262  friend ADvari& ADf1(double f, double g, double h, const ADvari &x);
263  friend ADvari& ADf2(double f, double gx, double gy, double hxx,
264  double hxy, double hyy, const ADvari &x, const ADvari &y);
265  friend ADvari& ADfn(double f, int n, const ADvar *x, const double *g, const double *h);
266  };
267 
268  inline void* Derp::operator new(size_t len) { return ADvari::adc.Memalloc(len); }
269 
270 
271  class
272 ADvar1: public ADvari { // simplest unary ops
273  public:
275  ADvar1(Advari_Opclass oc, double val1, const double *a1, const ADvari *c1):
276  ADvari(oc,val1), d(a1,this,c1) {}
277 #ifdef RAD_AUTO_AD_Const
278  ADvar1(const IndepADvar *, const IndepADvar &);
279  ADvar1(const IndepADvar *, const ADvari &);
280 #endif
281  };
282 
283  class
284 ConstADvari: public ADvari {
285  private:
287  ConstADvari() {}; // prevent construction without value (?)
288  static ConstADvari *lastcad;
289  public:
290  static CADcontext cadc;
291  inline void *operator new(size_t len) { return ConstADvari::cadc.Memalloc(len); }
292  inline ConstADvari(double t): ADvari(Hv_copy, t) { prevcad = lastcad; lastcad = this; }
293  static void aval_reset(void);
294  };
295 
296  class
298 {
299  private:
300  inline IndepADvar& operator=(const IndepADvar &x) {
301  /* private to prevent assignment */
302 #ifdef RAD_AUTO_AD_Const
303  if (cv)
304  cv->padv = 0;
305  cv = new ADvar1(this,x);
306  return *this;
307 #else
308 #ifdef RAD_EQ_ALIAS
309  cv = x.cv;
310  return *this;
311 #else
312  return ADvar_operatoreq(this,*x.cv);
313 #endif
314 #endif /* RAD_AUTO_AD_Const */
315  }
316  protected:
317  static void AD_Const(const IndepADvar&);
319  public:
320  typedef double value_type;
321  friend class ADvar;
322  friend class ADvar1;
323  friend class ADvarn;
324  friend class ADcontext;
325  IndepADvar(double);
326  IndepADvar(int);
327  IndepADvar(long);
328  IndepADvar& operator=(double);
329 #ifdef RAD_AUTO_AD_Const
330  inline IndepADvar(const IndepADvar &x) { cv = x.cv ? new ADvar1(this, x) : 0; };
331  inline IndepADvar() { cv = 0; }
332  inline ~IndepADvar() {
333  if (cv)
334  cv->padv = 0;
335  }
336 #else
337  inline IndepADvar() {
338 #ifndef RAD_EQ_ALIAS
339  cv = 0;
340 #endif
341  }
342  inline ~IndepADvar() {}
343  friend IndepADvar& ADvar_operatoreq(IndepADvar*, const ADvari&);
344 #endif
345 
346  friend void AD_Const(const IndepADvar&);
347 
348  inline operator ADvari&() { return *cv; }
349  inline operator ADvari&() const { return *(ADvari*)cv; }
350 
351  inline double val() const { return cv->Val; }
352  inline double adj() const { return cv->aval; }
353  static inline void Gradcomp(int wantgrad)
354  { ADcontext::Gradcomp(wantgrad); }
355  static inline void Gradcomp()
356  { ADcontext::Gradcomp(1); }
357  static inline void Hvprod(int n, ADvar **vp, double *v, double *hv)
358  { ADcontext::Hvprod(n, vp, v, hv); }
359  static inline void aval_reset() { ConstADvari::aval_reset(); }
360  static inline void Weighted_Gradcomp(int n, ADvar **v, double *w)
361  { ADcontext::Weighted_Gradcomp(n, v, w); }
362 
363 
364 #define Ai const ADvari&
365 #define AI const IndepADvar&
366 #define T2(r,f) \
367  r f(AI,AI);\
368  r f(Ai,AI);\
369  r f(AI,Ai);\
370  r f(double,AI);\
371  r f(AI,double);
372 #define T1(f) friend ADvari& f(AI);
373 
374 #define F friend ADvari&
375 T2(F, operator+)
376 T2(F, operator-)
377 T2(F, operator*)
378 T2(F, operator/)
379 T2(F, atan2)
380 T2(F, max)
381 T2(F, min)
382 T2(F, pow)
383 #undef F
384 #define F friend int
385 T2(F, operator<)
386 T2(F, operator<=)
387 T2(F, operator==)
388 T2(F, operator!=)
389 T2(F, operator>=)
390 T2(F, operator>)
391 
392 T1(operator+)
393 T1(operator-)
394 T1(abs)
395 T1(acos)
396 T1(acosh)
397 T1(asin)
398 T1(asinh)
399 T1(atan)
400 T1(atanh)
401 T1(cos)
402 T1(cosh)
403 T1(exp)
404 T1(log)
405 T1(log10)
406 T1(sin)
407 T1(sinh)
408 T1(sqrt)
409 T1(tan)
410 T1(tanh)
411 T1(fabs)
412 T1(copy)
413 
414 #undef T1
415 #undef T2
416 #undef F
417 #undef Ai
418 #undef AI
419 
420  };
421 
422  class
423 ADvar: public IndepADvar { // an "active" variable
424  void ADvar_ctr(double d);
425  public:
426  inline ADvar() { /* cv = 0; */ }
427  inline ADvar(double d) { ADvar_ctr(d); }
428  inline ADvar(int i) { ADvar_ctr((double)i); }
429  inline ADvar(long i) { ADvar_ctr((double)i); }
430  inline ~ADvar() {}
431 #ifdef RAD_AUTO_AD_Const
432  friend class ADvar1;
433  inline ADvar(const IndepADvar &x) { cv = x.cv ? new ADvar1(this, x) : 0; }
434  inline ADvar(ADvari &x) { cv = &x; x.padv = this; }
435  inline ADvar& operator=(const IndepADvar &x) {
436  if (cv)
437  cv->padv = 0;
438  cv = new ADvar1(this,x);
439  return *this;
440  }
441  inline ADvar& operator=(const ADvari &x) {
442  if (cv)
443  cv->padv = 0;
444  cv = new ADvar1(this, x);
445  return *this;
446  }
447 #else
448  friend ADvar& ADvar_operatoreq(ADvar*, const ADvari&);
449 #ifdef RAD_EQ_ALIAS
450  /* allow aliasing v and w after "v = w;" */
451  inline ADvar(const IndepADvar &x) { cv = x.cv; }
452  inline ADvar(const ADvari &x) { cv = (ADvari*)&x; }
453  inline ADvar& operator=(const ADvari &x) { cv = (ADvari*)&x; return *this; }
454  inline ADvar& operator=(const IndepADvar &x) { cv = (ADvari*)x.cv; return *this; }
455 #else
456  ADvar(const IndepADvar &x) { cv = x.cv ?
457  new ADvar1(Hv_copy, x.cv->Val, &CADcontext::One, x.cv) : 0; }
458  ADvar(const ADvari &x) { cv = new ADvar1(Hv_copy, x.Val, &CADcontext::One, &x); }
459  inline ADvar& operator=(const ADvari &x) { return ADvar_operatoreq(this,x); }
460  inline ADvar& operator=(const IndepADvar &x) { return ADvar_operatoreq(this,*x.cv); }
461 #endif /* RAD_EQ_ALIAS */
462 #endif /* RAD_AUTO_AD_Const */
463  ADvar& operator=(double);
464  ADvar& operator+=(const ADvari&);
465  ADvar& operator+=(double);
466  ADvar& operator-=(const ADvari&);
467  ADvar& operator-=(double);
468  ADvar& operator*=(const ADvari&);
469  ADvar& operator*=(double);
470  ADvar& operator/=(const ADvari&);
471  ADvar& operator/=(double);
472  inline static bool get_fpval_implies_const(void)
474  inline static void set_fpval_implies_const(bool newval)
476  inline static bool setget_fpval_implies_const(bool newval) {
479  return oldval;
480  }
481  static inline void Gradcomp(int wantgrad)
482  { ADcontext::Gradcomp(wantgrad); }
483  static inline void Gradcomp()
484  { ADcontext::Gradcomp(1); }
485  static inline void Hvprod(int n, ADvar **vp, double *v, double *hv)
486  { ADcontext::Hvprod(n, vp, v, hv); }
487  static inline void aval_reset() { ConstADvari::aval_reset(); }
488  static inline void Weighted_Gradcomp(int n, ADvar **v, double *w)
489  { ADcontext::Weighted_Gradcomp(n, v, w); }
490  };
491 
492  inline void AD_Const(const IndepADvar&v) { IndepADvar::AD_Const(v); }
493 
494  class
495 ConstADvar: public ADvar {
496  private: // disable op=
497  ConstADvar& operator+=(const ADvari&);
498  ConstADvar& operator+=(double);
499  ConstADvar& operator-=(const ADvari&);
500  ConstADvar& operator-=(double);
501  ConstADvar& operator*=(const ADvari&);
502  ConstADvar& operator*=(double);
503  ConstADvar& operator/=(const ADvari&);
504  ConstADvar& operator/=(double);
505  void ConstADvar_ctr(double);
506  public:
507  inline ConstADvar(double d) { ConstADvar_ctr(d); }
508  inline ConstADvar(int i) { ConstADvar_ctr((double)i); }
509  inline ConstADvar(long i) { ConstADvar_ctr((double)i); }
510  ConstADvar(const ADvari &x);
511 #ifdef RAD_AUTO_AD_Const
512  ConstADvar(const IndepADvar &x) { cv = new ADvar1(this,x); }
513 #endif
514  inline ~ConstADvar(){}
515 #ifdef RAD_NO_CONST_UPDATE
516  private:
517 #endif
518  ConstADvar();
519  inline ConstADvar& operator=(double d) { cv->Val = d; return *this; }
520  inline ConstADvar& operator=(const IndepADvar& d) { cv->Val = d.val(); return *this; }
521  };
522 
523  class
524 ADvar1s: public ADvar1 { // unary ops with partials
525  public:
526  double pL; // deriv of op w.r.t. left operand L
527  ADvar1s(double val1, double d1, const ADvari *c1):
528  ADvar1(Hv_timesL,val1,&pL,c1), pL(d1) {}
529  };
530 
531  class
532 ADvar1g: public ADvar1 { // unary ops with partials
533  public:
534  double pL; // deriv of op w.r.t. left operand L
535  double pL2; // partial of op w.r.t. L,L
536  ADvar1g(double val1, double d1, double d2, const ADvari *c1):
537  ADvar1(Hv_unary,val1,&pL,c1), pL(d1), pL2(d2) {}
538  };
539 
540  class
541 ADvar2: public ADvari { // basic binary ops
542  public:
543  Derp dL, dR;
544  ADvar2(Advari_Opclass oc, double val1, const ADvari *Lcv, const double *Lc,
545  const ADvari *Rcv, const double *Rc): ADvari(oc,val1) {
546  dR.next = Derp::LastDerp;
547  dL.next = &dR;
548  Derp::LastDerp = &dL;
549  dL.a = Lc;
550  dL.c = (ADvari*)Lcv;
551  dR.a = Rc;
552  dR.c = (ADvari*)Rcv;
553  dL.b = dR.b = this;
554  }
555  };
556 
557  class
558 ADvar2q: public ADvar2 { // binary ops with partials
559  public:
560  double pL; // deriv of op w.r.t. left operand L
561  double pR; // deriv of op w.r.t. right operand R
562  double pLR; // second partial w.r.t. L,R
563  double pR2; // second partial w.r.t. R,R
564  ADvar2q(double val1, double Lp, double Rp, double LR, double R2,
565  const ADvari *Lcv, const ADvari *Rcv);
566  };
567 
568  class
569 ADvar2g: public ADvar2 { // general binary ops with partials
570  public:
571  double pL; // deriv of op w.r.t. left operand L
572  double pR; // deriv of op w.r.t. right operand R
573  double pL2; // second partial w.r.t. L,L
574  double pLR; // second partial w.r.t. L,R
575  double pR2; // second partial w.r.t. R,R
576  ADvar2g(double val1, double Lp, double Rp, double L2, double LR, double R2,
577  const ADvari *Lcv, const ADvari *Rcv);
578  };
579 
580  class
581 ADvarn: public ADvari { // n-ary ops with partials g and 2nd partials h (lower triangle, rowwise)
582  public:
583  int n;
584  double *G, *H;
585  Derp *D;
586  ADvarn(double val1, int n1, const ADvar *x, const double *g, const double *h);
587  };
588 
589 inline ADvari &operator+(ADvari &T) { return T; }
590 inline ADvari &operator+(const ADvari &T) { return (ADvari&) T; }
591 
592 inline int operator<(const ADvari &L, const ADvari &R) { return L.Val < R.Val; }
593 inline int operator<(const ADvari &L, double R) { return L.Val < R; }
594 inline int operator<(double L, const ADvari &R) { return L < R.Val; }
595 
596 inline int operator<=(const ADvari &L, const ADvari &R) { return L.Val <= R.Val; }
597 inline int operator<=(const ADvari &L, double R) { return L.Val <= R; }
598 inline int operator<=(double L, const ADvari &R) { return L <= R.Val; }
599 
600 inline int operator==(const ADvari &L, const ADvari &R) { return L.Val == R.Val; }
601 inline int operator==(const ADvari &L, double R) { return L.Val == R; }
602 inline int operator==(double L, const ADvari &R) { return L == R.Val; }
603 
604 inline int operator!=(const ADvari &L, const ADvari &R) { return L.Val != R.Val; }
605 inline int operator!=(const ADvari &L, double R) { return L.Val != R; }
606 inline int operator!=(double L, const ADvari &R) { return L != R.Val; }
607 
608 inline int operator>=(const ADvari &L, const ADvari &R) { return L.Val >= R.Val; }
609 inline int operator>=(const ADvari &L, double R) { return L.Val >= R; }
610 inline int operator>=(double L, const ADvari &R) { return L >= R.Val; }
611 
612 inline int operator>(const ADvari &L, const ADvari &R) { return L.Val > R.Val; }
613 inline int operator>(const ADvari &L, double R) { return L.Val > R; }
614 inline int operator>(double L, const ADvari &R) { return L > R.Val; }
615 
616 inline ADvari& copy(const IndepADvar &x)
617 { return *(new ADvar1(Hv_copy, x.cv->Val, &CADcontext::One, x.cv)); }
618 
619 inline ADvari& copy(const ADvari &x)
620 { return *(new ADvar1(Hv_copy, x.Val, &CADcontext::One, &x)); }
621 
622 inline ADvari& abs(const ADvari &x)
623 { return fabs(x); }
624 
625 #define A (ADvari*)
626 #define T inline
627 #define F ADvari&
628 #define Ai const ADvari&
629 #define AI const IndepADvar&
630 #define D double
631 #define T2(r,f) \
632  T r f(Ai L, AI R) { return f(L, *A R.cv); }\
633  T r f(AI L, Ai R) { return f(*A L.cv, R); }\
634  T r f(AI L, AI R) { return f(*A L.cv, *A R.cv); }\
635  T r f(AI L, D R) { return f(*A L.cv, R); }\
636  T r f(D L, AI R) { return f(L, *A R.cv); }
637 
638 T2(F, operator+)
639 T2(F, operator-)
640 T2(F, operator*)
641 T2(F, operator/)
642 T2(F, atan2)
643 T2(F, pow)
644 T2(F, max)
645 T2(F, min)
646 T2(int, operator<)
647 T2(int, operator<=)
648 T2(int, operator==)
649 T2(int, operator!=)
650 T2(int, operator>=)
651 T2(int, operator>)
652 
653 #undef T2
654 #undef D
655 
656 #define T1(f)\
657  T F f(AI x) { return f(*A x.cv); }
658 
659 T1(operator+)
660 T1(operator-)
661 T1(abs)
662 T1(acos)
663 T1(acosh)
664 T1(asin)
665 T1(asinh)
666 T1(atan)
667 T1(atanh)
668 T1(cos)
669 T1(cosh)
670 T1(exp)
671 T1(log)
672 T1(log10)
673 T1(sin)
674 T1(sinh)
675 T1(sqrt)
676 T1(tan)
677 T1(tanh)
678 T1(fabs)
679 
680 #undef T1
681 #undef AI
682 #undef Ai
683 #undef F
684 #undef T
685 #undef A
686 
687 #ifndef SACADO_NO_NAMESPACE
688 } // namespace Rad2d
689 } // namespace Sacado
690 #endif // SACADO_NAMESPACE
691 #endif // SACADO_RAD2_H
ADvari & cos(const ADvari &v)
void * Memalloc(size_t len)
asin(expr.val())
cosh(expr.val())
Advari_Opclass opclass
abs(expr.val())
static bool setget_fpval_implies_const(bool newval)
static void aval_reset(void)
static void Hvprod(int n, ADvar **vp, double *v, double *hv)
static void Weighted_Gradcomp(int n, ADvar **v, double *w)
const double * a
ADvari(Advari_Opclass oc, double t, double ta)
ADvar1s(double val1, double d1, const ADvari *c1)
int operator>(const ADvari &L, const ADvari &R)
ADvari & asinh(const ADvari &v)
IndepADvar & operator=(const IndepADvar &x)
static void AD_Const(const IndepADvar &)
atan(expr.val())
ADvari & acosh(const ADvari &v)
static void Weighted_Gradcomp(int n, ADvar **v, double *w)
void AD_Const(const IndepADvar &v)
ADvari & operator+(ADvari &T)
#define R
Definition: Sacado_rad.hpp:161
ADvari & sinh(const ADvari &v)
ADvari & atanh(const ADvari &v)
ADvari & min(const ADvari &L, const ADvari &R)
ADvari(Advari_Opclass oc, double t)
ADvari & exp(const ADvari &v)
static void Hvprod(int n, ADvar **vp, double *v, double *hv)
ADvar1g(double val1, double d1, double d2, const ADvari *c1)
ConstADvar & operator=(const IndepADvar &d)
static void Gradcomp(int wantgrad)
ADvari & fabs(const ADvari &v)
ADvar(const ADvari &x)
tanh(expr.val())
ADvari & log10(const ADvari &v)
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
static ADcontext adc
static const double One
#define T2(r, f)
Definition: Sacado_rad.hpp:558
ADvari & asin(const ADvari &v)
const ADvari * b
ADvari & ADf2(double f, double gx, double gy, double hxx, double hxy, double hyy, const ADvari &x, const ADvari &y)
ConstADvar & operator=(double d)
sqrt(expr.val())
static CADcontext cadc
sinh(expr.val())
tan(expr.val())
static Derp * LastDerp
ADvari & atan(const ADvari &v)
int operator>=(const ADvari &L, const ADvari &R)
ADvari & cosh(const ADvari &v)
int operator<(const ADvari &L, const ADvari &R)
#define T1(r, f)
Definition: Sacado_rad.hpp:583
ADvari & sin(const ADvari &v)
ADvari & tan(const ADvari &v)
atan2(expr1.val(), expr2.val())
static void Hvprod(int, ADvar **, double *, double *)
static void Gradcomp(int wantgrad)
int operator!=(const ADvari &L, const ADvari &R)
#define T
ADvari & abs(const ADvari &x)
sin(expr.val())
ADvar & operator=(const IndepADvar &x)
ADvari & sqrt(const ADvari &v)
void * new_ADmemblock(size_t)
static void Weighted_Gradcomp(int, ADvar **, double *)
ADvari & max(const ADvari &L, const ADvari &R)
log(expr.val())
ADvar & ADvar_operatoreq(ADvar *This, const ADvari &x)
ADvari & pow(const ADvari &L, const ADvari &R)
static bool get_fpval_implies_const(void)
int operator<=(const ADvari &L, const ADvari &R)
static void aval_reset()
ADvar1(Advari_Opclass oc, double val1, const double *a1, const ADvari *c1)
ADvari & log(const ADvari &v)
acos(expr.val())
static void set_fpval_implies_const(bool newval)
ADvari & acos(const ADvari &v)
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)
int operator==(const ADvari &L, const ADvari &R)
ADvar & operator=(const ADvari &x)
ADvari & copy(const IndepADvar &x)
ADvar2(Advari_Opclass oc, double val1, const ADvari *Lcv, const double *Lc, const ADvari *Rcv, const double *Rc)
ADvari & atan2(const ADvari &L, const ADvari &R)
ADvari & ADf1(double f, double g, double h, const ADvari &x)
static void Gradcomp()
exp(expr.val())
fabs(expr.val())
ADvari & ADfn(double f, int n, const ADvar *x, const double *g, const double *h)
void ADvari_record(ADvari *x)
log10(expr.val())
ADvari & tanh(const ADvari &v)
cos(expr.val())
ADvar(const IndepADvar &x)
const double y