AD Absolute Value Functions: abs, fabs
Keywords: ad absolute value functions: abs fabs syntax x y atomic complex types derivative example

| Prev | Next |  |  |  |  |  |  |

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., abs ( 1 ) ( x ) = sign ( x ) = { + 1 if x > 0 0 if x = 0 -1 if x < 0 The result for `x == 0` used to be a directional derivative.
Example
The file abs.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.

Input File: cppad/local/abs.hpp