jax.numpy.ldexp
Contents
jax.numpy.ldexp#
- jax.numpy.ldexp(x1,x2,/)[source]#
Compute x1 * 2 ** x2
JAX implementation of
numpy.ldexp().Note that XLA does not provide an
ldexpoperation, so thisis implemneted in JAX via a standard multiplication andexponentiation.- Parameters:
x1 (ArrayLike) – real-valued input array.
x2 (ArrayLike) – integer input array. Must be broadcast-compatible with
x1.
- Returns:
x1*2**x2computed element-wise.- Return type:
See also
jax.numpy.frexp(): decompose values into mantissa and exponent.
Examples
>>>x1=jnp.arange(5.0)>>>x2=10>>>jnp.ldexp(x1,x2)Array([ 0., 1024., 2048., 3072., 4096.], dtype=float32)
ldexpcan be used to reconstruct the input tofrexp:>>>x=jnp.array([2.,3.,5.,11.])>>>m,e=jnp.frexp(x)>>>mArray([0.5 , 0.75 , 0.625 , 0.6875], dtype=float32)>>>eArray([2, 2, 3, 4], dtype=int32)>>>jnp.ldexp(m,e)Array([ 2., 3., 5., 11.], dtype=float32)
Contents
