lines 6-77 of file: example/atomic_four/mat_mul/identical_zero.cpp

{xrst_begin atomic_four_mat_mul_identical_zero.cpp}

Atomic Matrix Multiply Identical Zero: Example and Test
#######################################################

Purpose
*******
This example demonstrates how the
:ref:`atomic_four_mat_mul_for_type.hpp-name`
routine uses the *identical_zero_enum* type to reduce the number
of variables.

Zero
****
The first case computes the following matrix product

.. math::

   \left( \begin{array}{ccc}
   u_0 & 0   & 0 \\
   0   & u_1 & 0 \\
   0   & 0   & u_2
   \end{array} \right)
   \left( \begin{array}{ccc}
   u_3 & 0   & 0 \\
   0   & u_4 & 0 \\
   0   & 0   & u_5
   \end{array} \right)
   =
   \left( \begin{array}{ccc}
   u_0 u_3 & 0       & 0 \\
   0       & u_1 u_4 & 0 \\
   0       & 0       & u_2 u_5
   \end{array} \right)

The result matrix for this case has three variables,
one for each product on the diagonal.

One
***
The second case computes the following matrix product

.. math::

   \left( \begin{array}{ccc}
   u_0 & 1   & 1 \\
   1   & u_1 & 1 \\
   1   & 1   & u_2
   \end{array} \right)
   \left( \begin{array}{ccc}
   u_3 & 1   & 1 \\
   1   & u_4 & 1 \\
   1   & 1   & u_5
   \end{array} \right)
   =
   \left( \begin{array}{ccc}
   u_0 u_3 + 2   & u_0 + u_3 + 1 & u_0 + u_5 + 1 \\
   u_1 + u_3 + 1 & u_1 u_4 + 2   & u_1 + u_5 + 1  \\
   u_2 + u_3 + 1 & u_2 + u_4 + 1 & u_2 u_5 + 2
   \end{array} \right)

The result matrix for this case has nine variables,
one for each of its elements.

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

{xrst_end atomic_four_mat_mul_identical_zero.cpp}
