jax.numpy.frexp#
- jax.numpy.frexp(x, /)[source]#
Split floating point values into mantissa and twos exponent.
JAX implementation of
numpy.frexp().- Parameters:
x (ArrayLike) – real-valued array
- Returns:
A tuple
(mantissa, exponent)wheremantissais a floating point value between -1 and 1, andexponentis an integer such thatx == mantissa * 2 ** exponent.- Return type:
See also
jax.numpy.ldexp(): compute the inverse offrexp.
Examples
Split values into mantissa and exponent:
>>> x = jnp.array([1., 2., 3., 4., 5.]) >>> m, e = jnp.frexp(x) >>> m Array([0.5 , 0.5 , 0.75 , 0.5 , 0.625], dtype=float32) >>> e Array([1, 2, 2, 3, 3], dtype=int32)
Reconstruct the original array:
>>> m * 2 ** e Array([1., 2., 3., 4., 5.], dtype=float32)