39 #ifdef RAD_AUTO_AD_Const
40 ADvari *ADvari::First_ADvari, **ADvari::Last_ADvari = &ADvari::First_ADvari;
41 #undef RAD_DEBUG_BLOCKKEEP
43 #ifdef RAD_DEBUG_BLOCKKEEP
44 #if !(RAD_DEBUG_BLOCKKEEP > 0)
45 #undef RAD_DEBUG_BLOCKKEEP
47 extern "C" void _uninit_f2c(
void *x,
int type,
long len);
49 static ADmemblock *rad_Oldcurmb;
50 static int rad_busy_blocks;
60 #ifdef RAD_DEBUG_BLOCKKEEP
61 static size_t rad_mleft_save;
79 #ifdef RAD_AUTO_AD_Const
87 #ifdef RAD_DEBUG_BLOCKKEEP
88 Mleft = rad_mleft_save;
93 if (!(mb0 = rad_Oldcurmb))
95 for(;; mb = mb->
next) {
103 if (rad_busy_blocks >= RAD_DEBUG_BLOCKKEEP) {
108 for(mb =
Busy; mb != mb0; mb = mb1) {
132 #ifdef RAD_AUTO_AD_Const
133 *ADvari::Last_ADvari = 0;
134 ADvari::Last_ADvari = &ADvari::First_ADvari;
135 if ((anext = ADvari::First_ADvari)) {
152 #ifdef RAD_DEBUG_BLOCKKEEP
172 #ifdef RAD_DEBUG_BLOCKKEEP
181 while((d = d->
next));
197 #ifdef RAD_DEBUG_BLOCKKEEP
203 for(i = 0; i < n; i++)
204 v[i]->cv->aval = w[i];
206 while((d = d->
next));
210 #ifdef RAD_AUTO_AD_Const
219 cv =
new ADvari(
this,d);
224 cv =
new ADvari(
this,d);
229 IndepADvar::IndepADvar(double d)
252 #ifdef RAD_AUTO_AD_Const
285 #ifdef RAD_AUTO_AD_Const
301 #ifdef RAD_AUTO_AD_Const
311 ADvari(y.cv->Val), d(&CADcontext::One, this, y.cv)
313 *ADvari::Last_ADvari =
this;
314 ADvari::Last_ADvari = &Next;
315 padv = (IndepADvar*)x;
319 ADvari(y.Val), d(&CADcontext::One, this, &y)
321 *ADvari::Last_ADvari =
this;
322 ADvari::Last_ADvari = &Next;
323 padv = (IndepADvar*)x;
341 #ifdef RAD_AUTO_AD_Const
354 #ifdef RAD_AUTO_AD_Const
379 #ifdef RAD_AUTO_AD_Const
394 #ifdef RAD_AUTO_AD_Const
414 #ifdef RAD_AUTO_AD_Const
429 #ifdef RAD_AUTO_AD_Const
449 #ifdef RAD_AUTO_AD_Const
464 #ifdef RAD_AUTO_AD_Const
478 double Lv = L.
Val, Rv = R.
Val, pL = 1. / Rv, q = Lv/Rv;
479 return *(
new ADvar2q(q, pL, -q*pL, &L, &R));
485 #ifdef RAD_AUTO_AD_Const
488 double Lv = Lcv->
Val, Rv = R.
Val, pL = 1. / Rv, q = Lv/Rv;
500 double recip = 1. / R.
Val;
501 double q = L * recip;
502 return *(
new ADvar1s(q, -q*recip, &R));
508 #ifdef RAD_AUTO_AD_Const
523 double t = v.
Val, t1 =
sqrt(t*t - 1.);
524 return *(
new ADvar1s(
log(t + t1), 1./t1, &v));
535 double t = v.
Val, td = 1., t1 =
sqrt(t*t + 1.);
540 return *(
new ADvar1s(td*
log(t + t1), 1./t1, &v));
552 return *(
new ADvar1s(0.5*
log((1.+t)/(1.-t)), 1./(1. - t*t), &v));
597 double x = L.
Val, y = R.
Val, t = x*x + y*y;
603 double y = R.
Val, t = x*x + y*y;
609 double x = L.
Val, t = x*x + y*y;
626 rcv->
d.
a = &rcv->
Val;
639 static double num = 1. /
log(10.);
646 double x = L.
Val, y = R.
Val, t =
pow(x,y);
647 return *(
new ADvar2q(t, y*t/x, t*
log(x), &L, &R));
658 double x = L.
Val, t =
pow(x,y);
659 return *(
new ADvar1s(t, y*t/x, &L));
675 return *(
new ADvar1s(t, 0.5/t, &v));
695 if ((t = v.
Val) < 0) {
699 return *(
new ADvar1s(t, p, &v));
704 return *(
new ADvar1s(f, g, &x));
709 return *(
new ADvar2q(f, gx, gy, &x, &y));
721 for(i = 0; i < n1; i++, d1++) {
733 ADfn(
double f,
int n,
const ADvar *x,
const double *g) {
734 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)