lines 9-136 of file: include/cppad/core/rev_two.hpp

{xrst_begin RevTwo}
{xrst_spell
   ddw
}

Reverse Mode Second Partial Derivative Driver
#############################################

Syntax
******
*ddw* = *f* . ``RevTwo`` ( *x* , *i* , *j* )

Purpose
*******
We use :math:`F : \B{R}^n \rightarrow \B{R}^m` to denote the
:ref:`glossary@AD Function` corresponding to *f* .
The syntax above sets

.. math::

   ddw [ k * p + \ell ]
   =
   \DD{ F_{i[ \ell ]} }{ x_{j[ \ell ]} }{ x_k } (x)

for :math:`k = 0 , \ldots , n-1`
and :math:`\ell = 0 , \ldots , p`,
where :math:`p` is the size of the vectors *i* and *j* .

f
*
The object *f* has prototype

   ``ADFun`` < *Base* > *f*

Note that the :ref:`ADFun-name` object *f* is not ``const``
(see :ref:`RevTwo@RevTwo Uses Forward` below).

x
*
The argument *x* has prototype

   ``const`` *BaseVector* & *x*

(see :ref:`RevTwo@BaseVector` below)
and its size
must be equal to *n* , the dimension of the
:ref:`fun_property@Domain` space for *f* .
It specifies
that point at which to evaluate the partial derivatives listed above.

i
*
The argument *i* has prototype

   ``const`` *SizeVector_t* & *i*

(see :ref:`RevTwo@SizeVector_t` below)
We use *p* to denote the size of the vector *i* .
All of the indices in *i*
must be less than *m* , the dimension of the
:ref:`fun_property@Range` space for *f* ; i.e.,
for :math:`\ell = 0 , \ldots , p-1`, :math:`i[ \ell ]  < m`.

j
*
The argument *j* has prototype

   ``const`` *SizeVector_t* & *j*

(see :ref:`RevTwo@SizeVector_t` below)
and its size must be equal to *p* ,
the size of the vector *i* .
All of the indices in *j*
must be less than *n* ; i.e.,
for :math:`\ell = 0 , \ldots , p-1`, :math:`j[ \ell ]  < n`.

ddw
***
The result *ddw* has prototype

   *BaseVector* *ddw*

(see :ref:`RevTwo@BaseVector` below)
and its size is :math:`n * p`.
It contains the requested partial derivatives; to be specific,
for :math:`k = 0 , \ldots , n - 1`
and :math:`\ell = 0 , \ldots , p - 1`

.. math::

   ddw [ k * p + \ell ]
   =
   \DD{ F_{i[ \ell ]} }{ x_{j[ \ell ]} }{ x_k } (x)

BaseVector
**********
The type *BaseVector* must be a :ref:`SimpleVector-name` class with
:ref:`elements of type Base<SimpleVector@Elements of Specified Type>` .
The routine :ref:`CheckSimpleVector-name` will generate an error message
if this is not the case.

SizeVector_t
************
The type *SizeVector_t* must be a :ref:`SimpleVector-name` class with
:ref:`elements of type size_t<SimpleVector@Elements of Specified Type>` .
The routine :ref:`CheckSimpleVector-name` will generate an error message
if this is not the case.

RevTwo Uses Forward
*******************
After each call to :ref:`Forward-name` ,
the object *f* contains the corresponding
:ref:`Taylor coefficients<glossary@Taylor Coefficient>` .
After a call to ``RevTwo`` ,
the zero order Taylor coefficients correspond to
*f* . ``Forward`` (0, *x* )
and the other coefficients are unspecified.

Examples
********
{xrst_toc_hidden
   example/general/rev_two.cpp
}
The routine
:ref:`RevTwo<rev_two.cpp-name>` is both an example and test.
It returns ``true`` , if it succeeds and ``false`` otherwise.

{xrst_end RevTwo}
