本文整理汇总了Python中sympy.polys.densearith.dmp_mul_term函数的典型用法代码示例。如果您正苦于以下问题:Python dmp_mul_term函数的具体用法?Python dmp_mul_term怎么用?Python dmp_mul_term使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dmp_mul_term函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dmp_mul_term
def test_dmp_mul_term():
assert dmp_mul_term([ZZ(1),ZZ(2),ZZ(3)], ZZ(2), 1, 0, ZZ) == \
dup_mul_term([ZZ(1),ZZ(2),ZZ(3)], ZZ(2), 1, ZZ)
assert dmp_mul_term([[]], [ZZ(2)], 3, 1, ZZ) == [[]]
assert dmp_mul_term([[ZZ(1)]], [], 3, 1, ZZ) == [[]]
assert dmp_mul_term([[ZZ(1),ZZ(2)], [ZZ(3)]], [ZZ(2)], 2, 1, ZZ) == \
[[ZZ(2),ZZ(4)], [ZZ(6)], [], []]
assert dmp_mul_term([[]], [QQ(2,3)], 3, 1, QQ) == [[]]
assert dmp_mul_term([[QQ(1,2)]], [], 3, 1, QQ) == [[]]
assert dmp_mul_term([[QQ(1,5),QQ(2,5)], [QQ(3,5)]], [QQ(2,3)], 2, 1, QQ) == \
[[QQ(2,15),QQ(4,15)], [QQ(6,15)], [], []]
示例2: dmp_rr_prs_gcd
def dmp_rr_prs_gcd(f, g, u, K):
"""
Computes polynomial GCD using subresultants over a ring.
Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``, ``cff = quo(f, h)``,
and ``cfg = quo(g, h)``.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x,y, = ring("x,y", ZZ)
>>> f = x**2 + 2*x*y + y**2
>>> g = x**2 + x*y
>>> R.dmp_rr_prs_gcd(f, g)
(x + y, x + y, x)
"""
if not u:
return dup_rr_prs_gcd(f, g, K)
result = _dmp_rr_trivial_gcd(f, g, u, K)
if result is not None:
return result
fc, F = dmp_primitive(f, u, K)
gc, G = dmp_primitive(g, u, K)
h = dmp_subresultants(F, G, u, K)[-1]
c, _, _ = dmp_rr_prs_gcd(fc, gc, u - 1, K)
if K.is_negative(dmp_ground_LC(h, u, K)):
h = dmp_neg(h, u, K)
_, h = dmp_primitive(h, u, K)
h = dmp_mul_term(h, c, 0, u, K)
cff = dmp_quo(f, h, u, K)
cfg = dmp_quo(g, h, u, K)
return h, cff, cfg
示例3: dmp_rr_prs_gcd
def dmp_rr_prs_gcd(f, g, u, K):
"""
Computes polynomial GCD using subresultants over a ring.
Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``, ``cff = quo(f, h)``,
and ``cfg = quo(g, h)``.
Examples
========
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.euclidtools import dmp_rr_prs_gcd
>>> f = ZZ.map([[1], [2, 0], [1, 0, 0]])
>>> g = ZZ.map([[1], [1, 0], []])
>>> dmp_rr_prs_gcd(f, g, 1, ZZ)
([[1], [1, 0]], [[1], [1, 0]], [[1], []])
"""
if not u:
return dup_rr_prs_gcd(f, g, K)
result = _dmp_rr_trivial_gcd(f, g, u, K)
if result is not None:
return result
fc, F = dmp_primitive(f, u, K)
gc, G = dmp_primitive(g, u, K)
h = dmp_subresultants(F, G, u, K)[-1]
c, _, _ = dmp_rr_prs_gcd(fc, gc, u-1, K)
if K.is_negative(dmp_ground_LC(h, u, K)):
h = dmp_neg(h, u, K)
_, h = dmp_primitive(h, u, K)
h = dmp_mul_term(h, c, 0, u, K)
cff = dmp_quo(f, h, u, K)
cfg = dmp_quo(g, h, u, K)
return h, cff, cfg
示例4: dmp_ff_prs_gcd
def dmp_ff_prs_gcd(f, g, u, K):
"""
Computes polynomial GCD using subresultants over a field.
Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``, ``cff = quo(f, h)``,
and ``cfg = quo(g, h)``.
Examples
========
>>> from sympy.polys import ring, QQ
>>> R, x,y, = ring("x,y", QQ)
>>> f = QQ(1,2)*x**2 + x*y + QQ(1,2)*y**2
>>> g = x**2 + x*y
>>> R.dmp_ff_prs_gcd(f, g)
(x + y, 1/2*x + 1/2*y, x)
"""
if not u:
return dup_ff_prs_gcd(f, g, K)
result = _dmp_ff_trivial_gcd(f, g, u, K)
if result is not None:
return result
fc, F = dmp_primitive(f, u, K)
gc, G = dmp_primitive(g, u, K)
h = dmp_subresultants(F, G, u, K)[-1]
c, _, _ = dmp_ff_prs_gcd(fc, gc, u - 1, K)
_, h = dmp_primitive(h, u, K)
h = dmp_mul_term(h, c, 0, u, K)
h = dmp_ground_monic(h, u, K)
cff = dmp_quo(f, h, u, K)
cfg = dmp_quo(g, h, u, K)
return h, cff, cfg
示例5: dmp_ff_prs_gcd
def dmp_ff_prs_gcd(f, g, u, K):
"""
Computes polynomial GCD using subresultants over a field.
Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``, ``cff = quo(f, h)``,
and ``cfg = quo(g, h)``.
Examples
========
>>> from sympy.polys.domains import QQ
>>> from sympy.polys.euclidtools import dmp_ff_prs_gcd
>>> f = [[QQ(1,2)], [QQ(1), QQ(0)], [QQ(1,2), QQ(0), QQ(0)]]
>>> g = [[QQ(1)], [QQ(1), QQ(0)], []]
>>> dmp_ff_prs_gcd(f, g, 1, QQ)
([[1/1], [1/1, 0/1]], [[1/2], [1/2, 0/1]], [[1/1], []])
"""
if not u:
return dup_ff_prs_gcd(f, g, K)
result = _dmp_ff_trivial_gcd(f, g, u, K)
if result is not None:
return result
fc, F = dmp_primitive(f, u, K)
gc, G = dmp_primitive(g, u, K)
h = dmp_subresultants(F, G, u, K)[-1]
c, _, _ = dmp_ff_prs_gcd(fc, gc, u-1, K)
_, h = dmp_primitive(h, u, K)
h = dmp_mul_term(h, c, 0, u, K)
h = dmp_ground_monic(h, u, K)
cff = dmp_quo(f, h, u, K)
cfg = dmp_quo(g, h, u, K)
return h, cff, cfg
示例6: dmp_inner_subresultants
def dmp_inner_subresultants(f, g, u, K):
"""
Subresultant PRS algorithm in ``K[X]``.
**Examples**
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.euclidtools import dmp_inner_subresultants
>>> f = ZZ.map([[3, 0], [], [-1, 0, 0, -4]])
>>> g = ZZ.map([[1], [1, 0, 0, 0], [-9]])
>>> a = [[3, 0, 0, 0, 0], [1, 0, -27, 4]]
>>> b = [[-3, 0, 0, -12, 1, 0, -54, 8, 729, -216, 16]]
>>> R = ZZ.map([f, g, a, b])
>>> B = ZZ.map([[-1], [1], [9, 0, 0, 0, 0, 0, 0, 0, 0]])
>>> D = ZZ.map([0, 1, 1])
>>> dmp_inner_subresultants(f, g, 1, ZZ) == (R, B, D)
True
"""
if not u:
return dup_inner_subresultants(f, g, K)
n = dmp_degree(f, u)
m = dmp_degree(g, u)
if n < m:
f, g = g, f
n, m = m, n
R = [f, g]
d = n - m
v = u - 1
b = dmp_pow(dmp_ground(-K.one, v), d+1, v, K)
c = dmp_ground(-K.one, v)
B, D = [b], [d]
if dmp_zero_p(f, u) or dmp_zero_p(g, u):
return R, B, D
h = dmp_prem(f, g, u, K)
h = dmp_mul_term(h, b, 0, u, K)
while not dmp_zero_p(h, u):
k = dmp_degree(h, u)
R.append(h)
lc = dmp_LC(g, K)
p = dmp_pow(dmp_neg(lc, v, K), d, v, K)
if not d:
q = c
else:
q = dmp_pow(c, d-1, v, K)
c = dmp_exquo(p, q, v, K)
b = dmp_mul(dmp_neg(lc, v, K),
dmp_pow(c, m-k, v, K), v, K)
f, g, m, d = g, h, k, m-k
B.append(b)
D.append(d)
h = dmp_prem(f, g, u, K)
h = [ dmp_exquo(ch, b, v, K) for ch in h ]
return R, B, D
示例7: dmp_inner_subresultants
def dmp_inner_subresultants(f, g, u, K):
"""
Subresultant PRS algorithm in `K[X]`.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)
>>> f = 3*x**2*y - y**3 - 4
>>> g = x**2 + x*y**3 - 9
>>> a = 3*x*y**4 + y**3 - 27*y + 4
>>> b = -3*y**10 - 12*y**7 + y**6 - 54*y**4 + 8*y**3 + 729*y**2 - 216*y + 16
>>> prs = [f, g, a, b]
>>> sres = [[1], [1], [3, 0, 0, 0, 0], [-3, 0, 0, -12, 1, 0, -54, 8, 729, -216, 16]]
>>> R.dmp_inner_subresultants(f, g) == (prs, sres)
True
"""
if not u:
return dup_inner_subresultants(f, g, K)
n = dmp_degree(f, u)
m = dmp_degree(g, u)
if n < m:
f, g = g, f
n, m = m, n
if dmp_zero_p(f, u):
return [], []
v = u - 1
if dmp_zero_p(g, u):
return [f], [dmp_ground(K.one, v)]
R = [f, g]
d = n - m
b = dmp_pow(dmp_ground(-K.one, v), d + 1, v, K)
h = dmp_prem(f, g, u, K)
h = dmp_mul_term(h, b, 0, u, K)
lc = dmp_LC(g, K)
c = dmp_pow(lc, d, v, K)
S = [dmp_ground(K.one, v), c]
c = dmp_neg(c, v, K)
while not dmp_zero_p(h, u):
k = dmp_degree(h, u)
R.append(h)
f, g, m, d = g, h, k, m - k
b = dmp_mul(dmp_neg(lc, v, K),
dmp_pow(c, d, v, K), v, K)
h = dmp_prem(f, g, u, K)
h = [ dmp_quo(ch, b, v, K) for ch in h ]
lc = dmp_LC(g, K)
if d > 1:
p = dmp_pow(dmp_neg(lc, v, K), d, v, K)
q = dmp_pow(c, d - 1, v, K)
c = dmp_quo(p, q, v, K)
else:
c = dmp_neg(lc, v, K)
S.append(dmp_neg(c, v, K))
return R, S
示例8: dmp_inner_subresultants
def dmp_inner_subresultants(f, g, u, K):
"""
Subresultant PRS algorithm in `K[X]`.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)
>>> f = 3*x**2*y - y**3 - 4
>>> g = x**2 + x*y**3 - 9
>>> a = 3*x*y**4 + y**3 - 27*y + 4
>>> b = -3*y**10 - 12*y**7 + y**6 - 54*y**4 + 8*y**3 + 729*y**2 - 216*y + 16
>>> prs = [f, g, a, b]
>>> beta = [[-1], [1], [9, 0, 0, 0, 0, 0, 0, 0, 0]]
>>> delta = [0, 1, 1]
>>> R.dmp_inner_subresultants(f, g) == (prs, beta, delta)
True
"""
if not u:
return dup_inner_subresultants(f, g, K)
n = dmp_degree(f, u)
m = dmp_degree(g, u)
if n < m:
f, g = g, f
n, m = m, n
R = [f, g]
d = n - m
v = u - 1
b = dmp_pow(dmp_ground(-K.one, v), d + 1, v, K)
c = dmp_ground(-K.one, v)
B, D = [b], [d]
if dmp_zero_p(f, u) or dmp_zero_p(g, u):
return R, B, D
h = dmp_prem(f, g, u, K)
h = dmp_mul_term(h, b, 0, u, K)
while not dmp_zero_p(h, u):
k = dmp_degree(h, u)
R.append(h)
lc = dmp_LC(g, K)
p = dmp_pow(dmp_neg(lc, v, K), d, v, K)
if not d:
q = c
else:
q = dmp_pow(c, d - 1, v, K)
c = dmp_quo(p, q, v, K)
b = dmp_mul(dmp_neg(lc, v, K),
dmp_pow(c, m - k, v, K), v, K)
f, g, m, d = g, h, k, m - k
B.append(b)
D.append(d)
h = dmp_prem(f, g, u, K)
h = [ dmp_quo(ch, b, v, K) for ch in h ]
return R, B, D