本文整理汇总了Python中sympy.polys.polyclasses.DMP.cofactors方法的典型用法代码示例。如果您正苦于以下问题:Python DMP.cofactors方法的具体用法?Python DMP.cofactors怎么用?Python DMP.cofactors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.polys.polyclasses.DMP
的用法示例。
在下文中一共展示了DMP.cofactors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_DMP_functionality
# 需要导入模块: from sympy.polys.polyclasses import DMP [as 别名]
# 或者: from sympy.polys.polyclasses.DMP import cofactors [as 别名]
def test_DMP_functionality():
f = DMP([[1],[2,0],[1,0,0]], ZZ)
g = DMP([[1],[1,0]], ZZ)
h = DMP([[1]], ZZ)
assert f.degree() == 2
assert f.degree_list() == (2, 2)
assert f.total_degree() == 4
assert f.LC() == ZZ(1)
assert f.TC() == ZZ(0)
assert f.nth(1, 1) == ZZ(2)
raises(TypeError, "f.nth(0, 'x')")
assert f.max_norm() == 2
assert f.l1_norm() == 4
u = DMP([[2],[2,0]], ZZ)
assert f.diff(m=1, j=0) == u
assert f.diff(m=1, j=1) == u
raises(TypeError, "f.diff(m='x', j=0)")
u = DMP([1,2,1], ZZ)
v = DMP([1,2,1], ZZ)
assert f.eval(a=1, j=0) == u
assert f.eval(a=1, j=1) == v
assert f.eval(1).eval(1) == ZZ(4)
assert f.cofactors(g) == (g, g, h)
assert f.gcd(g) == g
assert f.lcm(g) == f
u = DMP([[QQ(45),QQ(30),QQ(5)]], QQ)
v = DMP([[QQ(1),QQ(2,3),QQ(1,9)]], QQ)
assert u.monic() == v
assert (4*f).content() == ZZ(4)
assert (4*f).primitive() == (ZZ(4), f)
f = DMP([[1],[2],[3],[4],[5],[6]], ZZ)
assert f.trunc(3) == DMP([[1],[-1],[],[1],[-1],[]], ZZ)
f = DMP(f_4, ZZ)
assert f.sqf_part() == -f
assert f.sqf_list() == (ZZ(-1), [(-f, 1)])
f = DMP([[-1],[],[],[5]], ZZ)
g = DMP([[3,1],[],[]], ZZ)
h = DMP([[45,30,5]], ZZ)
r = DMP([675,675,225,25], ZZ)
assert f.subresultants(g) == [f, g, h]
assert f.resultant(g) == r
f = DMP([1,3,9,-13], ZZ)
assert f.discriminant() == -11664
f = DMP([QQ(2),QQ(0)], QQ)
g = DMP([QQ(1),QQ(0),QQ(-16)], QQ)
s = DMP([QQ(1,32),QQ(0)], QQ)
t = DMP([QQ(-1,16)], QQ)
h = DMP([QQ(1)], QQ)
assert f.half_gcdex(g) == (s, h)
assert f.gcdex(g) == (s, t, h)
assert f.invert(g) == s
f = DMP([[1],[2],[3]], QQ)
raises(ValueError, "f.half_gcdex(f)")
raises(ValueError, "f.gcdex(f)")
raises(ValueError, "f.invert(f)")
f = DMP([1,0,20,0,150,0,500,0,625,-2,0,-10,9], ZZ)
g = DMP([1,0,0,-2,9], ZZ)
h = DMP([1,0,5,0], ZZ)
assert g.compose(h) == f
assert f.decompose() == [g, h]
f = DMP([[1],[2],[3]], QQ)
raises(ValueError, "f.decompose()")
raises(ValueError, "f.sturm()")