本文整理汇总了Python中sympy.polys.densebasic.dmp_ground函数的典型用法代码示例。如果您正苦于以下问题:Python dmp_ground函数的具体用法?Python dmp_ground怎么用?Python dmp_ground使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dmp_ground函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: dmp_fateman_poly_F_1
def dmp_fateman_poly_F_1(n, K):
"""Fateman's GCD benchmark: trivial GCD """
u = [K(1), K(0)]
for i in xrange(0, n):
u = [dmp_one(i, K), u]
v = [K(1), K(0), K(0)]
for i in xrange(0, n):
v = [dmp_one(i, K), dmp_zero(i), v]
m = n - 1
U = dmp_add_term(u, dmp_ground(K(1), m), 0, n, K)
V = dmp_add_term(u, dmp_ground(K(2), m), 0, n, K)
f = [[-K(3), K(0)], [], [K(1), K(0), -K(1)]]
W = dmp_add_term(v, dmp_ground(K(1), m), 0, n, K)
Y = dmp_raise(f, m, 1, K)
F = dmp_mul(U, V, n, K)
G = dmp_mul(W, Y, n, K)
H = dmp_one(n, K)
return F, G, H
开发者ID:Acebulf,项目名称:sympy,代码行数:28,代码来源:specialpolys.py
示例2: _dmp_ff_trivial_gcd
def _dmp_ff_trivial_gcd(f, g, u, K):
"""Handle trivial cases in GCD algorithm over a field. """
zero_f = dmp_zero_p(f, u)
zero_g = dmp_zero_p(g, u)
if zero_f and zero_g:
return tuple(dmp_zeros(3, u, K))
elif zero_f:
return (dmp_ground_monic(g, u, K), dmp_zero(u), dmp_ground(dmp_ground_LC(g, u, K), u))
elif zero_g:
return (dmp_ground_monic(f, u, K), dmp_ground(dmp_ground_LC(f, u, K), u), dmp_zero(u))
elif query("USE_SIMPLIFY_GCD"):
return _dmp_simplify_gcd(f, g, u, K)
else:
return None
开发者ID:mattpap,项目名称:sympy,代码行数:15,代码来源:euclidtools.py
示例3: dmp_sqf_list_include
def dmp_sqf_list_include(f, u, K, all=False):
"""
Return square-free decomposition of a polynomial in ``K[x]``.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)
>>> f = x**5 + 2*x**4*y + x**3*y**2
>>> R.dmp_sqf_list_include(f)
[(1, 1), (x + y, 2), (x, 3)]
>>> R.dmp_sqf_list_include(f, all=True)
[(1, 1), (x + y, 2), (x, 3)]
"""
if not u:
return dup_sqf_list_include(f, K, all=all)
coeff, factors = dmp_sqf_list(f, u, K, all=all)
if factors and factors[0][1] == 1:
g = dmp_mul_ground(factors[0][0], coeff, u, K)
return [(g, 1)] + factors[1:]
else:
g = dmp_ground(coeff, u)
return [(g, 1)] + factors
开发者ID:alhirzel,项目名称:sympy,代码行数:29,代码来源:sqfreetools.py
示例4: dmp_sqf_list_include
def dmp_sqf_list_include(f, u, K, all=False):
"""
Return square-free decomposition of a polynomial in ``K[x]``.
Examples
========
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.sqfreetools import dmp_sqf_list_include
>>> f = ZZ.map([[1], [2, 0], [1, 0, 0], [], [], []])
>>> dmp_sqf_list_include(f, 1, ZZ)
[([[1]], 1), ([[1], [1, 0]], 2), ([[1], []], 3)]
>>> dmp_sqf_list_include(f, 1, ZZ, all=True)
[([[1]], 1), ([[1], [1, 0]], 2), ([[1], []], 3)]
"""
if not u:
return dup_sqf_list_include(f, K, all=all)
coeff, factors = dmp_sqf_list(f, u, K, all=all)
if factors and factors[0][1] == 1:
g = dmp_mul_ground(factors[0][0], coeff, u, K)
return [(g, 1)] + factors[1:]
else:
g = dmp_ground(coeff, u)
return [(g, 1)] + factors
开发者ID:FireJade,项目名称:sympy,代码行数:30,代码来源:sqfreetools.py
示例5: __sub__
def __sub__(f, g):
if not isinstance(g, DMP):
try:
g = f.per(dmp_ground(f.dom.convert(g), f.lev))
except TypeError:
return NotImplemented
return f.sub(g)
开发者ID:fxkr,项目名称:sympy,代码行数:8,代码来源:polyclasses.py
示例6: dup_real_imag
def dup_real_imag(f, K):
"""
Return bivariate polynomials ``f1`` and ``f2``, such that ``f = f1 + f2*I``.
Examples
========
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.densetools import dup_real_imag
>>> dup_real_imag([ZZ(1), ZZ(1), ZZ(1), ZZ(1)], ZZ)
([[1], [1], [-3, 0, 1], [-1, 0, 1]], [[3, 0], [2, 0], [-1, 0, 1, 0]])
"""
if not K.is_ZZ and not K.is_QQ:
raise DomainError(
"computing real and imaginary parts is not supported over %s" % K)
f1 = dmp_zero(1)
f2 = dmp_zero(1)
if not f:
return f1, f2
g = [[[K.one, K.zero]], [[K.one], []]]
h = dmp_ground(f[0], 2)
for c in f[1:]:
h = dmp_mul(h, g, 2, K)
h = dmp_add_term(h, dmp_ground(c, 1), 0, 2, K)
H = dup_to_raw_dict(h)
for k, h in H.iteritems():
m = k % 4
if not m:
f1 = dmp_add(f1, h, 1, K)
elif m == 1:
f2 = dmp_add(f2, h, 1, K)
elif m == 2:
f1 = dmp_sub(f1, h, 1, K)
else:
f2 = dmp_sub(f2, h, 1, K)
return f1, f2
开发者ID:jenshnielsen,项目名称:sympy,代码行数:46,代码来源:densetools.py
示例7: dup_real_imag
def dup_real_imag(f, K):
"""
Return bivariate polynomials ``f1`` and ``f2``, such that ``f = f1 + f2*I``.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)
>>> R.dup_real_imag(x**3 + x**2 + x + 1)
(x**3 + x**2 - 3*x*y**2 + x - y**2 + 1, 3*x**2*y + 2*x*y - y**3 + y)
"""
if not K.is_ZZ and not K.is_QQ:
raise DomainError("computing real and imaginary parts is not supported over %s" % K)
f1 = dmp_zero(1)
f2 = dmp_zero(1)
if not f:
return f1, f2
g = [[[K.one, K.zero]], [[K.one], []]]
h = dmp_ground(f[0], 2)
for c in f[1:]:
h = dmp_mul(h, g, 2, K)
h = dmp_add_term(h, dmp_ground(c, 1), 0, 2, K)
H = dup_to_raw_dict(h)
for k, h in H.items():
m = k % 4
if not m:
f1 = dmp_add(f1, h, 1, K)
elif m == 1:
f2 = dmp_add(f2, h, 1, K)
elif m == 2:
f1 = dmp_sub(f1, h, 1, K)
else:
f2 = dmp_sub(f2, h, 1, K)
return f1, f2
开发者ID:asmeurer,项目名称:sympy,代码行数:45,代码来源:densetools.py
示例8: __sub__
def __sub__(f, g):
if not isinstance(g, DMP):
try:
g = f.per(dmp_ground(f.dom.convert(g), f.lev))
except TypeError:
return NotImplemented
except CoercionFailed, e:
if f.ring is not None:
g = f.ring.convert(g)
else:
raise e
开发者ID:Ryzh,项目名称:sympy,代码行数:11,代码来源:polyclasses.py
示例9: __init__
def __init__(self, rep, dom, lev=None):
if lev is not None:
if type(rep) is dict:
rep = dmp_from_dict(rep, lev, dom)
elif type(rep) is not list:
rep = dmp_ground(dom.convert(rep), lev)
else:
rep, lev = dmp_validate(rep)
self.rep = rep
self.lev = lev
self.dom = dom
开发者ID:fxkr,项目名称:sympy,代码行数:12,代码来源:polyclasses.py
示例10: _dmp_rr_trivial_gcd
def _dmp_rr_trivial_gcd(f, g, u, K):
"""Handle trivial cases in GCD algorithm over a ring. """
zero_f = dmp_zero_p(f, u)
zero_g = dmp_zero_p(g, u)
if zero_f and zero_g:
return tuple(dmp_zeros(3, u, K))
elif zero_f:
if K.is_nonnegative(dmp_ground_LC(g, u, K)):
return g, dmp_zero(u), dmp_one(u, K)
else:
return dmp_neg(g, u, K), dmp_zero(u), dmp_ground(-K.one, u)
elif zero_g:
if K.is_nonnegative(dmp_ground_LC(f, u, K)):
return f, dmp_one(u, K), dmp_zero(u)
else:
return dmp_neg(f, u, K), dmp_ground(-K.one, u), dmp_zero(u)
elif query('USE_SIMPLIFY_GCD'):
return _dmp_simplify_gcd(f, g, u, K)
else:
return None
开发者ID:addisonc,项目名称:sympy,代码行数:21,代码来源:euclidtools.py
示例11: dmp_factor_list_include
def dmp_factor_list_include(f, u, K):
"""Factor polynomials into irreducibles in `K[X]`. """
if not u:
return dup_factor_list_include(f, K)
coeff, factors = dmp_factor_list(f, u, K)
if not factors:
return [(dmp_ground(coeff, u), 1)]
else:
g = dmp_mul_ground(factors[0][0], coeff, u, K)
return [(g, factors[0][1])] + factors[1:]
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:12,代码来源:factortools.py
示例12: __add__
def __add__(f, g):
if not isinstance(g, DMP):
try:
g = f.per(dmp_ground(f.dom.convert(g), f.lev))
except TypeError:
return NotImplemented
except (CoercionFailed, NotImplementedError):
if f.ring is not None:
try:
g = f.ring.convert(g)
except (CoercionFailed, NotImplementedError):
return NotImplemented
return f.add(g)
开发者ID:StefenYin,项目名称:sympy,代码行数:14,代码来源:polyclasses.py
示例13: dmp_sub_ground
def dmp_sub_ground(f, c, u, K):
"""
Subtract an element of the ground domain from ``f``.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)
>>> R.dmp_sub_ground(x**3 + 2*x**2 + 3*x + 4, ZZ(4))
x**3 + 2*x**2 + 3*x
"""
return dmp_sub_term(f, dmp_ground(c, u - 1), 0, u, K)
开发者ID:QuaBoo,项目名称:sympy,代码行数:15,代码来源:densearith.py
示例14: dmp_sub_ground
def dmp_sub_ground(f, c, u, K):
"""
Subtract an element of the ground domain from ``f``.
**Examples**
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.densearith import dmp_sub_ground
>>> f = ZZ.map([[1], [2], [3], [4]])
>>> dmp_sub_ground(f, ZZ(4), 1, ZZ)
[[1], [2], [3], []]
"""
return dmp_sub_term(f, dmp_ground(c, u-1), 0, u, K)
开发者ID:101man,项目名称:sympy,代码行数:16,代码来源:densearith.py
示例15: dmp_add_ground
def dmp_add_ground(f, c, u, K):
"""
Add an element of the ground domain to ``f``.
Examples
========
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.densearith import dmp_add_ground
>>> f = ZZ.map([[1], [2], [3], [4]])
>>> dmp_add_ground(f, ZZ(4), 1, ZZ)
[[1], [2], [3], [8]]
"""
return dmp_add_term(f, dmp_ground(c, u-1), 0, u, K)
开发者ID:SwaathiRamesh,项目名称:sympy,代码行数:17,代码来源:densearith.py
示例16: dmp_fateman_poly_F_3
def dmp_fateman_poly_F_3(n, K):
"""Fateman's GCD benchmark: sparse inputs (deg f ~ vars f) """
u = dup_from_raw_dict({n+1: K.one}, K)
for i in xrange(0, n-1):
u = dmp_add_term([u], dmp_one(i, K), n+1, i+1, K)
v = dmp_add_term(u, dmp_ground(K(2), n-2), 0, n, K)
f = dmp_sqr(dmp_add_term([dmp_neg(v, n-1, K)], dmp_one(n-1, K), n+1, n, K), n, K)
g = dmp_sqr(dmp_add_term([v], dmp_one(n-1, K), n+1, n, K), n, K)
v = dmp_add_term(u, dmp_one(n-2, K), 0, n-1, K)
h = dmp_sqr(dmp_add_term([v], dmp_one(n-1, K), n+1, n, K), n, K)
return dmp_mul(f, h, n, K), dmp_mul(g, h, n, K), h
开发者ID:addisonc,项目名称:sympy,代码行数:17,代码来源:specialpolys.py
示例17: dmp_fateman_poly_F_2
def dmp_fateman_poly_F_2(n, K):
"""Fateman's GCD benchmark: linearly dense quartic inputs """
u = [K(1), K(0)]
for i in xrange(0, n - 1):
u = [dmp_one(i, K), u]
m = n - 1
v = dmp_add_term(u, dmp_ground(K(2), m - 1), 0, n, K)
f = dmp_sqr([dmp_one(m, K), dmp_neg(v, m, K)], n, K)
g = dmp_sqr([dmp_one(m, K), v], n, K)
v = dmp_add_term(u, dmp_one(m - 1, K), 0, n, K)
h = dmp_sqr([dmp_one(m, K), v], n, K)
return dmp_mul(f, h, n, K), dmp_mul(g, h, n, K), h
开发者ID:Acebulf,项目名称:sympy,代码行数:19,代码来源:specialpolys.py
示例18: _parse
def _parse(cls, rep, dom, lev=None):
if type(rep) is tuple:
num, den = rep
if lev is not None:
if type(num) is dict:
num = dmp_from_dict(num, lev, dom)
if type(den) is dict:
den = dmp_from_dict(den, lev, dom)
else:
num, num_lev = dmp_validate(num)
den, den_lev = dmp_validate(den)
if num_lev == den_lev:
lev = num_lev
else:
raise ValueError('inconsistent number of levels')
if dmp_zero_p(den, lev):
raise ZeroDivisionError('fraction denominator')
if dmp_zero_p(num, lev):
den = dmp_one(lev, dom)
else:
if dmp_negative_p(den, lev, dom):
num = dmp_neg(num, lev, dom)
den = dmp_neg(den, lev, dom)
else:
num = rep
if lev is not None:
if type(num) is dict:
num = dmp_from_dict(num, lev, dom)
elif type(num) is not list:
num = dmp_ground(dom.convert(num), lev)
else:
num, lev = dmp_validate(num)
den = dmp_one(lev, dom)
return num, den, lev
开发者ID:fxkr,项目名称:sympy,代码行数:42,代码来源:polyclasses.py
示例19: dmp_factor_list
def dmp_factor_list(f, u, K0, **args):
"""Factor polynomials into irreducibles in `K[X]`. """
if not u:
return dup_factor_list(f, K0, **args)
if not K0.has_CharacteristicZero: # pragma: no cover
raise DomainError('only characteristic zero allowed')
if K0.is_Algebraic:
coeff, factors = dmp_ext_factor(f, u, K0)
else:
if not K0.is_Exact:
K0_inexact, K0 = K0, K0.get_exact()
f = dmp_convert(f, u, K0_inexact, K0)
else:
K0_inexact = None
if K0.has_Field:
K = K0.get_ring()
denom, f = dmp_ground_to_ring(f, u, K0, K)
f = dmp_convert(f, u, K0, K)
else:
K = K0
if K.is_ZZ:
coeff, factors = _dmp_inner_factor(f, u, K)
elif K.is_Poly:
f, v = dmp_inject(f, u, K)
coeff, factors = dmp_factor_list(f, v, K.dom, **args)
for i, (f, k) in enumerate(factors):
factors[i] = (dmp_eject(f, v, K), k)
coeff = K.convert(coeff, K.dom)
else: # pragma: no cover
raise DomainError('factorization not supported over %s' % K0)
if K0.has_Field:
for i, (f, k) in enumerate(factors):
factors[i] = (dmp_convert(f, u, K, K0), k)
coeff = K0.convert(coeff, K)
denom = K0.convert(denom, K)
coeff = K0.quo(coeff, denom)
if K0_inexact is not None:
for i, (f, k) in enumerate(factors):
factors[i] = (dmp_convert(f, u, K0, K0_inexact), k)
coeff = K0_inexact.convert(coeff, K0)
if not args.get('include', False):
return coeff, factors
else:
if not factors:
return [(dmp_ground(coeff, u), 1)]
else:
g = dmp_mul_ground(factors[0][0], coeff, u, K)
return [(g, factors[0][1])] + factors[1:]
开发者ID:Aang,项目名称:sympy,代码行数:62,代码来源:factortools.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_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
开发者ID:addisonc,项目名称:sympy,代码行数:74,代码来源:euclidtools.py
注:本文中的sympy.polys.densebasic.dmp_ground函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论