sign

View page source

The Sign: sign

Syntax

y = sign ( x )

Description

Evaluates the sign function which is defined by

\[\begin{split}{\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.\end{split}\]

x, y

See the Possible Types for a unary standard math function.

Atomic

This is an atomic operation .

Derivative

CppAD computes the derivative of the sign function as zero for all argument values x . The correct mathematical derivative is different and is given by

\[{\rm sign}^{(1)} (x) = 2 \delta (x)\]

where \(\delta (x)\) is the Dirac Delta function.

Example

The file sign.cpp contains an example and test of this function.