divmod#
- class brainunit.math.divmod(x, y, **kwargs)#
Return element-wise quotient and remainder simultaneously.
Equivalent to
(x // y, x % y), but faster because it avoids redundant work. When x and y share a dimension, the operands are aligned tox.unitfirst (flooris not scale-linear): the quotient is dimensionless and the remainder carriesx.unit. For mixed dimensions, both operands are folded to magnitude-1 (base) units so the result does not depend on the unit representation; the quotient then carries the basex.unit / y.unitand the remainder the base unit ofx.- Parameters:
x (saiunit.Quantity |
Array|ndarray|number|bool) – Dividend array.y (saiunit.Quantity |
Array|ndarray|number|bool) – Divisor array. Ifx.shape != y.shape, they must be broadcastable to a common shape.
- Return type:
Tuple[saiunit.Quantity |Array|ndarray|number|bool, saiunit.Quantity |Array|ndarray|number|bool]- Returns:
out1 (ndarray or Quantity) – Element-wise quotient resulting from floor division.
out2 (ndarray or Quantity) – Element-wise remainder from floor division, with the dimension of x.
Examples
>>> import saiunit as u >>> a = u.math.array([7.0, 9.0]) * u.meter >>> b = u.math.array([2.0, 4.0]) * u.second >>> quotient, remainder = u.math.divmod(a, b)