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