本文整理汇总了Python中sympy.polys.densearith.dmp_quo函数的典型用法代码示例。如果您正苦于以下问题:Python dmp_quo函数的具体用法?Python dmp_quo怎么用?Python dmp_quo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dmp_quo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _dmp_simplify_gcd
def _dmp_simplify_gcd(f, g, u, K):
"""Try to eliminate `x_0` from GCD computation in `K[X]`. """
df = dmp_degree(f, u)
dg = dmp_degree(g, u)
if df > 0 and dg > 0:
return None
if not (df or dg):
F = dmp_LC(f, K)
G = dmp_LC(g, K)
else:
if not df:
F = dmp_LC(f, K)
G = dmp_content(g, u, K)
else:
F = dmp_content(f, u, K)
G = dmp_LC(g, K)
v = u - 1
h = dmp_gcd(F, G, v, K)
cff = [ dmp_quo(cf, h, v, K) for cf in f ]
cfg = [ dmp_quo(cg, h, v, K) for cg in g ]
return [h], cff, cfg
开发者ID:AdrianPotter,项目名称:sympy,代码行数:26,代码来源:euclidtools.py
示例2: dmp_discriminant
def dmp_discriminant(f, u, K):
"""
Computes discriminant of a polynomial in `K[X]`.
Examples
========
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.euclidtools import dmp_discriminant
>>> f = ZZ.map([[[[1]], [[]]], [[[1], []]], [[[1, 0]]]])
>>> dmp_discriminant(f, 3, ZZ)
[[[-4, 0]], [[1], [], []]]
"""
if not u:
return dup_discriminant(f, K)
d, v = dmp_degree(f, u), u-1
if d <= 0:
return dmp_zero(v)
else:
s = (-1)**((d*(d-1)) // 2)
c = dmp_LC(f, K)
r = dmp_resultant(f, dmp_diff(f, 1, u, K), u, K)
c = dmp_mul_ground(c, K(s), v, K)
return dmp_quo(r, c, v, K)
开发者ID:dyao-vu,项目名称:meta-core,代码行数:31,代码来源:euclidtools.py
示例3: dmp_sqf_part
def dmp_sqf_part(f, u, K):
"""
Returns square-free part of a polynomial in ``K[X]``.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)
>>> R.dmp_sqf_part(x**3 + 2*x**2*y + x*y**2)
x**2 + x*y
"""
if not u:
return dup_sqf_part(f, K)
if K.is_FiniteField:
return dmp_gf_sqf_part(f, u, K)
if dmp_zero_p(f, u):
return f
if K.is_negative(dmp_ground_LC(f, u, K)):
f = dmp_neg(f, u, K)
gcd = dmp_gcd(f, dmp_diff(f, 1, u, K), u, K)
sqf = dmp_quo(f, gcd, u, K)
if K.has_Field:
return dmp_ground_monic(sqf, u, K)
else:
return dmp_ground_primitive(sqf, u, K)[1]
开发者ID:alhirzel,项目名称:sympy,代码行数:33,代码来源:sqfreetools.py
示例4: dmp_discriminant
def dmp_discriminant(f, u, K):
"""
Computes discriminant of a polynomial in `K[X]`.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x,y,z,t = ring("x,y,z,t", ZZ)
>>> R.dmp_discriminant(x**2*y + x*z + t)
-4*y*t + z**2
"""
if not u:
return dup_discriminant(f, K)
d, v = dmp_degree(f, u), u - 1
if d <= 0:
return dmp_zero(v)
else:
s = (-1)**((d*(d - 1)) // 2)
c = dmp_LC(f, K)
r = dmp_resultant(f, dmp_diff(f, 1, u, K), u, K)
c = dmp_mul_ground(c, K(s), v, K)
return dmp_quo(r, c, v, K)
开发者ID:AdrianPotter,项目名称:sympy,代码行数:29,代码来源:euclidtools.py
示例5: dmp_rr_lcm
def dmp_rr_lcm(f, g, u, K):
"""
Computes polynomial LCM over a ring in `K[X]`.
Examples
========
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.euclidtools import dmp_rr_lcm
>>> f = ZZ.map([[1], [2, 0], [1, 0, 0]])
>>> g = ZZ.map([[1], [1, 0], []])
>>> dmp_rr_lcm(f, g, 1, ZZ)
[[1], [2, 0], [1, 0, 0], []]
"""
fc, f = dmp_ground_primitive(f, u, K)
gc, g = dmp_ground_primitive(g, u, K)
c = K.lcm(fc, gc)
h = dmp_quo(dmp_mul(f, g, u, K),
dmp_gcd(f, g, u, K), u, K)
return dmp_mul_ground(h, c, u, K)
开发者ID:dyao-vu,项目名称:meta-core,代码行数:26,代码来源:euclidtools.py
示例6: test_dmp_div
def test_dmp_div():
f, g, q, r = [5,4,3,2,1], [1,2,3], [5,-6,0], [20,1]
assert dmp_div(f, g, 0, ZZ) == (q, r)
assert dmp_quo(f, g, 0, ZZ) == q
assert dmp_rem(f, g, 0, ZZ) == r
raises(ExactQuotientFailed, lambda: dmp_exquo(f, g, 0, ZZ))
f, g, q, r = [[[1]]], [[[2]],[1]], [[[]]], [[[1]]]
assert dmp_div(f, g, 2, ZZ) == (q, r)
assert dmp_quo(f, g, 2, ZZ) == q
assert dmp_rem(f, g, 2, ZZ) == r
raises(ExactQuotientFailed, lambda: dmp_exquo(f, g, 2, ZZ))
开发者ID:BDGLunde,项目名称:sympy,代码行数:16,代码来源:test_densearith.py
示例7: dmp_sqf_part
def dmp_sqf_part(f, u, K):
"""
Returns square-free part of a polynomial in ``K[X]``.
Examples
========
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.sqfreetools import dmp_sqf_part
>>> f = ZZ.map([[1], [2, 0], [1, 0, 0], []])
>>> dmp_sqf_part(f, 1, ZZ)
[[1], [1, 0], []]
"""
if not u:
return dup_sqf_part(f, K)
if not K.has_CharacteristicZero:
return dmp_gf_sqf_part(f, u, K)
if dmp_zero_p(f, u):
return f
if K.is_negative(dmp_ground_LC(f, u, K)):
f = dmp_neg(f, u, K)
gcd = dmp_gcd(f, dmp_diff(f, 1, u, K), u, K)
sqf = dmp_quo(f, gcd, u, K)
if K.has_Field or not K.is_Exact:
return dmp_ground_monic(sqf, u, K)
else:
return dmp_ground_primitive(sqf, u, K)[1]
开发者ID:FireJade,项目名称:sympy,代码行数:35,代码来源:sqfreetools.py
示例8: dmp_rr_lcm
def dmp_rr_lcm(f, g, u, K):
"""
Computes polynomial LCM over a ring in `K[X]`.
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_lcm(f, g)
x**3 + 2*x**2*y + x*y**2
"""
fc, f = dmp_ground_primitive(f, u, K)
gc, g = dmp_ground_primitive(g, u, K)
c = K.lcm(fc, gc)
h = dmp_quo(dmp_mul(f, g, u, K),
dmp_gcd(f, g, u, K), u, K)
return dmp_mul_ground(h, c, u, K)
开发者ID:AdrianPotter,项目名称:sympy,代码行数:26,代码来源:euclidtools.py
示例9: 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
开发者ID:AdrianPotter,项目名称:sympy,代码行数:44,代码来源:euclidtools.py
示例10: 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
开发者ID:dyao-vu,项目名称:meta-core,代码行数:44,代码来源:euclidtools.py
示例11: 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
开发者ID:dyao-vu,项目名称:meta-core,代码行数:42,代码来源:euclidtools.py
示例12: 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
开发者ID:AdrianPotter,项目名称:sympy,代码行数:42,代码来源:euclidtools.py
示例13: dmp_ff_lcm
def dmp_ff_lcm(f, g, u, K):
"""
Computes polynomial LCM over a field in ``K[X]``.
**Examples**
>>> from sympy.polys.domains import QQ
>>> from sympy.polys.euclidtools import dmp_ff_lcm
>>> f = [[QQ(1,4)], [QQ(1), QQ(0)], [QQ(1), QQ(0), QQ(0)]]
>>> g = [[QQ(1,2)], [QQ(1), QQ(0)], []]
>>> dmp_ff_lcm(f, g, 1, QQ)
[[1/1], [4/1, 0/1], [4/1, 0/1, 0/1], []]
"""
h = dmp_quo(dmp_mul(f, g, u, K),
dmp_gcd(f, g, u, K), u, K)
return dmp_ground_monic(h, u, K)
开发者ID:fxkr,项目名称:sympy,代码行数:20,代码来源:euclidtools.py
示例14: dmp_ff_lcm
def dmp_ff_lcm(f, g, u, K):
"""
Computes polynomial LCM over a field in `K[X]`.
Examples
========
>>> from sympy.polys import ring, QQ
>>> R, x,y, = ring("x,y", QQ)
>>> f = QQ(1,4)*x**2 + x*y + y**2
>>> g = QQ(1,2)*x**2 + x*y
>>> R.dmp_ff_lcm(f, g)
x**3 + 4*x**2*y + 4*x*y**2
"""
h = dmp_quo(dmp_mul(f, g, u, K), dmp_gcd(f, g, u, K), u, K)
return dmp_ground_monic(h, u, K)
开发者ID:mattpap,项目名称:sympy,代码行数:20,代码来源:euclidtools.py
示例15: dmp_primitive
def dmp_primitive(f, u, K):
"""
Returns multivariate content and a primitive polynomial.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x,y, = ring("x,y", ZZ)
>>> R.dmp_primitive(2*x*y + 6*x + 4*y + 12)
(2*y + 6, x + 2)
"""
cont, v = dmp_content(f, u, K), u - 1
if dmp_zero_p(f, u) or dmp_one_p(cont, v, K):
return cont, f
else:
return cont, [ dmp_quo(c, cont, v, K) for c in f ]
开发者ID:AdrianPotter,项目名称:sympy,代码行数:20,代码来源:euclidtools.py
示例16: dmp_primitive
def dmp_primitive(f, u, K):
"""
Returns multivariate content and a primitive polynomial.
**Examples**
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.euclidtools import dmp_primitive
>>> f = ZZ.map([[2, 6], [4, 12]])
>>> dmp_primitive(f, 1, ZZ)
([2, 6], [[1], [2]])
"""
cont, v = dmp_content(f, u, K), u-1
if dmp_zero_p(f, u) or dmp_one_p(cont, v, K):
return cont, f
else:
return cont, [ dmp_quo(c, cont, v, K) for c in f ]
开发者ID:fxkr,项目名称:sympy,代码行数:21,代码来源:euclidtools.py
示例17: 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
开发者ID:Tkizzy,项目名称:PythonistaAppTemplate,代码行数:76,代码来源:euclidtools.py
示例18: dmp_zz_diophantine
def dmp_zz_diophantine(F, c, A, d, p, u, K):
"""Wang/EEZ: Solve multivariate Diophantine equations. """
if not A:
S = [ [] for _ in F ]
n = dup_degree(c)
for i, coeff in enumerate(c):
if not coeff:
continue
T = dup_zz_diophantine(F, n-i, p, K)
for j, (s, t) in enumerate(zip(S, T)):
t = dup_mul_ground(t, coeff, K)
S[j] = dup_trunc(dup_add(s, t, K), p, K)
else:
n = len(A)
e = dmp_expand(F, u, K)
a, A = A[-1], A[:-1]
B, G = [], []
for f in F:
B.append(dmp_quo(e, f, u, K))
G.append(dmp_eval_in(f, a, n, u, K))
C = dmp_eval_in(c, a, n, u, K)
v = u - 1
S = dmp_zz_diophantine(G, C, A, d, p, v, K)
S = [ dmp_raise(s, 1, v, K) for s in S ]
for s, b in zip(S, B):
c = dmp_sub_mul(c, s, b, u, K)
c = dmp_ground_trunc(c, p, u, K)
m = dmp_nest([K.one, -a], n, K)
M = dmp_one(n, K)
for k in xrange(0, d):
if dmp_zero_p(c, u):
break
M = dmp_mul(M, m, u, K)
C = dmp_diff_eval_in(c, k+1, a, n, u, K)
if not dmp_zero_p(C, v):
C = dmp_quo_ground(C, K.factorial(k+1), v, K)
T = dmp_zz_diophantine(G, C, A, d, p, v, K)
for i, t in enumerate(T):
T[i] = dmp_mul(dmp_raise(t, 1, v, K), M, u, K)
for i, (s, t) in enumerate(zip(S, T)):
S[i] = dmp_add(s, t, u, K)
for t, b in zip(T, B):
c = dmp_sub_mul(c, t, b, u, K)
c = dmp_ground_trunc(c, p, u, K)
S = [ dmp_ground_trunc(s, p, u, K) for s in S ]
return S
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:66,代码来源:factortools.py
示例19: quo
def quo(f, g):
"""Computes polynomial quotient of `f` and `g`. """
lev, dom, per, F, G = f.unify(g)
return per(dmp_quo(F, G, lev, dom))
开发者ID:fxkr,项目名称:sympy,代码行数:4,代码来源:polyclasses.py
示例20: 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_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
开发者ID:dyao-vu,项目名称:meta-core,代码行数:75,代码来源:euclidtools.py
注:本文中的sympy.polys.densearith.dmp_quo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论