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) where mantissa is a floating point value between -1 and 1, and exponent is an integer such that x == mantissa * 2 ** exponent.

Return type:

tuple[Array, Array]

See also

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)