jax.numpy.trunc#
- jax.numpy.trunc(x)[source]#
Round input to the nearest integer towards zero.
JAX implementation of
numpy.trunc()
.- Parameters:
x (ArrayLike) – input array or scalar.
- Returns:
An array with same shape and dtype as
x
containing the rounded values.- Return type:
See also
jax.numpy.fix()
: Rounds the input to the nearest integer towards zero.jax.numpy.ceil()
: Rounds the input up to the nearest integer.jax.numpy.floor()
: Rounds the input down to the nearest integer.
Examples
>>> key = jax.random.key(42) >>> x = jax.random.uniform(key, (3, 3), minval=-10, maxval=10) >>> with jnp.printoptions(precision=2, suppress=True): ... print(x) [[-0.23 3.6 2.33] [ 1.22 -0.99 1.72] [-8.5 5.5 3.98]] >>> jnp.trunc(x) Array([[-0., 3., 2.], [ 1., -0., 1.], [-8., 5., 3.]], dtype=float32)