15 #ifndef SACADO_TRADVEC_H
16 #define SACADO_TRADVEC_H
24 #if defined(RAD_DEBUG_BLOCKKEEP) && !defined(HAVE_SACADO_UNINIT)
25 #undef RAD_DEBUG_BLOCKKEEP
28 #ifdef RAD_Const_WARN //{ ==> RAD_AUTO_AD_Const and RAD_DEBUG
29 #ifndef RAD_AUTO_AD_Const
30 #define RAD_AUTO_AD_Const
37 #endif //} RAD_Const_WARN
44 #ifndef RAD_AUTO_AD_Const
45 #ifdef RAD_DEBUG_BLOCKKEEP
53 #ifdef RAD_AUTO_AD_Const
54 #undef RAD_DEBUG_BLOCKKEEP
55 #define Padvinit ,padv(0)
58 #ifdef RAD_DEBUG_BLOCKKEEP
59 #if !(RAD_DEBUG_BLOCKKEEP > 0)
60 #undef RAD_DEBUG_BLOCKKEEP
62 extern "C" void _uninit_f2c(
void *
x,
int type,
long len);
68 struct UninitType<float> {
69 static const int utype = 4;
73 struct UninitType<double> {
74 static const int utype = 5;
78 struct UninitType< std::complex<T> > {
79 static const int utype = UninitType<T>::utype + 2;
88 template<
typename T>
class
101 #define Dtype typename DoubleAvoid<Double>::dtype
102 #define Ttype typename DoubleAvoid<Double>::ttype
107 template<
typename Double>
class ADvar;
114 template<
typename Double>
class Derp;
116 template<
typename Double>
struct
124 template<
typename Double>
class
136 #ifdef RAD_DEBUG_BLOCKKEEP
138 ADMemblock *rad_Oldcurmb;
140 void *new_ADmemblock(
size_t);
141 void derp_init(
size_t);
145 void *Memalloc(
size_t len);
146 static void Gradcomp();
147 static void aval_reset(
void);
148 static void Weighted_Gradcomp(
size_t, ADVar**,
Double*);
149 static void Weighted_GradcompVec(
size_t,
size_t*, ADVar***,
Double**);
150 static void Outvar_Gradcomp(ADVar&);
153 template<
typename Double>
class
162 template<
typename Double>
class
173 Derp(
const ADVari *);
175 Derp(
const Double *,
const ADVari *,
const ADVari *);
176 inline void *
operator new(
size_t len) {
return (
Derp*)ADVari::adc.Memalloc(len); }
182 #define Ai const ADvari<Double>&
183 #define AI const IndepADvar<Double>&
184 #define T template<typename Double>
211 #define F ADvari<Double>&
258 template<
typename Double>ADvari<Double>&
ADf1(
Double f,
Double g,
const IndepADvar<Double> &
x);
260 const IndepADvar<Double> &
x,
const IndepADvar<Double> &
y);
261 template<
typename Double>ADvari<Double>&
ADfn(
Double f,
int n,
262 const IndepADvar<Double> *
x,
const Double *g);
264 template<
typename Double> IndepADvar<Double>&
ADvar_operatoreq(IndepADvar<Double>*,
265 const ADvari<Double>&);
266 template<
typename Double> ADvar<Double>&
ADvar_operatoreq(ADvar<Double>*,
const ADvari<Double>&);
267 template<
typename Double>
void AD_Const(
const IndepADvar<Double>&);
268 template<
typename Double>
void AD_Const1(
Double*,
const IndepADvar<Double>&);
269 template<
typename Double> ADvari<Double>&
ADf1(
Double,
Double,
const ADvari<Double>&);
271 const ADvari<Double>&,
const ADvari<Double>&);
273 const IndepADvar<Double>&,
const ADvari<Double>&);
275 const ADvari<Double>&,
const IndepADvar<Double>&);
276 template<
typename Double>
Double val(
const ADvari<Double>&);
278 template<
typename Double>
class
284 #ifdef RAD_AUTO_AD_Const
286 #ifdef RAD_Const_WARN
287 mutable const IndepADVar *padv;
290 mutable const IndepADVar *padv;
291 #endif //RAD_Const_WARN
293 inline void ADvari_padv(
const IndepADVar *v) {
296 #endif //RAD_AUTO_AD_Const
300 static int gcgen_cur, last_opno, zap_gcgen, zap_gcgen1, zap_opno;
301 static FILE *debug_file;
310 Last_ADvari = &this->Next;
313 void *
operator new(
size_t len) {
316 rv->gcgen = gcgen_cur;
317 rv->opno = ++last_opno;
318 if (last_opno == zap_opno && gcgen_cur == zap_gcgen)
319 printf(
"Got to opno %d\n", last_opno);
325 void operator delete(
void*) {}
327 inline ADvari(): Val(0.), aval(0)
Padvinit { Linkup(); }
328 #ifdef RAD_AUTO_AD_Const
329 friend class ADcontext<
Double>;
330 friend class ADvar<
Double>;
331 friend class ADvar1<
Double>;
332 friend class ADvar1s<
Double>;
333 friend class ADvar2<
Double>;
334 friend class ADvar2q<
Double>;
335 friend class ConstADvar<
Double>;
336 ADvari(
const IndepADVar *,
Double);
340 #define Ai const ADvari&
341 #define T1(r,f) F r f <>(Ai);
344 F r f <>(Ttype,Ai); \
345 F r f <>(Ai,Ttype); \
346 F r f <>(double,Ai); \
347 F r f <>(Ai,double); \
395 friend ADvari& ADfn<>(
Double f,
int n,
const IndepADVar *
x,
const Double *g);
397 inline operator Double() {
return this->Val; }
398 inline operator Double()
const {
return this->Val; }
403 template<
typename Double>
class
411 ADVari(val1), d(a1,this,c1) {}
412 #ifdef RAD_AUTO_AD_Const
413 typedef typename ADVari::IndepADVar IndepADVar;
415 ADvar1(
const IndepADVar*,
const IndepADVar&);
416 ADvar1(
const IndepADVar*,
const ADVari&);
418 ADVari(val1), d(a1,this,c1) {
420 this->ADvari_padv(v);
426 template<
typename Double>
class
427 ConstADvari:
public ADvari<Double> {
439 static void aval_reset(
void);
442 template<
typename Double>
class
445 static void AD_Const(
const IndepADvar&);
450 #ifdef RAD_AUTO_AD_Const
455 #elif defined(RAD_EQ_ALIAS)
460 #endif //RAD_AUTO_AD_Const
477 #ifdef RAD_AUTO_AD_Const //{
479 inline IndepADvar() { cv = 0; }
480 inline ~IndepADvar() {
494 #ifdef RAD_Const_WARN
495 inline operator ADVari&()
const {
496 ADVari *tcv = this->cv;
501 inline operator ADVari*()
const {
502 ADVari *tcv = this->cv;
507 #else //RAD_Const_WARN
508 inline operator ADVari&()
const {
return *this->cv; }
509 inline operator ADVari*()
const {
return this->cv; }
510 #endif //RAD_Const_WARN
522 friend void AD_Const1<>(
Double*,
const IndepADvar&);
524 friend ADVari& ADf1<>(
Double,
Double,
const IndepADvar&);
542 #define Ai const ADVari&
543 #define AI const IndepADvar&
557 #define T1(f) friend ADVari& f<> (AI);
559 #define F friend ADVari&
608 template<
typename Double>
class
609 ADvar:
public IndepADvar<Double> {
620 if (ConstADVari::cadc.fpval_implies_const)
621 x =
new ConstADVari(d);
623 #ifdef RAD_AUTO_AD_Const //{
624 x =
new ADVari((IndepADVar*)
this, d);
625 x->ADvari_padv(
this);
641 #ifdef RAD_AUTO_AD_Const //{{
642 inline ADvar(IndepADVar &
x) {
643 this->cv = x.cv ?
new ADVar1(
this, x) : 0;
645 inline ADvar(ADVari &x) { this->cv = &
x; x.ADvari_padv(
this); }
646 inline ADvar& operator=(IndepADVar &x) {
649 this->cv =
new ADVar1(
this,x);
652 inline ADvar& operator=(ADVari &x) {
655 this->cv =
new ADVar1(
this, x);
659 friend ADvar& ADvar_operatoreq<>(ADvar*,
const ADVari&);
662 inline ADvar(
const IndepADVar &x) {
663 this->cv = (ADVari*)x.cv;
665 inline ADvar(
const ADVari &x) { this->cv = (ADVari*)&x; }
666 inline ADvar& operator=(IndepADVar &x) {
667 this->cv = (ADVari*)x.cv;
return *
this;
669 inline ADvar& operator=(
const ADVari &x) { this->cv = (ADVari*)&x;
return *
this; }
671 ADvar(const IndepADVar &x) {
673 this->cv =
new ADVar1(x.cv->Val, &this->cv->adc.One, x.cv);
680 this->cv =
new ADVar1(x.
cv->Val, &this->cv->adc.One, (ADVari*)x.
cv);
686 this->cv =
new ADVar1(x.
Val, &this->cv->adc.One, &x);
691 ADvar& operator=(Double);
692 ADvar& operator+=(
const ADVari&);
693 ADvar& operator+=(Double);
694 ADvar& operator-=(
const ADVari&);
695 ADvar& operator-=(Double);
696 ADvar& operator*=(
const ADVari&);
697 ADvar& operator*=(Double);
698 ADvar& operator/=(
const ADVari&);
699 ADvar& operator/=(Double);
701 {
return ConstADVari::cadc.fpval_implies_const; }
703 { ConstADVari::cadc.fpval_implies_const = newval; }
705 bool oldval = ConstADVari::cadc.fpval_implies_const;
706 ConstADVari::cadc.fpval_implies_const = newval;
710 static inline void aval_reset() { ConstADVari::aval_reset(); }
719 template<
typename Double>
723 template<
typename Double>
726 template<
typename Double>
class
727 ConstADvar:
public ADvar<Double> {
744 void ConstADvar_ctr(Double);
754 #ifdef RAD_NO_CONST_UPDATE
768 #define ADvar_nd ADvar
770 template<
typename Double>
class
771 ADvar1s:
public ADvar1<Double> {
776 ADvar1s(Double val1, Double a1,
const ADVari *c1): ADVar1(val1,&a,c1), a(a1) {}
777 #ifdef RAD_AUTO_AD_Const
779 ADvar1s(Double val1, Double a1,
const ADVari *c1,
const ADVar *v):
780 ADVar1(val1,&a,c1,v), a(a1) {}
784 template<
typename Double>
class
785 ADvar2:
public ADvari<Double> {
791 ADvar2(Double val1,
const ADVari *Lcv,
const Double *Lc,
792 const ADVari *Rcv,
const Double *Rc):
794 dR.
next = DErp::LastDerp;
796 DErp::LastDerp = &dL;
803 #ifdef RAD_AUTO_AD_Const
805 ADvar2(Double val1,
const ADVari *Lcv,
const Double *Lc,
806 const ADVari *Rcv,
const Double *Rc, ADVar *v):
808 dR.
next = DErp::LastDerp;
810 DErp::LastDerp = &dL;
817 this->ADvari_padv(v);
822 template<
typename Double>
class
823 ADvar2q:
public ADvar2<Double> {
829 ADvar2q(Double val1, Double Lp, Double Rp,
const ADVari *Lcv,
const ADVari *Rcv):
830 ADVar2(val1), a(Lp), b(Rp) {
831 this->dR.next = DErp::LastDerp;
832 this->dL.next = &this->dR;
833 DErp::LastDerp = &this->dL;
838 this->dL.b = this->dR.b =
this;
840 #ifdef RAD_AUTO_AD_Const
842 ADvar2q(Double val1, Double Lp, Double Rp,
const ADVari *Lcv,
843 const ADVari *Rcv,
const ADVar *v):
844 ADVar2(val1), a(Lp), b(Rp) {
845 this->dR.next = DErp::LastDerp;
846 this->dL.next = &this->dR;
847 DErp::LastDerp = &this->dL;
852 this->dL.b = this->dR.b =
this;
854 this->ADvari_padv(v);
859 template<
typename Double>
class
860 ADvarn:
public ADvari<Double> {
868 ADvarn(Double val1,
int n1,
const IndepADVar *x,
const Double *g):
869 ADVari(val1), n(n1) {
874 a1 = a = (Double*)ADVari::adc.Memalloc(n*
sizeof(*a));
875 d1 = Da = (DErp*)ADVari::adc.Memalloc(n*
sizeof(DErp));
876 dlast = DErp::LastDerp;
877 for(i = 0; i < n1; i++, d1++) {
885 DErp::LastDerp = dlast;
889 template<
typename Double>
892 template<
typename Double>
893 inline int operator<(const ADvari<Double> &L,
const ADvari<Double> &
R) {
return L.Val <
R.Val; }
894 template<
typename Double>
895 inline int operator<(const ADvari<Double> &L, Double
R) {
return L.Val <
R; }
896 template<
typename Double>
897 inline int operator<(Double L, const ADvari<Double> &
R) {
return L <
R.Val; }
899 template<
typename Double>
900 inline int operator<=(const ADvari<Double> &L,
const ADvari<Double> &
R) {
return L.Val <=
R.Val; }
901 template<
typename Double>
902 inline int operator<=(const ADvari<Double> &L, Double
R) {
return L.Val <=
R; }
903 template<
typename Double>
904 inline int operator<=(Double L, const ADvari<Double> &
R) {
return L <=
R.Val; }
906 template<
typename Double>
908 template<
typename Double>
910 template<
typename Double>
913 template<
typename Double>
915 template<
typename Double>
917 template<
typename Double>
920 template<
typename Double>
922 template<
typename Double>
924 template<
typename Double>
927 template<
typename Double>
929 template<
typename Double>
931 template<
typename Double>
934 template<
typename Double>
937 return Mbase + (Mleft -= len);
938 return new_ADmemblock(len);
941 template<
typename Double>
947 template<
typename Double>
954 template<
typename Double>
973 #ifndef RAD_DEBUG_gcgen1
974 #define RAD_DEBUG_gcgen1 -1
991 Mbase = (
char*)First->
memblk;
992 Mleft =
sizeof(First->memblk);
994 #ifdef RAD_DEBUG_BLOCKKEEP
1001 template<
typename Double>
void*
1005 #ifdef RAD_AUTO_AD_Const
1008 #ifdef RAD_Const_WARN
1018 ADVari::Last_ADvari = &ADVari::First_ADvari;
1019 #ifdef RAD_DEBUG_BLOCKKEEP
1020 Mleft = rad_mleft_save;
1021 if (Mleft <
sizeof(First->memblk))
1022 _uninit_f2c(Mbase + Mleft,
1023 UninitType<Double>::utype,
1024 (
sizeof(First->memblk) - Mleft)
1026 if ((mb = Busy->
next)) {
1028 for(;; mb = mb->
next) {
1030 UninitType<Double>::utype,
1031 sizeof(First->memblk)
1037 rad_Oldcurmb = Busy;
1038 if (rad_busy_blocks >= RAD_DEBUG_BLOCKKEEP) {
1039 rad_busy_blocks = 0;
1043 for(mb = Busy; mb != mb0; mb = mb1) {
1050 Mbase = (
char*)First->
memblk;
1051 Mleft =
sizeof(First->memblk);
1058 for(mb = Busy; mb != mb0; mb = mb1) {
1065 Mbase = (
char*)First->
memblk;
1066 Mleft =
sizeof(First->memblk);
1068 #ifdef RAD_AUTO_AD_Const // {
1069 if ((a = ADVari::First_ADvari)) {
1073 #ifdef RAD_Const_WARN
1074 if ((i = a->opno) > 0)
1077 v->
cv = cv =
new ADVari(v, a->
Val);
1081 v->
cv =
new ADVari(v, a->
Val);
1087 #endif // } RAD_AUTO_AD_Const
1089 return Mbase + (Mleft -= len);
1096 #ifdef RAD_DEBUG_BLOCKKEEP
1101 return (Mbase = (
char*)x->
memblk) +
1102 (Mleft =
sizeof(First->memblk) - len);
1105 template<
typename Double>
void
1115 rad_mleft_save = Mleft;
1118 len = n *
sizeof(
Double);
1124 else if (n > nmax) {
1138 Mleft = rad_mleft_save;
1143 *ADVari::Last_ADvari = 0;
1144 for(a = ADVari::First_ADvari;
a; a = a->
Next) {
1145 d = a->
aval = (Double*)Memalloc(len);
1147 do *d = 0.;
while(++d < de);
1150 d = c->
aval = (Double*)Memalloc(len);
1152 do *d = 0.;
while(++d < de);
1157 for(a = ADVari::First_ADvari;
a; a = a->
Next)
1160 else for(a = ADVari::First_ADvari;
a; a = a->
Next) {
1163 do *d = 0.;
while(++d < de);
1168 if (ADVari::gcgen_cur == ADVari::zap_gcgen1) {
1170 if (!(fname = getenv(
"RAD_DEBUG_FILE")))
1171 fname =
"rad_debug.out";
1175 ADVari::debug_file = fopen(fname,
"w");
1176 ADVari::zap_gcgen1 = -1;
1181 template<
typename Double>
void
1185 #ifdef RAD_AUTO_AD_Const
1188 #ifdef RAD_Const_WARN
1194 ADVari::adc.derp_init(1);
1195 if ((d = DErp::LastDerp) != 0) {
1198 if (ADVari::debug_file)
1200 fprintf(ADVari::debug_file,
"%d\t%d\t%g + %g * %g",
1203 fprintf(ADVari::debug_file,
" = %g\n", *d->
c->
aval);
1204 }
while((d = d->
next));
1208 while((d = d->
next));
1211 if (ADVari::debug_file) {
1212 fclose(ADVari::debug_file);
1213 ADVari::debug_file = 0;
1215 ADVari::gcgen_cur++;
1216 ADVari::last_opno = 0;
1220 template<
typename Double>
void
1225 #ifdef RAD_AUTO_AD_Const
1228 #ifdef RAD_Const_WARN
1234 ADVari::adc.derp_init(1);
1236 if ((d = DErp::LastDerp) != 0) {
1237 for(i = 0; i < n; i++)
1238 *V[i]->cv->
aval = w[i];
1240 if (ADVari::debug_file)
1242 fprintf(ADVari::debug_file,
"%d\t%d\t%g + %g * %g",
1245 fprintf(ADVari::debug_file,
" = %g\n", *d->
c->
aval);
1246 }
while((d = d->
next));
1250 while((d = d->
next));
1253 if (ADVari::debug_file) {
1254 fclose(ADVari::debug_file);
1255 ADVari::debug_file = 0;
1257 if (ADVari::debug_file)
1258 fflush(ADVari::debug_file);
1259 ADVari::gcgen_cur++;
1260 ADVari::last_opno = 0;
1264 template<
typename Double>
void
1270 Double
A, *
D, *D1, *De, *wi;
1271 #ifdef RAD_AUTO_AD_Const
1274 #ifdef RAD_Const_WARN
1280 ADVari::adc.derp_init(n);
1284 if ((d = DErp::LastDerp) != 0) {
1285 for(i = 0; i < n; i++) {
1289 for(ii = 0; ii < ni; ++ii)
1290 Vi[ii]->cv->
aval[i] = wi[ii];
1293 if (ADVari::debug_file)
1299 for(i = 0; i < n; ++
i, ++
D, ++D1) {
1300 fprintf(ADVari::debug_file,
"%d:\t%d\t%d\t%g + %g * %g",
1301 i, d->
c->opno, d->
b->opno, *D, A, *D1);
1303 fprintf(ADVari::debug_file,
" = %g\n", *D);
1305 }
while((d = d->
next));
1313 do *D++ += A * *D1++;
while(D < De);
1315 while((d = d->
next));
1318 if (ADVari::debug_file) {
1319 fclose(ADVari::debug_file);
1320 ADVari::debug_file = 0;
1322 if (ADVari::debug_file)
1323 fflush(ADVari::debug_file);
1324 ADVari::gcgen_cur++;
1325 ADVari::last_opno = 0;
1329 template<
typename Double>
void
1337 template<
typename Double>
1343 template<
typename Double>
1346 cv =
new ADVari(
Double(i));
1349 template<
typename Double>
1352 cv =
new ADVari(
Double(i));
1355 template<
typename Double>
1358 cv =
new ADVari(
Double(i));
1361 template<
typename Double>
1364 this->cv =
new ConstADVari(0.);
1367 template<
typename Double>
void
1370 this->cv =
new ConstADVari(d);
1373 template<
typename Double>
1376 ConstADVari *
y =
new ConstADVari(x.
cv->Val);
1381 template<
typename Double>
1384 ConstADVari *
y =
new ConstADVari(x.
cv->Val);
1389 template<
typename Double>
1392 ConstADVari *
y =
new ConstADVari(x.
Val);
1397 template<
typename Double>
1403 ConstADVari *ncv =
new ConstADVari(v.
val());
1404 #ifdef RAD_AUTO_AD_Const
1410 template<
typename Double>
1417 template<
typename Double>
1428 #ifdef RAD_AUTO_AD_Const
1430 template<
typename Double>
1433 this->ADvari_padv(x);
1437 template<
typename Double>
1439 ADVari(y.cv->Val), d((const Double*)&ADcontext<Double>::One, (ADVari*)this, y.cv)
1441 this->ADvari_padv(x);
1444 template<
typename Double>
1446 ADVari(y.Val), d((const Double*)&ADcontext<Double>::One, this, &y)
1448 this->ADvari_padv(x);
1453 template<
typename Double>
1461 template<
typename Double>
1472 template<
typename Double>
1476 #ifdef RAD_AUTO_AD_Const
1479 this->cv =
new ADVari(
this,d);
1481 this->cv =
new ADVari(d);
1486 template<
typename Double>
1490 #ifdef RAD_AUTO_AD_Const
1493 this->cv =
new ADVari(
this,d);
1495 this->cv = ConstADVari::cadc.fpval_implies_const
1496 ?
new ConstADVari(d)
1502 template<
typename Double>
1508 template<
typename Double>
1514 #ifdef RAD_AUTO_AD_Const
1515 #define RAD_ACA ,this
1520 template<
typename Double>
1523 ADVari *Lcv = this->cv;
1528 template<
typename Double>
1534 template<
typename Double>
1537 ADVari *tcv = this->cv;
1538 this->cv =
new ADVar1(tcv->
Val + R, &tcv->
adc.One, tcv
RAD_ACA);
1542 template<
typename Double>
1548 template<
typename Double>
1554 template<
typename Double>
1557 ADVari *Lcv = this->cv;
1562 template<
typename Double>
1568 template<
typename Double>
1571 ADVari *tcv = this->cv;
1572 this->cv =
new ADVar1(tcv->
Val - R, &tcv->
adc.One, tcv
RAD_ACA);
1576 template<
typename Double>
1582 template<
typename Double>
1588 template<
typename Double>
1591 ADVari *Lcv = this->cv;
1596 template<
typename Double>
1602 template<
typename Double>
1605 ADVari *Lcv = this->cv;
1610 template<
typename Double>
1616 template<
typename Double>
1619 Double Lv = L.
Val, Rv = R.
Val, pL = 1. / Rv, q = Lv/Rv;
1623 template<
typename Double>
1626 ADVari *Lcv = this->cv;
1627 Double Lv = Lcv->
Val, Rv = R.
Val, pL = 1. / Rv, q = Lv/Rv;
1632 template<
typename Double>
1638 template<
typename Double>
1641 Double recip = 1. / R.
Val;
1642 Double q = L * recip;
1646 template<
typename Double>
1649 ADVari *Lcv = this->cv;
1654 template<
typename Double>
1661 template<
typename Double>
1668 template<
typename Double>
1675 template<
typename Double>
1686 template<
typename Double>
1693 template<
typename Double>
1700 template<
typename Double>
1703 Double x = L.
Val,
y = R.
Val, t = x*x +
y*
y;
1707 template<
typename Double>
1710 Double
y = R.
Val, t = x*x + y*
y;
1714 template<
typename Double>
1717 Double x = L.
Val, t = x*x + y*
y;
1721 template<
typename Double>
1728 template<
typename Double>
1736 template<
typename Double>
1744 template<
typename Double>
1751 template<
typename Double>
1759 template<
typename Double>
1767 template<
typename Double>
1773 template<
typename Double>
1779 template<
typename Double>
1783 rcv->
d.a = &rcv->
Val;
1788 template<
typename Double>
1795 template<
typename Double>
1798 static double num = 1. /
std::log(10.);
1803 template<
typename Double>
1810 template<
typename Double>
1817 template<
typename Double>
1824 template<
typename Double>
1830 template<
typename Double>
1836 template<
typename Double>
1843 template<
typename Double>
1850 template<
typename Double>
1857 template<
typename Double>
1862 if ((t = v.
Val) < 0) {
1869 template<
typename Double>
1876 if ((t = v.
Val) < 0) {
1883 template<
typename Double>
1889 template<
typename Double>
1890 inline ADvari<Double>&
1895 template<
typename Double>
1901 template<
typename Double>
1907 template<
typename Double>
1913 template<
typename Double>
1919 template<
typename Double>
1925 template<
typename Double>
1926 inline ADvari<Double>&
1931 template<
typename Double>
1938 #define A (ADvari<Double>*)
1939 #ifdef RAD_Const_WARN
1940 #define C(x) (((x)->opno < 0) ? RAD_Const_Warn(x) : 0, *A x)
1944 #define T template<typename Double> inline
1945 #define F ADvari<Double>&
1946 #define Ai const ADvari<Double>&
1947 #define AI const IndepADvar<Double>&
1950 T r f(Ai L, AI R) { return f(L, C(R.cv)); }\
1951 T r f(AI L, Ai R) { return f(C(L.cv), R); }\
1952 T r f(AI L, AI R) { return f(C(L.cv), C(R.cv)); }\
1953 T r f(AI L, D R) { return f(C(L.cv), R); }\
1954 T r f(Ai L, Dtype R) { return f(L, (D)R); }\
1955 T r f(AI L, Dtype R) { return f(C(L.cv), (D)R); }\
1956 T r f(Ai L, long R) { return f(L, (D)R); }\
1957 T r f(AI L, long R) { return f(C(L.cv), (D)R); }\
1958 T r f(Ai L, int R) { return f(L, (D)R); }\
1959 T r f(AI L, int R) { return f(C(L.cv), (D)R); }\
1960 T r f(D L, AI R) { return f(L, C(R.cv)); }\
1961 T r f(Dtype L, Ai R) { return f((D)L, R); }\
1962 T r f(Dtype L, AI R) { return f((D)L, C(R.cv)); }\
1963 T r f(long L, Ai R) { return f((D)L, R); }\
1964 T r f(long L, AI R) { return f((D)L, C(R.cv)); }\
1965 T r f(int L, Ai R) { return f((D)L, R); }\
1966 T r f(int L, AI R) { return f((D)L, C(R.cv)); }
1987 T F f(AI x) { return f(C(x.cv)); }
ADvar & operator+=(const ADVari &)
ADT_RAD ADvari< double > Ai
Double val(const ADvari< Double > &)
ADvari< Double > & operator-(const ADvari< Double > &T)
ADvari< Double > & max(const ADvari< Double > &L, const ADvari< Double > &R)
ADvari< Double > & operator/(const ADvari< Double > &L, const ADvari< Double > &R)
BigUInt< n > operator+(BigUInt< n > const &a, BigUInt< n > const &b)
ADvari< Double > & atan(const ADvari< Double > &v)
ConstADvar & operator=(ADVari &d)
void AD_Const1(Double *, const IndepADvar< Double > &)
ADT_RAD IndepADvar< double > AI
ADvarn(Double val1, int n1, const IndepADVar *x, const Double *g)
ADvari< Double > & ADf1(Double f, Double g, const IndepADvar< Double > &x)
Sacado::RadVec::ADvar< double > ADVar
ADvari< Double > & log(const ADvari< Double > &v)
IndepADvar & operator=(IndepADvar &x)
static CADcontext< Double > cadc
ADVari::IndepADVar IndepADVar
IndepADvar< Double > IndepADVar
ADmemblock< Double > ADMemblock
static bool setget_fpval_implies_const(bool newval)
ADvari< Double > & ADfn(Double f, int n, const IndepADvar< Double > *x, const Double *g)
void AD_Const1(Double *, const IndepADvar< Double > &)
void AD_Const(const IndepADvar< Double > &)
static void Weighted_Gradcomp(size_t, ADVar **, Double *)
ADvari< Double > & ADf2(Double f, Double gx, Double gy, const IndepADvar< Double > &x, const IndepADvar< Double > &y)
bool operator!=(const Allocator< T > &a_t, const Allocator< U > &a_u)
ADvar & operator/=(const ADVari &)
ADvari< Double > & sinh(const ADvari< Double > &v)
ADvari< Double > & exp(const ADvari< Double > &v)
ADvari< Double > & acos(const ADvari< Double > &v)
ConstADvari< Double > ConstADVari
ADvar1(Double val1, const Double *a1, const ADVari *c1)
static void Outvar_Gradcomp(ADVar &v)
ADvari< Double > & cosh(const ADvari< Double > &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
ADVar::IndepADVar IndepADVar
void ConstADvar_ctr(Double)
FloatingPoint< double > Double
static void aval_reset(void)
bool operator>(BigUInt< n > const &a, BigUInt< n > const &b)
ADvar & operator-=(const ADVari &)
IndepADvar< Double > & ADvar_operatoreq(IndepADvar< Double > *, const ADvari< Double > &)
static int rad_need_reinit
ADvar & operator=(const ADVari &x)
bool operator>=(BigUInt< n > const &a, BigUInt< n > const &b)
ADvar2(Double val1, const ADVari *Lcv, const Double *Lc, const ADVari *Rcv, const Double *Rc)
ADvar2q(Double val1, Double Lp, Double Rp, const ADVari *Lcv, const ADVari *Rcv)
static void Weighted_Gradcomp(size_t n, ADVar **v, Double *w)
static void Outvar_Gradcomp(ADvar &v)
void * new_ADmemblock(size_t)
int RAD_Const_Warn(void *v)
static void Weighted_Gradcomp(size_t n, ADvar **v, Double *w)
static void Weighted_GradcompVec(size_t, size_t *, ADVar ***, Double **)
ADvari< Double > & tan(const ADvari< Double > &v)
ADvari< Double > & fabs(const ADvari< Double > &v)
ADvari< Double > & asin(const ADvari< Double > &v)
static void AD_Const(const IndepADvar &)
ADvari< Double > & abs(const ADvari< Double > &v)
ADvari< Double > & atanh(const ADvari< Double > &v)
ADvari< Double > & pow(const ADvari< Double > &L, const ADvari< Double > &R)
IndepADvar< Double > IndepADVar
IndepADVar::ADVari ADVari
atan2(expr1.val(), expr2.val())
ADvar & operator*=(const ADVari &)
static void set_fpval_implies_const(bool newval)
ADVar::ConstADVari ConstADVari
ADvari< Double > & operator+(const ADvari< Double > &T)
bool operator==(const Handle< T > &h1, const Handle< T > &h2)
Compare two handles.
ADvari< Double > & log10(const ADvari< Double > &v)
ADvari< Double > & acosh(const ADvari< Double > &v)
ADvari< Double > & sqrt(const ADvari< Double > &v)
ADvari< Double > & atan2(const ADvari< Double > &L, const ADvari< Double > &R)
ConstADvar & operator=(Double d)
ADvari< Double > & sin(const ADvari< Double > &v)
Turn ADvar into a meta-function class usable with mpl::apply.
static ADcontext< Double > adc
static bool get_fpval_implies_const(void)
ADvari< Double > & tanh(const ADvari< Double > &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)
ADvari< Double > & operator*(const ADvari< Double > &L, const ADvari< Double > &R)
static ConstADvari * lastcad
ADvari< Double > & asinh(const ADvari< Double > &v)
ADvari< Double > & min(const ADvari< Double > &L, const ADvari< Double > &R)
ScalarType< value_type >::type scalar_type
static void Outvar_Gradcomp(ADVar &)
void AD_Const(const IndepADvar &v)
ADvari< Double > & cos(const ADvari< Double > &v)
static void Weighted_GradcompVec(size_t n, size_t *np, ADvar ***v, Double **w)
ADvar1s(Double val1, Double a1, const ADVari *c1)
ADvar1(Double val1, const ADVari *c1)
static void Weighted_GradcompVec(size_t n, size_t *np, ADVar ***v, Double **w)
static ADvari ** Last_ADvari