本文整理汇总了Python中sympy.polys.polyclasses.DMP.add方法的典型用法代码示例。如果您正苦于以下问题:Python DMP.add方法的具体用法?Python DMP.add怎么用?Python DMP.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.polys.polyclasses.DMP
的用法示例。
在下文中一共展示了DMP.add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_DMP_arithmetics
# 需要导入模块: from sympy.polys.polyclasses import DMP [as 别名]
# 或者: from sympy.polys.polyclasses.DMP import add [as 别名]
def test_DMP_arithmetics():
f = DMP([[2],[2,0]], ZZ)
assert f.mul_ground(2) == DMP([[4],[4,0]], ZZ)
assert f.exquo_ground(2) == DMP([[1],[1,0]], ZZ)
raises(ExactQuotientFailed, 'f.quo_ground(3)')
f = DMP([[-5]], ZZ)
g = DMP([[5]], ZZ)
assert f.abs() == g
assert abs(f) == g
assert g.neg() == f
assert -g == f
h = DMP([[]], ZZ)
assert f.add(g) == h
assert f + g == h
assert g + f == h
assert f + 5 == h
assert 5 + f == h
h = DMP([[-10]], ZZ)
assert f.sub(g) == h
assert f - g == h
assert g - f == -h
assert f - 5 == h
assert 5 - f == -h
h = DMP([[-25]], ZZ)
assert f.mul(g) == h
assert f * g == h
assert g * f == h
assert f * 5 == h
assert 5 * f == h
h = DMP([[25]], ZZ)
assert f.sqr() == h
assert f.pow(2) == h
assert f**2 == h
raises(TypeError, "f.pow('x')")
f = DMP([[1],[],[1,0,0]], ZZ)
g = DMP([[2],[-2,0]], ZZ)
q = DMP([[2],[2,0]], ZZ)
r = DMP([[8,0,0]], ZZ)
assert f.pdiv(g) == (q, r)
assert f.pexquo(g) == q
assert f.prem(g) == r
raises(ExactQuotientFailed, 'f.pquo(g)')
f = DMP([[1],[],[1,0,0]], ZZ)
g = DMP([[1],[-1,0]], ZZ)
q = DMP([[1],[1,0]], ZZ)
r = DMP([[2,0,0]], ZZ)
assert f.div(g) == (q, r)
assert f.exquo(g) == q
assert f.rem(g) == r
assert divmod(f, g) == (q, r)
assert f // g == q
assert f % g == r
raises(ExactQuotientFailed, 'f.quo(g)')