示例#1
0
def test_poly_divide():
    const = numpoly.polynomial([1, 2])
    poly1 = numpoly.polynomial(X)
    poly2 = numpoly.polynomial([1, X])
    poly3 = numpoly.polynomial([[0, Y], [X, 1]])
    assert numpy.all(numpoly.poly_divide(poly1, const) == [X, 0.5 * X])
    assert numpy.all(numpoly.poly_divide(const, poly1) == [0, 0])
    assert numpy.all(poly1.__truediv__(poly2) == [X, 1])
    assert numpy.all(poly2.__rtruediv__(poly3) == [[0, 0], [X, 0]])
    assert numpy.all(poly2.__div__(poly1) == [0, 1])
    assert numpy.all(poly3.__rdiv__(poly2) == [[0, 0], [0, X]])
示例#2
0
 def __rdiv__(self, value: "PolyLike") -> "ndpoly":
     """Return value/self."""
     return numpoly.poly_divide(value, self)
示例#3
0
 def __div__(self, value: "PolyLike") -> "ndpoly":
     """Return self/value."""
     return numpoly.poly_divide(self, value)