Prev Next

@(@\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }@)@This is cppad-20221105 documentation. Here is a link to its current documentation .
AD Absolute Value Functions: abs, fabs

Syntax
y = abs(x)
y = fabs(x)

x, y
See the possible types for a unary standard math function.

Atomic
In the case where x is an AD type, this is an atomic operation .

Complex Types
The functions abs and fabs are not defined for the base types std::complex<float> or std::complex<double> because the complex abs function is not complex differentiable (see complex types faq ).

Derivative
CppAD defines the derivative of the abs function is the sign function; i.e., @[@ {\rm abs}^{(1)} ( 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. @]@ The result for x == 0 used to be a directional derivative.

Example
The file fabs.cpp contains an example and test of this function.
Input File: include/cppad/core/abs.hpp