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) [[ 2.88 -3.55 -6.13] [ 7.73 4.49 -6.16] [-3.1 -4.95 2.64]] >>> jnp.trunc(x) Array([[ 2., -3., -6.], [ 7., 4., -6.], [-3., -4., 2.]], dtype=float32)