本文整理汇总了Python中sympy.polys.densearith.dmp_pow函数的典型用法代码示例。如果您正苦于以下问题:Python dmp_pow函数的具体用法?Python dmp_pow怎么用?Python dmp_pow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dmp_pow函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: pow
def pow(f, n):
"""Raise `f` to a non-negative power `n`. """
if isinstance(n, int):
return f.per(dmp_pow(f.num, n, f.lev, f.dom),
dmp_pow(f.den, n, f.lev, f.dom), cancel=False)
else:
raise TypeError("`int` expected, got %s" % type(n))
开发者ID:fxkr,项目名称:sympy,代码行数:7,代码来源:polyclasses.py
示例2: dmp_zz_wang_lead_coeffs
def dmp_zz_wang_lead_coeffs(f, T, cs, E, H, A, u, K):
"""Wang/EEZ: Compute correct leading coefficients. """
C, J, v = [], [0]*len(E), u-1
for h in H:
c = dmp_one(v, K)
d = dup_LC(h, K)*cs
for i in reversed(xrange(len(E))):
k, e, (t, _) = 0, E[i], T[i]
while not (d % e):
d, k = d//e, k+1
if k != 0:
c, J[i] = dmp_mul(c, dmp_pow(t, k, v, K), v, K), 1
C.append(c)
if any([ not j for j in J ]):
raise ExtraneousFactors # pragma: no cover
CC, HH = [], []
for c, h in zip(C, H):
d = dmp_eval_tail(c, A, v, K)
lc = dup_LC(h, K)
if K.is_one(cs):
cc = lc//d
else:
g = K.gcd(lc, d)
d, cc = d//g, lc//g
h, cs = dup_mul_ground(h, d, K), cs//d
c = dmp_mul_ground(c, cc, v, K)
CC.append(c)
HH.append(h)
if K.is_one(cs):
return f, HH, CC
CCC, HHH = [], []
for c, h in zip(CC, HH):
CCC.append(dmp_mul_ground(c, cs, v, K))
HHH.append(dmp_mul_ground(h, cs, 0, K))
f = dmp_mul_ground(f, cs**(len(H)-1), u, K)
return f, HHH, CCC
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:52,代码来源:factortools.py
示例3: 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
示例4: 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
示例5: test_dmp_pow
def test_dmp_pow():
assert dmp_pow([[]], 0, 1, ZZ) == [[ZZ(1)]]
assert dmp_pow([[]], 0, 1, QQ) == [[QQ(1)]]
assert dmp_pow([[]], 1, 1, ZZ) == [[]]
assert dmp_pow([[]], 7, 1, ZZ) == [[]]
assert dmp_pow([[ZZ(1)]], 0, 1, ZZ) == [[ZZ(1)]]
assert dmp_pow([[ZZ(1)]], 1, 1, ZZ) == [[ZZ(1)]]
assert dmp_pow([[ZZ(1)]], 7, 1, ZZ) == [[ZZ(1)]]
assert dmp_pow([[QQ(3,7)]], 0, 1, QQ) == [[QQ(1,1)]]
assert dmp_pow([[QQ(3,7)]], 1, 1, QQ) == [[QQ(3,7)]]
assert dmp_pow([[QQ(3,7)]], 7, 1, QQ) == [[QQ(2187,823543)]]
f = dup_normal([2,0,0,1,7], ZZ)
assert dmp_pow(f, 2, 0, ZZ) == dup_pow(f, 2, ZZ)
开发者ID:BDGLunde,项目名称:sympy,代码行数:18,代码来源:test_densearith.py
示例6: 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
开发者ID:AdrianPotter,项目名称:sympy,代码行数:78,代码来源:euclidtools.py
示例7: 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
示例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
开发者ID:Tkizzy,项目名称:PythonistaAppTemplate,代码行数:76,代码来源:euclidtools.py
示例9: pow
def pow(f, n):
"""Raise ``f`` to a non-negative power ``n``. """
if isinstance(n, int):
return f.per(dmp_pow(f.rep, n, f.lev, f.dom))
else:
raise TypeError("`int` expected, got %s" % type(n))
开发者ID:Ryzh,项目名称:sympy,代码行数:6,代码来源:polyclasses.py
注:本文中的sympy.polys.densearith.dmp_pow函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论