numpoly.poly_divmod

numpoly.poly_divmod(dividend: numpoly.typing.PolyLike, divisor: numpoly.typing.PolyLike, out: Tuple[Optional[numpoly.baseclass.ndpoly], Optional[numpoly.baseclass.ndpoly]] = (None, None), where: Union[numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]] = True, **kwargs: Any)Tuple[numpoly.baseclass.ndpoly, numpoly.baseclass.ndpoly][source]

Return element-wise quotient and remainder simultaneously.

numpoly.divmod(x, y) is equivalent to (x / y, x % y), but faster because it avoids redundant work. It is used to implement the Python built-in function divmod on Numpoly arrays.

Note:

Unlike numbers, this returns the polynomial division and polynomial remainder. This means that this function is _not_ backwards compatible with numpy.divmod for constants. For example: numpy.divmod(11, 2) == (5, 1) while numpoly.divmod(11, 2) == (5.5, 0).

Args:
dividend:

The array being divided.

divisor:

Array that that will divide the dividend.

out:

A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

where:

This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

kwargs:

Keyword args passed to numpy.ufunc.

Return:

Element-wise quotient and remainder resulting from floor division. This is a scalar if both x1 and x2 are scalars.

Example:
>>> q0, q1 = numpoly.variable(2)
>>> denominator = [q0*q1**2+2*q0**3*q1**2, -2+q0*q1**2]
>>> numerator = -2+q0*q1**2
>>> floor, remainder = numpoly.poly_divmod(
...     denominator, numerator)
>>> floor
polynomial([2.0*q0**2+1.0, 1.0])
>>> remainder
polynomial([4.0*q0**2+2.0, 0.0])
>>> floor*numerator+remainder
polynomial([2.0*q0**3*q1**2+q0*q1**2, q0*q1**2-2.0])