Prev | Next |
f
is an
ADFun<Base>
object,
the vectors returned by
f.Forward
,
and
f.Reverse
,
have values of type
Base
and not
AD<Base>
.
This reflects the fact that operations used to calculate
these function values are not recorded by the tape corresponding to
AD<Base>
operations.
f.Forward
might be used as part of
Taylor's method for solving ordinary
differential equations.
In addition, we might want to differentiate the
solution of a differential equation with respect to parameters
in the equation.
This can be accomplished in the following way:
AD< AD<double> >
.
AD<double>
class.
double
class.
AD< AD<double> >
recording depend on the
variables
in the
AD<double>
recording,
we must first declaring these variables; i.e.,
Independent(a1x)
where
a1x
is
a SimpleVector
with elements of type
AD<double>
.
This will start recording a new tape of
operations performed using
AD<double>
class objects.
Independent(a2x)
where
a2x
is
a SimpleVector
with elements of type
AD< AD<double> >
.
This will start recording a new tape of
operations performed using
AD< AD<double> >
class objects.
AD< AD<double> >
class objects.
We then stop the recording using
a1f.Dependent(a2x, a2y)
where
a2y
is
a SimpleVector
with elements of type
AD< AD<double> >
and
a1f
is an
ADFun< AD<double> >
object.
AD< AD<double> >
recording depend on the
variables
in the
AD<double>
recording,
it is preferred to delay declaring these variables to this point; i.e.,
Independent(a1x)
where
a1x
is
a SimpleVector
with elements of type
AD<double>
.
This will start recording a new tape of
operations performed using
AD<double>
class objects.
AD<double>
class objects.
Note that derivatives of the inner function can be included
in the calculation of the outer function using
a1f
.
We then stop the recording of
AD<double>
operations using
g.Dependent(a1x, a1y)
where
a1y
is
a SimpleVector
with elements of type
AD<double>
and
g
is an
ADFun<double>
object.
g
can then be used to calculate
the derivatives of the outer function.