jax.lax.sign#

jax.lax.sign(x)[source]#

Elementwise sign.

This function lowers directly to the stablehlo.sign operation.

Parameters:

x (ArrayLike) – input array

Returns:

Array of same shape and dtype as x, containing the sign of the value, as defined in Notes below.

Return type:

Array

Notes

For floating-point inputs, returns

\[\begin{split} \mathrm{sign}(x) = \begin{cases} -1 & x < 0\\ -0 & x = -0\\ \mathit{NaN} & x = \mathit{NaN}\\ +0 & x = +0\\ 1 & x > 0 \end{cases}\end{split}\]

For signed integer inputs, returns

\[\begin{split}\mathrm{sign}(x) = \begin{cases} -1 & x < 0\\ 0 & x = 0\\ 1 & x > 0 \end{cases}\end{split}\]

For complex inputs, returns the complex phase, i.e. \(\mathrm{sign}(x) = x / |x|\).