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  void operator delete(void*) {} /*Should never be called.*/
293  inline ConstADvari(double t): ADvari(Hv_copy, t) { prevcad = lastcad; lastcad = this; }
294  static void aval_reset(void);
295  };
296 
297  class
299 {
300  private:
301  inline IndepADvar& operator=(const IndepADvar &x) {
302  /* private to prevent assignment */
303 #ifdef RAD_AUTO_AD_Const
304  if (cv)
305  cv->padv = 0;
306  cv = new ADvar1(this,x);
307  return *this;
308 #else
309 #ifdef RAD_EQ_ALIAS
310  cv = x.cv;
311  return *this;
312 #else
313  return ADvar_operatoreq(this,*x.cv);
314 #endif
315 #endif /* RAD_AUTO_AD_Const */
316  }
317  protected:
318  static void AD_Const(const IndepADvar&);
320  public:
321  typedef double value_type;
322  friend class ADvar;
323  friend class ADvar1;
324  friend class ADvarn;
325  friend class ADcontext;
326  IndepADvar(double);
327  IndepADvar(int);
328  IndepADvar(long);
329  IndepADvar& operator=(double);
330 #ifdef RAD_AUTO_AD_Const
331  inline IndepADvar(const IndepADvar &x) { cv = x.cv ? new ADvar1(this, x) : 0; };
332  inline IndepADvar() { cv = 0; }
333  inline ~IndepADvar() {
334  if (cv)
335  cv->padv = 0;
336  }
337 #else
338  inline IndepADvar() {
339 #ifndef RAD_EQ_ALIAS
340  cv = 0;
341 #endif
342  }
343  inline ~IndepADvar() {}
344  friend IndepADvar& ADvar_operatoreq(IndepADvar*, const ADvari&);
345 #endif
346 
347  friend void AD_Const(const IndepADvar&);
348 
349  inline operator ADvari&() { return *cv; }
350  inline operator ADvari&() const { return *(ADvari*)cv; }
351 
352  inline double val() const { return cv->Val; }
353  inline double adj() const { return cv->aval; }
354  static inline void Gradcomp(int wantgrad)
355  { ADcontext::Gradcomp(wantgrad); }
356  static inline void Gradcomp()
357  { ADcontext::Gradcomp(1); }
358  static inline void Hvprod(int n, ADvar **vp, double *v, double *hv)
359  { ADcontext::Hvprod(n, vp, v, hv); }
360  static inline void aval_reset() { ConstADvari::aval_reset(); }
361  static inline void Weighted_Gradcomp(int n, ADvar **v, double *w)
362  { ADcontext::Weighted_Gradcomp(n, v, w); }
363 
364 
365 #define Ai const ADvari&
366 #define AI const IndepADvar&
367 #define T2(r,f) \
368  r f(AI,AI);\
369  r f(Ai,AI);\
370  r f(AI,Ai);\
371  r f(double,AI);\
372  r f(AI,double);
373 #define T1(f) friend ADvari& f(AI);
374 
375 #define F friend ADvari&
376 T2(F, operator+)
377 T2(F, operator-)
378 T2(F, operator*)
379 T2(F, operator/)
380 T2(F, atan2)
381 T2(F, max)
382 T2(F, min)
383 T2(F, pow)
384 #undef F
385 #define F friend int
386 T2(F, operator<)
387 T2(F, operator<=)
388 T2(F, operator==)
389 T2(F, operator!=)
390 T2(F, operator>=)
391 T2(F, operator>)
392 
393 T1(operator+)
394 T1(operator-)
395 T1(abs)
396 T1(acos)
397 T1(acosh)
398 T1(asin)
399 T1(asinh)
400 T1(atan)
401 T1(atanh)
402 T1(cos)
403 T1(cosh)
404 T1(exp)
405 T1(log)
406 T1(log10)
407 T1(sin)
408 T1(sinh)
409 T1(sqrt)
410 T1(tan)
411 T1(tanh)
412 T1(fabs)
413 T1(copy)
414 
415 #undef T1
416 #undef T2
417 #undef F
418 #undef Ai
419 #undef AI
420 
421  };
422 
423  class
424 ADvar: public IndepADvar { // an "active" variable
425  void ADvar_ctr(double d);
426  public:
427  inline ADvar() { /* cv = 0; */ }
428  inline ADvar(double d) { ADvar_ctr(d); }
429  inline ADvar(int i) { ADvar_ctr((double)i); }
430  inline ADvar(long i) { ADvar_ctr((double)i); }
431  inline ~ADvar() {}
432 #ifdef RAD_AUTO_AD_Const
433  friend class ADvar1;
434  inline ADvar(const IndepADvar &x) { cv = x.cv ? new ADvar1(this, x) : 0; }
435  inline ADvar(ADvari &x) { cv = &x; x.padv = this; }
436  inline ADvar& operator=(const IndepADvar &x) {
437  if (cv)
438  cv->padv = 0;
439  cv = new ADvar1(this,x);
440  return *this;
441  }
442  inline ADvar& operator=(const ADvari &x) {
443  if (cv)
444  cv->padv = 0;
445  cv = new ADvar1(this, x);
446  return *this;
447  }
448 #else
449  friend ADvar& ADvar_operatoreq(ADvar*, const ADvari&);
450 #ifdef RAD_EQ_ALIAS
451  /* allow aliasing v and w after "v = w;" */
452  inline ADvar(const IndepADvar &x) { cv = x.cv; }
453  inline ADvar(const ADvari &x) { cv = (ADvari*)&x; }
454  inline ADvar& operator=(const ADvari &x) { cv = (ADvari*)&x; return *this; }
455  inline ADvar& operator=(const IndepADvar &x) { cv = (ADvari*)x.cv; return *this; }
456 #else
457  ADvar(const IndepADvar &x) { cv = x.cv ?
458  new ADvar1(Hv_copy, x.cv->Val, &CADcontext::One, x.cv) : 0; }
459  ADvar(const ADvari &x) { cv = new ADvar1(Hv_copy, x.Val, &CADcontext::One, &x); }
460  inline ADvar& operator=(const ADvari &x) { return ADvar_operatoreq(this,x); }
461  inline ADvar& operator=(const IndepADvar &x) { return ADvar_operatoreq(this,*x.cv); }
462 #endif /* RAD_EQ_ALIAS */
463 #endif /* RAD_AUTO_AD_Const */
464  ADvar& operator=(double);
465  ADvar& operator+=(const ADvari&);
466  ADvar& operator+=(double);
467  ADvar& operator-=(const ADvari&);
468  ADvar& operator-=(double);
469  ADvar& operator*=(const ADvari&);
470  ADvar& operator*=(double);
471  ADvar& operator/=(const ADvari&);
472  ADvar& operator/=(double);
473  inline static bool get_fpval_implies_const(void)
475  inline static void set_fpval_implies_const(bool newval)
477  inline static bool setget_fpval_implies_const(bool newval) {
480  return oldval;
481  }
482  static inline void Gradcomp(int wantgrad)
483  { ADcontext::Gradcomp(wantgrad); }
484  static inline void Gradcomp()
485  { ADcontext::Gradcomp(1); }
486  static inline void Hvprod(int n, ADvar **vp, double *v, double *hv)
487  { ADcontext::Hvprod(n, vp, v, hv); }
488  static inline void aval_reset() { ConstADvari::aval_reset(); }
489  static inline void Weighted_Gradcomp(int n, ADvar **v, double *w)
490  { ADcontext::Weighted_Gradcomp(n, v, w); }
491  };
492 
493  inline void AD_Const(const IndepADvar&v) { IndepADvar::AD_Const(v); }
494 
495  class
496 ConstADvar: public ADvar {
497  private: // disable op=
498  ConstADvar& operator+=(const ADvari&);
499  ConstADvar& operator+=(double);
500  ConstADvar& operator-=(const ADvari&);
501  ConstADvar& operator-=(double);
502  ConstADvar& operator*=(const ADvari&);
503  ConstADvar& operator*=(double);
504  ConstADvar& operator/=(const ADvari&);
505  ConstADvar& operator/=(double);
506  void ConstADvar_ctr(double);
507  public:
508  inline ConstADvar(double d) { ConstADvar_ctr(d); }
509  inline ConstADvar(int i) { ConstADvar_ctr((double)i); }
510  inline ConstADvar(long i) { ConstADvar_ctr((double)i); }
511  ConstADvar(const ADvari &x);
512 #ifdef RAD_AUTO_AD_Const
513  ConstADvar(const IndepADvar &x) { cv = new ADvar1(this,x); }
514 #endif
515  inline ~ConstADvar(){}
516 #ifdef RAD_NO_CONST_UPDATE
517  private:
518 #endif
519  ConstADvar();
520  inline ConstADvar& operator=(double d) { cv->Val = d; return *this; }
521  inline ConstADvar& operator=(const IndepADvar& d) { cv->Val = d.val(); return *this; }
522  };
523 
524  class
525 ADvar1s: public ADvar1 { // unary ops with partials
526  public:
527  double pL; // deriv of op w.r.t. left operand L
528  ADvar1s(double val1, double d1, const ADvari *c1):
529  ADvar1(Hv_timesL,val1,&pL,c1), pL(d1) {}
530  };
531 
532  class
533 ADvar1g: public ADvar1 { // unary ops with partials
534  public:
535  double pL; // deriv of op w.r.t. left operand L
536  double pL2; // partial of op w.r.t. L,L
537  ADvar1g(double val1, double d1, double d2, const ADvari *c1):
538  ADvar1(Hv_unary,val1,&pL,c1), pL(d1), pL2(d2) {}
539  };
540 
541  class
542 ADvar2: public ADvari { // basic binary ops
543  public:
544  Derp dL, dR;
545  ADvar2(Advari_Opclass oc, double val1, const ADvari *Lcv, const double *Lc,
546  const ADvari *Rcv, const double *Rc): ADvari(oc,val1) {
547  dR.next = Derp::LastDerp;
548  dL.next = &dR;
549  Derp::LastDerp = &dL;
550  dL.a = Lc;
551  dL.c = (ADvari*)Lcv;
552  dR.a = Rc;
553  dR.c = (ADvari*)Rcv;
554  dL.b = dR.b = this;
555  }
556  };
557 
558  class
559 ADvar2q: public ADvar2 { // binary ops with partials
560  public:
561  double pL; // deriv of op w.r.t. left operand L
562  double pR; // deriv of op w.r.t. right operand R
563  double pLR; // second partial w.r.t. L,R
564  double pR2; // second partial w.r.t. R,R
565  ADvar2q(double val1, double Lp, double Rp, double LR, double R2,
566  const ADvari *Lcv, const ADvari *Rcv);
567  };
568 
569  class
570 ADvar2g: public ADvar2 { // general binary ops with partials
571  public:
572  double pL; // deriv of op w.r.t. left operand L
573  double pR; // deriv of op w.r.t. right operand R
574  double pL2; // second partial w.r.t. L,L
575  double pLR; // second partial w.r.t. L,R
576  double pR2; // second partial w.r.t. R,R
577  ADvar2g(double val1, double Lp, double Rp, double L2, double LR, double R2,
578  const ADvari *Lcv, const ADvari *Rcv);
579  };
580 
581  class
582 ADvarn: public ADvari { // n-ary ops with partials g and 2nd partials h (lower triangle, rowwise)
583  public:
584  int n;
585  double *G, *H;
586  Derp *D;
587  ADvarn(double val1, int n1, const ADvar *x, const double *g, const double *h);
588  };
589 
590 inline ADvari &operator+(ADvari &T) { return T; }
591 inline ADvari &operator+(const ADvari &T) { return (ADvari&) T; }
592 
593 inline int operator<(const ADvari &L, const ADvari &R) { return L.Val < R.Val; }
594 inline int operator<(const ADvari &L, double R) { return L.Val < R; }
595 inline int operator<(double L, const ADvari &R) { return L < R.Val; }
596 
597 inline int operator<=(const ADvari &L, const ADvari &R) { return L.Val <= R.Val; }
598 inline int operator<=(const ADvari &L, double R) { return L.Val <= R; }
599 inline int operator<=(double L, const ADvari &R) { return L <= R.Val; }
600 
601 inline int operator==(const ADvari &L, const ADvari &R) { return L.Val == R.Val; }
602 inline int operator==(const ADvari &L, double R) { return L.Val == R; }
603 inline int operator==(double L, const ADvari &R) { return L == R.Val; }
604 
605 inline int operator!=(const ADvari &L, const ADvari &R) { return L.Val != R.Val; }
606 inline int operator!=(const ADvari &L, double R) { return L.Val != R; }
607 inline int operator!=(double L, const ADvari &R) { return L != R.Val; }
608 
609 inline int operator>=(const ADvari &L, const ADvari &R) { return L.Val >= R.Val; }
610 inline int operator>=(const ADvari &L, double R) { return L.Val >= R; }
611 inline int operator>=(double L, const ADvari &R) { return L >= R.Val; }
612 
613 inline int operator>(const ADvari &L, const ADvari &R) { return L.Val > R.Val; }
614 inline int operator>(const ADvari &L, double R) { return L.Val > R; }
615 inline int operator>(double L, const ADvari &R) { return L > R.Val; }
616 
617 inline ADvari& copy(const IndepADvar &x)
618 { return *(new ADvar1(Hv_copy, x.cv->Val, &CADcontext::One, x.cv)); }
619 
620 inline ADvari& copy(const ADvari &x)
621 { return *(new ADvar1(Hv_copy, x.Val, &CADcontext::One, &x)); }
622 
623 inline ADvari& abs(const ADvari &x)
624 { return fabs(x); }
625 
626 #define A (ADvari*)
627 #define T inline
628 #define F ADvari&
629 #define Ai const ADvari&
630 #define AI const IndepADvar&
631 #define D double
632 #define T2(r,f) \
633  T r f(Ai L, AI R) { return f(L, *A R.cv); }\
634  T r f(AI L, Ai R) { return f(*A L.cv, R); }\
635  T r f(AI L, AI R) { return f(*A L.cv, *A R.cv); }\
636  T r f(AI L, D R) { return f(*A L.cv, R); }\
637  T r f(D L, AI R) { return f(L, *A R.cv); }
638 
639 T2(F, operator+)
640 T2(F, operator-)
641 T2(F, operator*)
642 T2(F, operator/)
643 T2(F, atan2)
644 T2(F, pow)
645 T2(F, max)
646 T2(F, min)
647 T2(int, operator<)
648 T2(int, operator<=)
649 T2(int, operator==)
650 T2(int, operator!=)
651 T2(int, operator>=)
652 T2(int, operator>)
653 
654 #undef T2
655 #undef D
656 
657 #define T1(f)\
658  T F f(AI x) { return f(*A x.cv); }
659 
660 T1(operator+)
661 T1(operator-)
662 T1(abs)
663 T1(acos)
664 T1(acosh)
665 T1(asin)
666 T1(asinh)
667 T1(atan)
668 T1(atanh)
669 T1(cos)
670 T1(cosh)
671 T1(exp)
672 T1(log)
673 T1(log10)
674 T1(sin)
675 T1(sinh)
676 T1(sqrt)
677 T1(tan)
678 T1(tanh)
679 T1(fabs)
680 
681 #undef T1
682 #undef AI
683 #undef Ai
684 #undef F
685 #undef T
686 #undef A
687 
688 #ifndef SACADO_NO_NAMESPACE
689 } // namespace Rad2d
690 } // namespace Sacado
691 #endif // SACADO_NAMESPACE
692 #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)
const double y
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)