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, scalar}) -- First input array, expected to have a real-valued data type. Both inputs x1 and x2 can not be scalars at the same time.
x2 ({dpnp.ndarray, usm_ndarray, scalar}) -- Second input array, also expected to have a real-valued data type. Both inputs x1 and x2 can not be scalars at the same time.
out ({None, dpnp.ndarray, usm_ndarray}, optional) -- Output array to populate. Array must have the correct shape and the expected data type. Default:
None
.order ({"C", "F", "A", "K"}, optional) -- Memory layout of the newly output array, if parameter out is
None
. Default:"K"
.
- Returns:
out -- An array containing the element-wise remainders. Each remainder has the same sign as respective element x2_i. The data type of the returned array is determined by the Type Promotion Rules.
- Return type:
dpnp.ndarray
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.
Notes
Returns
0
when x2 is0
and both x1 and x2 are (arrays of) integers.dpnp.mod
is an alias ofdpnp.remainder
.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 forremainder
ondpnp.ndarray
.>>> x1 = np.arange(7) >>> x1 % 5 array([0, 1, 2, 3, 4, 0, 1])