lines 7-38 of file: example/general/cond_exp.cpp

{xrst_begin cond_exp.cpp}

Conditional Expressions: Example and Test
#########################################

See Also
********
:ref:`optimize_conditional_skip.cpp-name`

Description
***********
Use ``CondExp`` to compute

.. math::

   f(x) = \sum_{j=0}^{m-1} x_j \log( x_j )

and its derivative at various argument values
( where :math:`x_j \geq 0` )
with out having to re-tape; i.e.,
using only one :ref:`ADFun-name` object.
Note that :math:`x_j \log ( x_j ) \rightarrow 0`
as :math:`x_j \downarrow 0` and
we need to handle the case :math:`x_j = 0`
in a special way to avoid returning zero times minus infinity.

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

{xrst_end cond_exp.cpp}
