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:
- Return type:
Tuple[Union[saiunit.Quantity,Array,ndarray,number,bool],Union[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)