jax.numpy.floor_divide#

jax.numpy.floor_divide(x1, x2, /)[source]#

Calculates the floor division of x1 by x2 element-wise

JAX implementation of numpy.floor_divide.

Parameters:
  • x1 (ArrayLike) – Input array, the dividend

  • x2 (ArrayLike) – Input array, the divisor

Returns:

An array-like object containing each of the quotients rounded down to the nearest integer towards negative infinity. This is equivalent to x1 // x2 in Python.

Return type:

Array

Note

x1 // x2 is equivalent to jnp.floor_divide(x1, x2) for arrays x1 and x2

See also

jax.numpy.divide() and jax.numpy.true_divide() for floating point division.

Examples

>>> x1 = jnp.array([10, 20, 30])
>>> x2 = jnp.array([3, 4, 7])
>>> jnp.floor_divide(x1, x2)
Array([3, 5, 4], dtype=int32)
>>> x1 = jnp.array([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5])
>>> x2 = 3
>>> jnp.floor_divide(x1, x2)
Array([-2, -2, -1, -1, -1,  0,  0,  0,  1,  1,  1], dtype=int32)
>>> x1 = jnp.array([6, 6, 6], dtype=jnp.int32)
>>> x2 = jnp.array([2.0, 2.5, 3.0], dtype=jnp.float32)
>>> jnp.floor_divide(x1, x2)
Array([3., 2., 2.], dtype=float32)