19 #ifdef RAD_AUTO_AD_Const
20 ADvari *ADvari::First_ADvari, **ADvari::Last_ADvari = &ADvari::First_ADvari;
21 #undef RAD_DEBUG_BLOCKKEEP
23 #ifdef RAD_DEBUG_BLOCKKEEP
24 #if !(RAD_DEBUG_BLOCKKEEP > 0)
25 #undef RAD_DEBUG_BLOCKKEEP
27 extern "C" void _uninit_f2c(
void *
x,
int type,
long len);
29 static ADmemblock *rad_Oldcurmb;
30 static int rad_busy_blocks;
40 #ifdef RAD_DEBUG_BLOCKKEEP
41 static size_t rad_mleft_save;
59 #ifdef RAD_AUTO_AD_Const
67 #ifdef RAD_DEBUG_BLOCKKEEP
68 Mleft = rad_mleft_save;
73 if (!(mb0 = rad_Oldcurmb))
75 for(;; mb = mb->
next) {
83 if (rad_busy_blocks >= RAD_DEBUG_BLOCKKEEP) {
88 for(mb =
Busy; mb != mb0; mb = mb1) {
112 #ifdef RAD_AUTO_AD_Const
113 *ADvari::Last_ADvari = 0;
114 ADvari::Last_ADvari = &ADvari::First_ADvari;
115 if ((anext = ADvari::First_ADvari)) {
132 #ifdef RAD_DEBUG_BLOCKKEEP
152 #ifdef RAD_DEBUG_BLOCKKEEP
161 while((d = d->
next));
177 #ifdef RAD_DEBUG_BLOCKKEEP
183 for(i = 0; i < n; i++)
184 v[i]->cv->aval = w[i];
186 while((d = d->
next));
190 #ifdef RAD_AUTO_AD_Const
199 cv =
new ADvari(
this,d);
204 cv =
new ADvari(
this,d);
209 IndepADvar::IndepADvar(double d)
232 #ifdef RAD_AUTO_AD_Const
265 #ifdef RAD_AUTO_AD_Const
281 #ifdef RAD_AUTO_AD_Const
291 ADvari(y.cv->Val), d(&CADcontext::One, this, y.cv)
293 *ADvari::Last_ADvari =
this;
294 ADvari::Last_ADvari = &Next;
295 padv = (IndepADvar*)x;
299 ADvari(y.Val), d(&CADcontext::One, this, &y)
301 *ADvari::Last_ADvari =
this;
302 ADvari::Last_ADvari = &Next;
303 padv = (IndepADvar*)x;
321 #ifdef RAD_AUTO_AD_Const
334 #ifdef RAD_AUTO_AD_Const
359 #ifdef RAD_AUTO_AD_Const
374 #ifdef RAD_AUTO_AD_Const
394 #ifdef RAD_AUTO_AD_Const
409 #ifdef RAD_AUTO_AD_Const
429 #ifdef RAD_AUTO_AD_Const
444 #ifdef RAD_AUTO_AD_Const
458 double Lv = L.
Val, Rv = R.
Val, pL = 1. / Rv, q = Lv/Rv;
459 return *(
new ADvar2q(q, pL, -q*pL, &L, &R));
465 #ifdef RAD_AUTO_AD_Const
468 double Lv = Lcv->
Val, Rv = R.
Val, pL = 1. / Rv, q = Lv/Rv;
480 double recip = 1. / R.
Val;
481 double q = L * recip;
482 return *(
new ADvar1s(q, -q*recip, &R));
488 #ifdef RAD_AUTO_AD_Const
503 double t = v.
Val, t1 =
sqrt(t*t - 1.);
504 return *(
new ADvar1s(
log(t + t1), 1./t1, &v));
515 double t = v.
Val, td = 1., t1 =
sqrt(t*t + 1.);
520 return *(
new ADvar1s(td*
log(t + t1), 1./t1, &v));
532 return *(
new ADvar1s(0.5*
log((1.+t)/(1.-t)), 1./(1. - t*t), &v));
583 double y = R.
Val, t = x*x + y*
y;
589 double x = L.
Val, t = x*x + y*
y;
606 rcv->
d.
a = &rcv->
Val;
619 static double num = 1. /
log(10.);
638 double x = L.
Val, t =
pow(x,y);
639 return *(
new ADvar1s(t, y*t/x, &L));
655 return *(
new ADvar1s(t, 0.5/t, &v));
675 if ((t = v.
Val) < 0) {
679 return *(
new ADvar1s(t, p, &v));
684 return *(
new ADvar1s(f, g, &x));
689 return *(
new ADvar2q(f, gx, gy, &x, &y));
701 for(i = 0; i < n1; i++, d1++) {
714 return *(
new ADvarn(f, n, x, g));
ADvar & operator+=(const ADvari &)
ADvari & asin(const ADvari &v)
static void AD_Const(const IndepADvar &)
ADvari & sin(const ADvari &v)
ADvari & max(const ADvari &L, const ADvari &R)
void * new_ADmemblock(size_t)
ADvari & acosh(const ADvari &v)
ADvar & operator-=(const ADvari &)
ADvar & operator=(const ADvari &x)
ADvari & operator*(const ADvari &L, const ADvari &R)
ADvari & log(const ADvari &v)
ADvari & operator-(const ADvari &T)
ADvari & log10(const ADvari &v)
ADvari & asinh(const ADvari &v)
Sacado::Rad::ADvar< double > R
ADvari & atanh(const ADvari &v)
static void Weighted_Gradcomp(int, ADvar **, double *)
ADvari & operator/(const ADvari &L, const ADvari &R)
ADvar & operator*=(const ADvari &)
ADvari & fabs(const ADvari &v)
ADvari & atan(const ADvari &v)
ADvarn(double val1, int n1, const ADvar *x, const double *g)
static ConstADvari * lastcad
static int rad_need_reinit
ADvari & cosh(const ADvari &v)
ADvari & tan(const ADvari &v)
static void aval_reset(void)
ADvari & tanh(const ADvari &v)
IndepADvar & operator=(const IndepADvar &x)
ADvari & operator+(ADvari &T)
static const double negOne
ADvari & cos(const ADvari &v)
ADvari & ADfn(double f, int n, const ADvar *x, const double *g)
ADvari & sqrt(const ADvari &v)
ADvari & acos(const ADvari &v)
ADvar & ADvar_operatoreq(ADvar *This, const ADvari &x)
ADvar & operator/=(const ADvari &)
ADvari & ADf1(double f, double g, const ADvari &x)
ADvari & exp(const ADvari &v)
void ConstADvar_ctr(double)
ADvari & atan2(const ADvari &L, const ADvari &R)
ADvari & pow(const ADvari &L, const ADvari &R)
ADvari & ADf2(double f, double gx, double gy, const ADvari &x, const ADvari &y)
ADvari & min(const ADvari &L, const ADvari &R)
ADvari & sinh(const ADvari &v)