jax.numpy.sign

Contents

jax.numpy.sign#

jax.numpy.sign(x, /)#

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 sign(x.real) + 0j if x.real != 0 else sign(x.imag) + 0j.

complex(nan, 0) is returned for complex nan inputs.

Parameters:

x (array_like) – Input values.

Returns:

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

Return type:

ndarray