jax.numpy.absolute — JAX documentation (original) (raw)
jax.numpy.absolute#
jax.numpy.absolute(x, /)[source]#
Calculate the absolute value element-wise.
JAX implementation of numpy.absolute.
This is the same function as jax.numpy.abs().
Parameters:
x (ArrayLike) – Input array
Returns:
An array-like object containing the absolute value of each element in x, with the same shape as x. For complex valued input, \(a + ib\), the absolute value is \(\sqrt{a^2+b^2}\).
Return type:
Examples
x1 = jnp.array([5, -2, 0, 12]) jnp.absolute(x1) Array([ 5, 2, 0, 12], dtype=int32)
x2 = jnp.array([[ 8, -3, 1],[ 0, 9, -6]]) jnp.absolute(x2) Array([[8, 3, 1], [0, 9, 6]], dtype=int32)
x3 = jnp.array([8 + 15j, 3 - 4j, -5 + 0j]) jnp.absolute(x3) Array([17., 5., 5.], dtype=float32)