jax.numpy.spacing#
- jax.numpy.spacing(x, /)[source]#
Return the spacing between
xand the next adjacent number.JAX implementation of
numpy.spacing().- Parameters:
x (ArrayLike) – real-valued array. Integer or boolean types will be cast to float.
- Returns:
Array of same shape as
xcontaining spacing between each entry ofxand its closest adjacent value.- Return type:
See also
jax.numpy.nextafter(): find the next representable value.
Examples
>>> x = jnp.array([0.0, 0.25, 0.5, 0.75, 1.0], dtype='float32') >>> jnp.spacing(x) Array([1.4012985e-45, 2.9802322e-08, 5.9604645e-08, 5.9604645e-08, 1.1920929e-07], dtype=float32)
For
x = 1, the spacing is equal to theepsvalue given byjax.numpy.finfo:>>> x = jnp.float32(1) >>> jnp.spacing(x) == jnp.finfo(x.dtype).eps Array(True, dtype=bool)