本文整理汇总了Python中sympy.polys.densebasic.dmp_one_p函数的典型用法代码示例。如果您正苦于以下问题:Python dmp_one_p函数的具体用法?Python dmp_one_p怎么用?Python dmp_one_p使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dmp_one_p函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_dmp_content
def test_dmp_content():
assert dmp_content([[-2]], 1, ZZ) == [2]
f, g, F = [ZZ(3),ZZ(2),ZZ(1)], [ZZ(1)], []
for i in xrange(0, 5):
g = dup_mul(g, f, ZZ)
F.insert(0, g)
assert dmp_content(F, 1, ZZ) == f
assert dmp_one_p(dmp_content(f_4, 2, ZZ), 1, ZZ)
assert dmp_one_p(dmp_content(f_5, 2, ZZ), 1, ZZ)
assert dmp_one_p(dmp_content(f_6, 3, ZZ), 2, ZZ)
开发者ID:addisonc,项目名称:sympy,代码行数:14,代码来源:test_euclidtools.py
示例2: dmp_pow
def dmp_pow(f, n, u, K):
"""Raise f to the n-th power in `K[X]`. """
if not u:
return dup_pow(f, n, K)
if not n:
return dmp_one(u, K)
if n < 0:
raise ValueError("can't raise polynomial to a negative power")
if n == 1 or dmp_zero_p(f, u) or dmp_one_p(f, u, K):
return f
g = dmp_one(u, K)
while True:
n, m = n//2, n
if m & 1:
g = dmp_mul(g, f, u, K)
if not n:
break
f = dmp_sqr(f, u, K)
return g
开发者ID:Aang,项目名称:sympy,代码行数:26,代码来源:densearith.py
示例3: dmp_content
def dmp_content(f, u, K):
"""
Returns GCD of multivariate coefficients.
**Examples**
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.euclidtools import dmp_content
>>> f = ZZ.map([[2, 6], [4, 12]])
>>> dmp_content(f, 1, ZZ)
[2, 6]
"""
cont, v = dmp_LC(f, K), u-1
if dmp_zero_p(f, u):
return cont
for c in f[1:]:
cont = dmp_gcd(cont, c, v, K)
if dmp_one_p(cont, v, K):
break
if K.is_negative(dmp_ground_LC(cont, v, K)):
return dmp_neg(cont, v, K)
else:
return cont
开发者ID:addisonc,项目名称:sympy,代码行数:30,代码来源:euclidtools.py
示例4: dmp_content
def dmp_content(f, u, K):
"""
Returns GCD of multivariate coefficients.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x,y, = ring("x,y", ZZ)
>>> R.dmp_content(2*x*y + 6*x + 4*y + 12)
2*y + 6
"""
cont, v = dmp_LC(f, K), u - 1
if dmp_zero_p(f, u):
return cont
for c in f[1:]:
cont = dmp_gcd(cont, c, v, K)
if dmp_one_p(cont, v, K):
break
if K.is_negative(dmp_ground_LC(cont, v, K)):
return dmp_neg(cont, v, K)
else:
return cont
开发者ID:AdrianPotter,项目名称:sympy,代码行数:29,代码来源:euclidtools.py
示例5: test_dmp_primitive
def test_dmp_primitive():
assert dmp_primitive([[]], 1, ZZ) == ([], [[]])
assert dmp_primitive([[1]], 1, ZZ) == ([1], [[1]])
f, g, F = [ZZ(3),ZZ(2),ZZ(1)], [ZZ(1)], []
for i in xrange(0, 5):
g = dup_mul(g, f, ZZ)
F.insert(0, g)
assert dmp_primitive(F, 1, ZZ) == (f,
[ dup_exquo(c, f, ZZ) for c in F ])
cont, f = dmp_primitive(f_4, 2, ZZ)
assert dmp_one_p(cont, 1, ZZ) and f == f_4
cont, f = dmp_primitive(f_5, 2, ZZ)
assert dmp_one_p(cont, 1, ZZ) and f == f_5
cont, f = dmp_primitive(f_6, 3, ZZ)
assert dmp_one_p(cont, 2, ZZ) and f == f_6
开发者ID:addisonc,项目名称:sympy,代码行数:19,代码来源:test_euclidtools.py
示例6: _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_contain_one = dmp_one_p(f, u, K) or dmp_one_p(g, u, K)
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 if_contain_one:
return dmp_one(u, K), f, g
elif query('USE_SIMPLIFY_GCD'):
return _dmp_simplify_gcd(f, g, u, K)
else:
return None
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:24,代码来源:euclidtools.py
示例7: __ne__
def __ne__(f, g):
try:
if isinstance(g, DMP):
_, _, _, (F_num, F_den), G = f.poly_unify(g)
if f.lev == g.lev:
return not (dmp_one_p(F_den, f.lev, f.dom) and F_num == G)
else:
_, _, _, F, G = f.frac_unify(g)
if f.lev == g.lev:
return F != G
except UnificationFailed:
pass
return True
开发者ID:fxkr,项目名称:sympy,代码行数:16,代码来源:polyclasses.py
示例8: 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
示例9: 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_exquo(c, cont, v, K) for c in f ]
开发者ID:addisonc,项目名称:sympy,代码行数:21,代码来源:euclidtools.py
示例10: dmp_pow
def dmp_pow(f, n, u, K):
"""
Raise ``f`` to the ``n``-th power in ``K[X]``.
Examples
========
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.densearith import dmp_pow
>>> f = ZZ.map([[1, 0], [1]])
>>> dmp_pow(f, 3, 1, ZZ)
[[1, 0, 0, 0], [3, 0, 0], [3, 0], [1]]
"""
if not u:
return dup_pow(f, n, K)
if not n:
return dmp_one(u, K)
if n < 0:
raise ValueError("can't raise polynomial to a negative power")
if n == 1 or dmp_zero_p(f, u) or dmp_one_p(f, u, K):
return f
g = dmp_one(u, K)
while True:
n, m = n//2, n
if m & 1:
g = dmp_mul(g, f, u, K)
if not n:
break
f = dmp_sqr(f, u, K)
return g
开发者ID:SwaathiRamesh,项目名称:sympy,代码行数:40,代码来源:densearith.py
示例11: dmp_pow
def dmp_pow(f, n, u, K):
"""
Raise ``f`` to the ``n``-th power in ``K[X]``.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)
>>> R.dmp_pow(x*y + 1, 3)
x**3*y**3 + 3*x**2*y**2 + 3*x*y + 1
"""
if not u:
return dup_pow(f, n, K)
if not n:
return dmp_one(u, K)
if n < 0:
raise ValueError("can't raise polynomial to a negative power")
if n == 1 or dmp_zero_p(f, u) or dmp_one_p(f, u, K):
return f
g = dmp_one(u, K)
while True:
n, m = n//2, n
if m & 1:
g = dmp_mul(g, f, u, K)
if not n:
break
f = dmp_sqr(f, u, K)
return g
开发者ID:QuaBoo,项目名称:sympy,代码行数:38,代码来源:densearith.py
示例12: dmp_prs_resultant
def dmp_prs_resultant(f, g, u, K):
"""
Resultant algorithm in ``K[X]`` using subresultant PRS.
**Examples**
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.euclidtools import dmp_prs_resultant
>>> f = ZZ.map([[3, 0], [], [-1, 0, 0, -4]])
>>> g = ZZ.map([[1], [1, 0, 0, 0], [-9]])
>>> a = ZZ.map([[3, 0, 0, 0, 0], [1, 0, -27, 4]])
>>> b = ZZ.map([[-3, 0, 0, -12, 1, 0, -54, 8, 729, -216, 16]])
>>> dmp_prs_resultant(f, g, 1, ZZ) == (b[0], [f, g, a, b])
True
"""
if not u:
return dup_prs_resultant(f, g, K)
if dmp_zero_p(f, u) or dmp_zero_p(g, u):
return (dmp_zero(u-1), [])
R, B, D = dmp_inner_subresultants(f, g, u, K)
if dmp_degree(R[-1], u) > 0:
return (dmp_zero(u-1), R)
if dmp_one_p(R[-2], u, K):
return (dmp_LC(R[-1], K), R)
s, i, v = 1, 1, u-1
p = dmp_one(v, K)
q = dmp_one(v, K)
for b, d in zip(B, D)[:-1]:
du = dmp_degree(R[i-1], u)
dv = dmp_degree(R[i ], u)
dw = dmp_degree(R[i+1], u)
if du % 2 and dv % 2:
s = -s
lc, i = dmp_LC(R[i], K), i+1
p = dmp_mul(dmp_mul(p, dmp_pow(b, dv, v, K), v, K),
dmp_pow(lc, du-dw, v, K), v, K)
q = dmp_mul(q, dmp_pow(lc, dv*(1+d), v, K), v, K)
_, p, q = dmp_inner_gcd(p, q, v, K)
if s < 0:
p = dmp_neg(p, v, K)
i = dmp_degree(R[-2], u)
res = dmp_pow(dmp_LC(R[-1], K), i, v, K)
res = dmp_exquo(dmp_mul(res, p, v, K), q, v, K)
return res, R
开发者ID:addisonc,项目名称:sympy,代码行数:62,代码来源:euclidtools.py
示例13: is_one
def is_one(f):
"""Returns `True` if `f` is a unit polynomial. """
return dmp_one_p(f.rep, f.lev, f.dom)
开发者ID:fxkr,项目名称:sympy,代码行数:3,代码来源:polyclasses.py
示例14: test_dmp_one_p
def test_dmp_one_p():
assert dmp_one_p([1], 0, ZZ) == True
assert dmp_one_p([[1]], 1, ZZ) == True
assert dmp_one_p([[[1]]], 2, ZZ) == True
assert dmp_one_p([[[12]]], 2, ZZ) == False
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:5,代码来源:test_densebasic.py
示例15: dmp_prs_resultant
def dmp_prs_resultant(f, g, u, K):
"""
Resultant algorithm in `K[X]` using subresultant PRS.
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
>>> res, prs = R.dmp_prs_resultant(f, g)
>>> res == b # resultant has n-1 variables
False
>>> res == b.drop(x)
True
>>> prs == [f, g, a, b]
True
"""
if not u:
return dup_prs_resultant(f, g, K)
if dmp_zero_p(f, u) or dmp_zero_p(g, u):
return (dmp_zero(u - 1), [])
R, B, D = dmp_inner_subresultants(f, g, u, K)
if dmp_degree(R[-1], u) > 0:
return (dmp_zero(u - 1), R)
if dmp_one_p(R[-2], u, K):
return (dmp_LC(R[-1], K), R)
s, i, v = 1, 1, u - 1
p = dmp_one(v, K)
q = dmp_one(v, K)
for b, d in list(zip(B, D))[:-1]:
du = dmp_degree(R[i - 1], u)
dv = dmp_degree(R[i ], u)
dw = dmp_degree(R[i + 1], u)
if du % 2 and dv % 2:
s = -s
lc, i = dmp_LC(R[i], K), i + 1
p = dmp_mul(dmp_mul(p, dmp_pow(b, dv, v, K), v, K),
dmp_pow(lc, du - dw, v, K), v, K)
q = dmp_mul(q, dmp_pow(lc, dv*(1 + d), v, K), v, K)
_, p, q = dmp_inner_gcd(p, q, v, K)
if s < 0:
p = dmp_neg(p, v, K)
i = dmp_degree(R[-2], u)
res = dmp_pow(dmp_LC(R[-1], K), i, v, K)
res = dmp_quo(dmp_mul(res, p, v, K), q, v, K)
return res, R
开发者ID:Tkizzy,项目名称:PythonistaAppTemplate,代码行数:69,代码来源:euclidtools.py
注:本文中的sympy.polys.densebasic.dmp_one_p函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论