lines 6-92 of file: example/atomic_four/mat_mul/reverse.cpp

{xrst_begin atomic_four_mat_mul_reverse.cpp}
{xrst_spell
   ccccccccc
   cccccccccc
}

Atomic Matrix Multiply Reverse Mode: Example and Test
#####################################################

Purpose
*******
This example demonstrates using reverse mode
with the :ref:`atomic_four_mat_mul-name` class.

f(x)
****
For this example, the function :math:`f(x)` is

.. math::

   f(x) =
   \left( \begin{array}{ccc}
   x_0 & x_1 & x_2  \\
   x_3 & x_4 & x_5
   \end{array} \right)
   \left( \begin{array}{c}
   x_6 \\
   x_7 \\
   x_8
   \end{array} \right)
   =
   \left( \begin{array}{c}
   x_0 * x_6 + x_1 * x_7 + x_2 * x_8 \\
   x_3 * x_6 + x_4 * x_7 + x_5 * x_8
   \end{array} \right)

Jacobian of f(x)
****************
The Jacobian of :math:`f(x)` is

.. math::

   f^{(1)} (x) = \left( \begin{array}{cccccccccc}
      x_6 & x_7 & x_8 & 0   & 0   & 0   & x_0 & x_1 & x_2 \\
      0   & 0   & 0   & x_6 & x_7 & x_8 & x_3 & x_4 & x_5
   \end{array} \right)

g(x)
****
We define the function :math:`g(x) = f_0^{(1)} (x)^\R{T}`; i.e.,

.. math::

   g(x) = ( x_6, x_7, x_8, 0, 0, 0, x_0, x_1, x_2 )^\R{T}

Hessian
*******
The Hessian of :math:`f_1(x)` is the Jacobian
of :math:`g(x)`; i.e.,

.. math::

   f_1^{(2)} (x)
   =
   g^{(1)} (x)
   =
   \left( \begin{array}{ccccccccc}
      % 0   1   2   3   4   5   6   7   8
         0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0   \\ % 0
         0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0   \\ % 1
         0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1   \\ % 2
         0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0   \\ % 3
         0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0   \\ % 4
         0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0   \\ % 5
         1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0   \\ % 6
         0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0   \\ % 7
         0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0   \\ % 8
   \end{array} \right)

Source
******
{xrst_literal
   // BEGIN C++
   // END C++
}

{xrst_end atomic_four_mat_mul_reverse.cpp}
