sign#
- class brainunit.math.sign(x, **kwargs)#
Return the sign of each element in the input array.
Units are stripped before the sign is computed. Returns -1, 0, or +1.
- Parameters:
x (
Array|ndarray|bool|number|bool|int|float|complex| saiunit.Quantity) – Input values.- Returns:
y – The sign of
x. Contains -1 for negative, 0 for zero, and +1 for positive elements.- Return type:
Array
Examples
>>> import saiunit as u >>> import jax.numpy as jnp >>> u.math.sign(jnp.array([-5.0, 0.0, 3.0])) Array([-1., 0., 1.], dtype=float32) >>> q = jnp.array([-2.0, 0.0, 4.0]) * u.second >>> u.math.sign(q) Array([-1., 0., 1.], dtype=float32)