mindspore.numpy.divmod

mindspore.numpy.divmod(x1, x2, dtype=None)

Returns element-wise quotient and remainder simultaneously.

参数
  • x1 (Union[Tensor]) – Dividend tensor.

  • x2 (Union[Tensor, int, float, bool]) – Divisor. If x1.shape != x2.shape, they must be broadcastable to a common shape.

  • dtype (mindspore.dtype, optional) – Default: None . Overrides the dtype of the output Tensor.

返回

Element-wise quotient and remainder from floor division, in format of (quotient, remainder)

异常

TypeError – If x1 and x2 are not Tensor or scalar.

Supported Platforms:

Ascend GPU CPU

样例

>>> import mindspore.numpy as np
>>> a = np.array([1, 2, 3, 4, 5])
>>> print(np.divmod(a, 1.5))
(Tensor(shape=[5], dtype=Float32,
 value= [ 0.00000000e+00,  1.00000000e+00,  2.00000000e+00,  2.00000000e+00,  3.00000000e+00]),
 Tensor(shape=[5], dtype=Float32,
 value= [ 1.00000000e+00,  5.00000000e-01,  0.00000000e+00,  1.00000000e+00,  5.00000000e-01]))