dpnp.remainder

dpnp.remainder(x1, x2, out=None, where=True, order='K', dtype=None, subok=True, **kwargs)

Calculates the remainder of division for each element x1_i of the input array x1 with the respective element x2_i of the input array x2. This function is equivalent to the Python modulus operator.

For full documentation refer to numpy.remainder.

Parameters:
  • x1 ({dpnp.ndarray, usm_ndarray}) – First input array, expected to have a real-valued data type.

  • x2 ({dpnp.ndarray, usm_ndarray}) – Second input array, also expected to have a real-valued data type.

  • out ({None, dpnp.ndarray}, optional) – Output array to populate. Array must have the correct shape and the expected data type.

  • order ({"C", "F", "A", "K"}, optional) – Memory layout of the newly output array, if parameter out is None. Default: “K”.

Returns:

  • out (dpnp.ndarray) – an array containing the element-wise remainders. The data type of the returned array is determined by the Type Promotion Rules.

  • Limitations

  • Parameters where and subok are supported with their default values.

  • Keyword argument kwargs is currently unsupported.

  • Otherwise NotImplementedError exception will be raised.

See also

dpnp.fmod

Calculate the element-wise remainder of division.

dpnp.divide

Standard division.

dpnp.floor

Round a number to the nearest integer toward minus infinity.

dpnp.floor_divide

Compute the largest integer smaller or equal to the division of the inputs.

dpnp.mod

Calculate the element-wise remainder of division.

Examples

>>> import dpnp as np
>>> np.remainder(np.array([4, 7]), np.array([2, 3]))
array([0, 1])
>>> np.remainder(np.arange(7), 5)
array([0, 1, 2, 3, 4, 0, 1])

The % operator can be used as a shorthand for remainder on dpnp.ndarray.

>>> x1 = np.arange(7)
>>> x1 % 5
array([0, 1, 2, 3, 4, 0, 1])