本文整理汇总了Python中sympy.polys.densebasic.dmp_nest函数的典型用法代码示例。如果您正苦于以下问题:Python dmp_nest函数的具体用法?Python dmp_nest怎么用?Python dmp_nest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dmp_nest函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: dmp_zz_wang_hensel_lifting
def dmp_zz_wang_hensel_lifting(f, H, LC, A, p, u, K):
"""Wang/EEZ: Parallel Hensel lifting algorithm. """
S, n, v = [f], len(A), u-1
H = list(H)
for i, a in enumerate(reversed(A[1:])):
s = dmp_eval_in(S[0], a, n-i, u-i, K)
S.insert(0, dmp_ground_trunc(s, p, v-i, K))
d = max(dmp_degree_list(f, u)[1:])
for j, s, a in zip(xrange(2, n+2), S, A):
G, w = list(H), j-1
I, J = A[:j-2], A[j-1:]
for i, (h, lc) in enumerate(zip(H, LC)):
lc = dmp_ground_trunc(dmp_eval_tail(lc, J, v, K), p, w-1, K)
H[i] = [lc] + dmp_raise(h[1:], 1, w-1, K)
m = dmp_nest([K.one, -a], w, K)
M = dmp_one(w, K)
c = dmp_sub(s, dmp_expand(H, w, K), w, K)
dj = dmp_degree_in(s, w, w)
for k in xrange(0, dj):
if dmp_zero_p(c, w):
break
M = dmp_mul(M, m, w, K)
C = dmp_diff_eval_in(c, k+1, a, w, w, K)
if not dmp_zero_p(C, w-1):
C = dmp_quo_ground(C, K.factorial(k+1), w-1, K)
T = dmp_zz_diophantine(G, C, I, d, p, w-1, K)
for i, (h, t) in enumerate(zip(H, T)):
h = dmp_add_mul(h, dmp_raise(t, 1, w-1, K), M, w, K)
H[i] = dmp_ground_trunc(h, p, w, K)
h = dmp_sub(s, dmp_expand(H, w, K), w, K)
c = dmp_ground_trunc(h, p, w, K)
if dmp_expand(H, u, K) != f:
raise ExtraneousFactors # pragma: no cover
else:
return H
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:50,代码来源:factortools.py
示例2: test_dmp_nest
def test_dmp_nest():
assert dmp_nest(ZZ(1), 2, ZZ) == [[[1]]]
assert dmp_nest([[1]], 0, ZZ) == [[1]]
assert dmp_nest([[1]], 1, ZZ) == [[[1]]]
assert dmp_nest([[1]], 2, ZZ) == [[[[1]]]]
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:6,代码来源:test_densebasic.py
示例3: 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
示例4: test_dmp_factor_list
def test_dmp_factor_list():
assert dmp_factor_list([[]], 1, ZZ) == (ZZ(0), [])
assert dmp_factor_list([[]], 1, QQ) == (QQ(0), [])
assert dmp_factor_list([[]], 1, ZZ['y']) == (DMP([],ZZ), [])
assert dmp_factor_list([[]], 1, QQ['y']) == (DMP([],QQ), [])
assert dmp_factor_list_include([[]], 1, ZZ) == [([[]], 1)]
assert dmp_factor_list([[ZZ(7)]], 1, ZZ) == (ZZ(7), [])
assert dmp_factor_list([[QQ(1,7)]], 1, QQ) == (QQ(1,7), [])
assert dmp_factor_list([[DMP([ZZ(7)],ZZ)]], 1, ZZ['y']) == (DMP([ZZ(7)],ZZ), [])
assert dmp_factor_list([[DMP([QQ(1,7)],QQ)]], 1, QQ['y']) == (DMP([QQ(1,7)],QQ), [])
assert dmp_factor_list_include([[ZZ(7)]], 1, ZZ) == [([[ZZ(7)]], 1)]
f, g = [ZZ(1),ZZ(2),ZZ(1)], [ZZ(1),ZZ(1)]
assert dmp_factor_list(dmp_nest(f, 200, ZZ), 200, ZZ) == \
(ZZ(1), [(dmp_nest(g, 200, ZZ), 2)])
assert dmp_factor_list(dmp_raise(f, 200, 0, ZZ), 200, ZZ) == \
(ZZ(1), [(dmp_raise(g, 200, 0, ZZ), 2)])
assert dmp_factor_list([ZZ(1),ZZ(2),ZZ(1)], 0, ZZ) == \
(ZZ(1), [([ZZ(1), ZZ(1)], 2)])
assert dmp_factor_list([QQ(1,2),QQ(1),QQ(1,2)], 0, QQ) == \
(QQ(1,2), [([QQ(1),QQ(1)], 2)])
assert dmp_factor_list([[ZZ(1)],[ZZ(2)],[ZZ(1)]], 1, ZZ) == \
(ZZ(1), [([[ZZ(1)], [ZZ(1)]], 2)])
assert dmp_factor_list([[QQ(1,2)],[QQ(1)],[QQ(1,2)]], 1, QQ) == \
(QQ(1,2), [([[QQ(1)],[QQ(1)]], 2)])
f = [[ZZ(4),ZZ(0)],[ZZ(4),ZZ(0),ZZ(0)],[]]
assert dmp_factor_list(f, 1, ZZ) == \
(ZZ(4), [([[ZZ(1),ZZ(0)]], 1),
([[ZZ(1)],[]], 1),
([[ZZ(1)],[ZZ(1),ZZ(0)]], 1)])
assert dmp_factor_list_include(f, 1, ZZ) == \
[([[ZZ(4),ZZ(0)]], 1),
([[ZZ(1)],[]], 1),
([[ZZ(1)],[ZZ(1),ZZ(0)]], 1)]
f = [[QQ(1,2),QQ(0)],[QQ(1,2),QQ(0),QQ(0)],[]]
assert dmp_factor_list(f, 1, QQ) == \
(QQ(1,2), [([[QQ(1),QQ(0)]], 1),
([[QQ(1)],[]], 1),
([[QQ(1)],[QQ(1),QQ(0)]], 1)])
f = [[RR(2.0)],[],[-RR(8.0),RR(0.0),RR(0.0)]]
assert dmp_factor_list(f, 1, RR) == \
(RR(2.0), [([[RR(1.0)],[-RR(2.0),RR(0.0)]], 1),
([[RR(1.0)],[ RR(2.0),RR(0.0)]], 1)])
f = [[DMP([ZZ(4),ZZ(0)],ZZ)],[DMP([ZZ(4),ZZ(0),ZZ(0)],ZZ)],[DMP([],ZZ)]]
assert dmp_factor_list(f, 1, ZZ['y']) == \
(DMP([ZZ(4)],ZZ), [([[DMP([ZZ(1),ZZ(0)],ZZ)]], 1),
([[DMP([ZZ(1)],ZZ)],[]], 1),
([[DMP([ZZ(1)],ZZ)],[DMP([ZZ(1),ZZ(0)],ZZ)]], 1)])
f = [[DMP([QQ(1,2),QQ(0)],ZZ)],[DMP([QQ(1,2),QQ(0),QQ(0)],ZZ)],[DMP([],ZZ)]]
assert dmp_factor_list(f, 1, QQ['y']) == \
(DMP([QQ(1,2)],QQ), [([[DMP([QQ(1),QQ(0)],QQ)]], 1),
([[DMP([QQ(1)],QQ)],[]], 1),
([[DMP([QQ(1)],QQ)],[DMP([QQ(1),QQ(0)],QQ)]], 1)])
K = FF(2)
raises(DomainError, "dmp_factor_list([[K(1)],[],[K(1),K(0),K(0)]], 1, K)")
raises(DomainError, "dmp_factor_list([[EX(sin(1))]], 1, EX)")
开发者ID:ENuge,项目名称:sympy,代码行数:76,代码来源:test_factortools.py
注:本文中的sympy.polys.densebasic.dmp_nest函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论