lines 7-54 of file: example/sparse/dependency.cpp

{xrst_begin dependency.cpp}
{xrst_spell
   rl
}

Computing Dependency: Example and Test
######################################

Discussion
**********
The partial of an dependent variable with respect to an independent variable
might always be zero even though the dependent variable depends on the
value of the dependent variable. Consider the following case

.. math::

   f(x) = {\rm sign} (x) =
   \left\{ \begin{array}{rl}
      +1 & {\rm if} \; x > 0 \\
      0  & {\rm if} \; x = 0 \\
      -1 & {\rm if} \; x < 0
   \end{array} \right.

In this case the value of :math:`f(x)` depends on the value of :math:`x`
but CppAD always returns zero for the derivative of the :ref:`sign-name` function.

Dependency Pattern
******************
If the *i*-th dependent variables depends on the
value of the *j*-th independent variable,
the corresponding entry in the dependency pattern is non-zero (true).
Otherwise it is zero (false).
CppAD uses :ref:`sparsity patterns<glossary@Sparsity Pattern>`
to represent dependency patterns.

Computation
***********
The *dependency* argument to
:ref:`for_jac_sparsity<for_jac_sparsity@dependency>` and
:ref:`RevSparseJac<RevSparseJac@dependency>` is a flag that signals
that the dependency pattern (instead of the sparsity pattern) is computed.

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

{xrst_end dependency.cpp}
