jax.numpy.sign

Contents

jax.numpy.sign#

jax.numpy.sign(x, /)[source]#

Returns an element-wise indication of the sign of a number.

LAX-backend implementation of numpy.sign().

Original docstring below.

The sign function returns -1 if x < 0, 0 if x==0, 1 if x > 0. nan is returned for nan inputs.

For complex inputs, the sign function returns x / abs(x), the generalization of the above (and 0 if x==0).

Changed in version 2.0.0: Definition of complex sign changed to follow the Array API standard.

Parameters:

x (array_like) – Input values.

Returns:

y – The sign of x. This is a scalar if x is a scalar.

Return type:

ndarray