lines 6-74 of file: example/atomic_four/mat_mul/rev_depend.cpp {xrst_begin atomic_four_mat_mul_rev_depend.cpp} {xrst_spell multiplications } Atomic Matrix Multiply Reverse Dependency: Example and Test ########################################################### Purpose ******* This example uses the atomic matrix multiply ``rev_depend`` function to reduce the number of variables in the recording of :math:`g(u)`. f(u) **** .. math:: f(u) = \left( \begin{array}{cc} 2 u_0 & 2 u_1 \\ 2 u_2 & 2 u_3 \\ \end{array} \right) \left( \begin{array}{cc} 2 u_4 & 2 u_5 \\ 2 u_6 & 2 u_7 \end{array} \right) = \left( \begin{array}{cc} 4( u_0 u_4 + u_1 u_6 ) & 4( u_0 u_5 + u_1 u_7 ) \\ 4( u_2 u_4 + u_3 u_6 ) & 4( u_2 u_5 + u_3 u_7 ) \\ \end{array} \right) .. math:: f_{0,0} (u) = 4 ( u_0 u_4 + u_1 u_6 ) Forward Analysis **************** Forward dependency analysis determines that there is a new variable for each of the 8 multiplications by 2.0. It also determines, using :ref:`for_type` that each of the 4 elements in the matrix product result is a new variable. Reverse Analysis **************** Reverse analysis detect that only 1 of the 4 elements in the matrix product is used. In addition it determines, using :ref:`rev_depend` , that only 4 of the 8 multiplications by 2.0 are used. size_var ******** The difference in :ref:`fun_property@size_var` is the difference between only using forward dependency and using both; i.e., (8 - 4) + (4 - 1) = 7. Source ****** {xrst_literal // BEGIN C++ // END C++ } {xrst_end atomic_four_mat_mul_rev_depend.cpp}