本文整理汇总了Python中sympy.polys.densebasic.dup_normal函数的典型用法代码示例。如果您正苦于以下问题:Python dup_normal函数的具体用法?Python dup_normal怎么用?Python dup_normal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dup_normal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_dup_pow
def test_dup_pow():
assert dup_pow([], 0, ZZ) == [ZZ(1)]
assert dup_pow([], 0, QQ) == [QQ(1)]
assert dup_pow([], 1, ZZ) == []
assert dup_pow([], 7, ZZ) == []
assert dup_pow([ZZ(1)], 0, ZZ) == [ZZ(1)]
assert dup_pow([ZZ(1)], 1, ZZ) == [ZZ(1)]
assert dup_pow([ZZ(1)], 7, ZZ) == [ZZ(1)]
assert dup_pow([ZZ(3)], 0, ZZ) == [ZZ(1)]
assert dup_pow([ZZ(3)], 1, ZZ) == [ZZ(3)]
assert dup_pow([ZZ(3)], 7, ZZ) == [ZZ(2187)]
assert dup_pow([QQ(1,1)], 0, QQ) == [QQ(1,1)]
assert dup_pow([QQ(1,1)], 1, QQ) == [QQ(1,1)]
assert dup_pow([QQ(1,1)], 7, QQ) == [QQ(1,1)]
assert dup_pow([QQ(3,7)], 0, QQ) == [QQ(1,1)]
assert dup_pow([QQ(3,7)], 1, QQ) == [QQ(3,7)]
assert dup_pow([QQ(3,7)], 7, QQ) == [QQ(2187,823543)]
f = dup_normal([2,0,0,1,7], ZZ)
assert dup_pow(f, 0, ZZ) == dup_normal([1], ZZ)
assert dup_pow(f, 1, ZZ) == dup_normal([2,0,0,1,7], ZZ)
assert dup_pow(f, 2, ZZ) == dup_normal([4,0,0,4,28,0,1,14,49], ZZ)
assert dup_pow(f, 3, ZZ) == dup_normal([8,0,0,12,84,0,6,84,294,1,21,147,343], ZZ)
开发者ID:BDGLunde,项目名称:sympy,代码行数:29,代码来源:test_densearith.py
示例2: test_dup_diff
def test_dup_diff():
assert dup_diff([], 1, ZZ) == []
assert dup_diff([7], 1, ZZ) == []
assert dup_diff([2, 7], 1, ZZ) == [2]
assert dup_diff([1, 2, 1], 1, ZZ) == [2, 2]
assert dup_diff([1, 2, 3, 4], 1, ZZ) == [3, 4, 3]
assert dup_diff([1, -1, 0, 0, 2], 1, ZZ) == [4, -3, 0, 0]
f = dup_normal([17, 34, 56, -345, 23, 76, 0, 0, 12, 3, 7], ZZ)
assert dup_diff(f, 0, ZZ) == f
assert dup_diff(f, 1, ZZ) == dup_diff(f, 1, ZZ)
assert dup_diff(f, 2, ZZ) == dup_diff(dup_diff(f, 1, ZZ), 1, ZZ)
assert dup_diff(
f, 3, ZZ) == dup_diff(dup_diff(dup_diff(f, 1, ZZ), 1, ZZ), 1, ZZ)
K = FF(3)
f = dup_normal([17, 34, 56, -345, 23, 76, 0, 0, 12, 3, 7], K)
assert dup_diff(f, 1, K) == dup_normal([2, 0, 1, 0, 0, 2, 0, 0, 0, 0], K)
assert dup_diff(f, 2, K) == dup_normal([1, 0, 0, 2, 0, 0, 0], K)
assert dup_diff(f, 3, K) == dup_normal([], K)
assert dup_diff(f, 0, K) == f
assert dup_diff(f, 1, K) == dup_diff(f, 1, K)
assert dup_diff(f, 2, K) == dup_diff(dup_diff(f, 1, K), 1, K)
assert dup_diff(
f, 3, K) == dup_diff(dup_diff(dup_diff(f, 1, K), 1, K), 1, K)
开发者ID:FireJade,项目名称:sympy,代码行数:28,代码来源:test_densetools.py
示例3: test_dup_mul
def test_dup_mul():
assert dup_mul([], [], ZZ) == []
assert dup_mul([], [ZZ(1)], ZZ) == []
assert dup_mul([ZZ(1)], [], ZZ) == []
assert dup_mul([ZZ(1)], [ZZ(1)], ZZ) == [ZZ(1)]
assert dup_mul([ZZ(5)], [ZZ(7)], ZZ) == [ZZ(35)]
assert dup_mul([], [], QQ) == []
assert dup_mul([], [QQ(1,2)], QQ) == []
assert dup_mul([QQ(1,2)], [], QQ) == []
assert dup_mul([QQ(1,2)], [QQ(4,7)], QQ) == [QQ(2,7)]
assert dup_mul([QQ(5,7)], [QQ(3,7)], QQ) == [QQ(15,49)]
f = dup_normal([3,0,0,6,1,2], ZZ)
g = dup_normal([4,0,1,0], ZZ)
h = dup_normal([12,0,3,24,4,14,1,2,0], ZZ)
assert dup_mul(f, g, ZZ) == h
assert dup_mul(g, f, ZZ) == h
f = dup_normal([2,0,0,1,7], ZZ)
h = dup_normal([4,0,0,4,28,0,1,14,49], ZZ)
assert dup_mul(f, f, ZZ) == h
K = FF(6)
assert dup_mul([K(2),K(1)], [K(3),K(4)], K) == [K(5),K(4)]
开发者ID:BDGLunde,项目名称:sympy,代码行数:28,代码来源:test_densearith.py
示例4: test_dup_extract
def test_dup_extract():
f = dup_normal([2930944, 0, 2198208, 0, 549552, 0, 45796], ZZ)
g = dup_normal([17585664, 0, 8792832, 0, 1099104, 0], ZZ)
F = dup_normal([64, 0, 48, 0, 12, 0, 1], ZZ)
G = dup_normal([384, 0, 192, 0, 24, 0], ZZ)
assert dup_extract(f, g, ZZ) == (45796, F, G)
开发者ID:FireJade,项目名称:sympy,代码行数:8,代码来源:test_densetools.py
示例5: test_dup_mul_ground
def test_dup_mul_ground():
f = dup_normal([], ZZ)
assert dup_mul_ground(f, ZZ(2), ZZ) == dup_normal([], ZZ)
f = dup_normal([1,2,3], ZZ)
assert dup_mul_ground(f, ZZ(0), ZZ) == dup_normal([], ZZ)
assert dup_mul_ground(f, ZZ(2), ZZ) == dup_normal([2,4,6], ZZ)
开发者ID:BDGLunde,项目名称:sympy,代码行数:9,代码来源:test_densearith.py
示例6: test_dup_rr_div
def test_dup_rr_div():
raises(ZeroDivisionError, lambda: dup_rr_div([1,2,3], [], ZZ))
f = dup_normal([3,1,1,5], ZZ)
g = dup_normal([5,-3,1], ZZ)
q, r = [], f
assert dup_rr_div(f, g, ZZ) == (q, r)
开发者ID:BDGLunde,项目名称:sympy,代码行数:9,代码来源:test_densearith.py
示例7: test_dup_ff_div
def test_dup_ff_div():
raises(ZeroDivisionError, lambda: dup_ff_div([1,2,3], [], QQ))
f = dup_normal([3,1,1,5], QQ)
g = dup_normal([5,-3,1], QQ)
q = [QQ(3,5), QQ(14,25)]
r = [QQ(52,25), QQ(111,25)]
assert dup_ff_div(f, g, QQ) == (q, r)
开发者ID:BDGLunde,项目名称:sympy,代码行数:10,代码来源:test_densearith.py
示例8: test_dup_sqr
def test_dup_sqr():
assert dup_sqr([], ZZ) == []
assert dup_sqr([ZZ(2)], ZZ) == [ZZ(4)]
assert dup_sqr([ZZ(1),ZZ(2)], ZZ) == [ZZ(1),ZZ(4),ZZ(4)]
assert dup_sqr([], QQ) == []
assert dup_sqr([QQ(2,3)], QQ) == [QQ(4,9)]
assert dup_sqr([QQ(1,3),QQ(2,3)], QQ) == [QQ(1,9),QQ(4,9),QQ(4,9)]
f = dup_normal([2,0,0,1,7], ZZ)
assert dup_sqr(f, ZZ) == dup_normal([4,0,0,4,28,0,1,14,49], ZZ)
开发者ID:Aang,项目名称:sympy,代码行数:12,代码来源:test_densearith.py
示例9: dup_ff_div
def dup_ff_div(f, g, K):
"""Polynomial division with remainder over a field. """
df = dup_degree(f)
dg = dup_degree(g)
q, r = [], f
if not g:
raise ZeroDivisionError("polynomial division")
elif df < dg:
return q, r
lc_g = dup_LC(g, K)
while True:
dr = dup_degree(r)
if dr < dg:
break
lc_r = dup_LC(r, K)
c = K.exquo(lc_r, lc_g)
j = dr - dg
q = dup_add_term(q, c, j, K)
h = dup_mul_term(g, c, j, K)
r = dup_sub(r, h, K)
if not K.is_Exact:
r = dup_normal(r, K)
return q, r
开发者ID:Aang,项目名称:sympy,代码行数:34,代码来源:densearith.py
示例10: test_dup_quo_ground
def test_dup_quo_ground():
raises(ZeroDivisionError, 'dup_quo_ground(dup_normal([1,2,3], ZZ), ZZ(0), ZZ)')
raises(ExactQuotientFailed, 'dup_quo_ground(dup_normal([1,2,3], ZZ), ZZ(3), ZZ)')
f = dup_normal([], ZZ)
assert dup_quo_ground(f, ZZ(3), ZZ) == dup_normal([], ZZ)
f = dup_normal([6,2,8], ZZ)
assert dup_quo_ground(f, ZZ(1), ZZ) == f
assert dup_quo_ground(f, ZZ(2), ZZ) == dup_normal([3,1,4], ZZ)
f = dup_normal([6,2,8], QQ)
assert dup_quo_ground(f, QQ(1), QQ) == f
assert dup_quo_ground(f, QQ(2), QQ) == [QQ(3),QQ(1),QQ(4)]
assert dup_quo_ground(f, QQ(7), QQ) == [QQ(6,7),QQ(2,7),QQ(8,7)]
开发者ID:Aang,项目名称:sympy,代码行数:18,代码来源:test_densearith.py
示例11: test_dup_mul_term
def test_dup_mul_term():
f = dup_normal([], ZZ)
assert dup_mul_term(f, ZZ(2), 3, ZZ) == dup_normal([], ZZ)
f = dup_normal([1,1], ZZ)
assert dup_mul_term(f, ZZ(0), 3, ZZ) == dup_normal([], ZZ)
f = dup_normal([1,2,3], ZZ)
assert dup_mul_term(f, ZZ(2), 0, ZZ) == dup_normal([2,4,6], ZZ)
assert dup_mul_term(f, ZZ(2), 1, ZZ) == dup_normal([2,4,6,0], ZZ)
assert dup_mul_term(f, ZZ(2), 2, ZZ) == dup_normal([2,4,6,0,0], ZZ)
assert dup_mul_term(f, ZZ(2), 3, ZZ) == dup_normal([2,4,6,0,0,0], ZZ)
开发者ID:BDGLunde,项目名称:sympy,代码行数:15,代码来源:test_densearith.py
示例12: test_dup_gcdex
def test_dup_gcdex():
f = dup_normal([1,-2,-6,12,15], QQ)
g = dup_normal([1,1,-4,-4], QQ)
s = [QQ(-1,5),QQ(3,5)]
t = [QQ(1,5),QQ(-6,5),QQ(2)]
h = [QQ(1),QQ(1)]
assert dup_half_gcdex(f, g, QQ) == (s, h)
assert dup_gcdex(f, g, QQ) == (s, t, h)
f = dup_normal([1,4,0,-1,1], QQ)
g = dup_normal([1,0,-1,1], QQ)
s, t, h = dup_gcdex(f, g, QQ)
S, T, H = dup_gcdex(g, f, QQ)
assert dup_add(dup_mul(s, f, QQ),
dup_mul(t, g, QQ), QQ) == h
assert dup_add(dup_mul(S, g, QQ),
dup_mul(T, f, QQ), QQ) == H
f = dup_normal([2,0], QQ)
g = dup_normal([1,0,-16], QQ)
s = [QQ(1,32),QQ(0)]
t = [QQ(-1,16)]
h = [QQ(1)]
assert dup_half_gcdex(f, g, QQ) == (s, h)
assert dup_gcdex(f, g, QQ) == (s, t, h)
开发者ID:addisonc,项目名称:sympy,代码行数:31,代码来源:test_euclidtools.py
示例13: dup_ff_div
def dup_ff_div(f, g, K):
"""
Polynomial division with remainder over a field.
Examples
========
>>> from sympy.polys.domains import QQ
>>> from sympy.polys.densearith import dup_ff_div
>>> f = QQ.map([1, 0, 1])
>>> g = QQ.map([2, -4])
>>> dup_ff_div(f, g, QQ)
([1/2, 1/1], [5/1])
"""
df = dup_degree(f)
dg = dup_degree(g)
q, r = [], f
if not g:
raise ZeroDivisionError("polynomial division")
elif df < dg:
return q, r
lc_g = dup_LC(g, K)
while True:
dr = dup_degree(r)
if dr < dg:
break
lc_r = dup_LC(r, K)
c = K.exquo(lc_r, lc_g)
j = dr - dg
q = dup_add_term(q, c, j, K)
h = dup_mul_term(g, c, j, K)
r = dup_sub(r, h, K)
if not K.is_Exact:
r = dup_normal(r, K)
return q, r
开发者ID:SwaathiRamesh,项目名称:sympy,代码行数:49,代码来源:densearith.py
示例14: dup_ff_div
def dup_ff_div(f, g, K):
"""
Polynomial division with remainder over a field.
Examples
========
>>> from sympy.polys import ring, QQ
>>> R, x = ring("x", QQ)
>>> R.dup_ff_div(x**2 + 1, 2*x - 4)
(1/2*x + 1, 5)
"""
df = dup_degree(f)
dg = dup_degree(g)
q, r = [], f
if not g:
raise ZeroDivisionError("polynomial division")
elif df < dg:
return q, r
lc_g = dup_LC(g, K)
while True:
dr = dup_degree(r)
if dr < dg:
break
lc_r = dup_LC(r, K)
c = K.exquo(lc_r, lc_g)
j = dr - dg
q = dup_add_term(q, c, j, K)
h = dup_mul_term(g, c, j, K)
r = dup_sub(r, h, K)
if not K.is_Exact:
r = dup_normal(r, K)
return q, r
开发者ID:Acebulf,项目名称:sympy,代码行数:46,代码来源:densearith.py
示例15: 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
示例16: test_dup_quo_ground
def test_dup_quo_ground():
raises(ZeroDivisionError, lambda: dup_quo_ground(dup_normal([1,2,3], ZZ), ZZ(0), ZZ))
f = dup_normal([], ZZ)
assert dup_quo_ground(f, ZZ(3), ZZ) == dup_normal([], ZZ)
f = dup_normal([6,2,8], ZZ)
assert dup_quo_ground(f, ZZ(1), ZZ) == f
assert dup_quo_ground(f, ZZ(2), ZZ) == dup_normal([3,1,4], ZZ)
assert dup_quo_ground(f, ZZ(3), ZZ) == dup_normal([2,0,2], ZZ)
f = dup_normal([6,2,8], QQ)
assert dup_quo_ground(f, QQ(1), QQ) == f
assert dup_quo_ground(f, QQ(2), QQ) == [QQ(3),QQ(1),QQ(4)]
assert dup_quo_ground(f, QQ(7), QQ) == [QQ(6,7),QQ(2,7),QQ(8,7)]
开发者ID:BDGLunde,项目名称:sympy,代码行数:19,代码来源:test_densearith.py
示例17: test_dup_pdiv
def test_dup_pdiv():
f = dup_normal([3,1,1,5], ZZ)
g = dup_normal([5,-3,1], ZZ)
q = dup_normal([15, 14], ZZ)
r = dup_normal([52, 111], ZZ)
assert dup_pdiv(f, g, ZZ) == (q, r)
assert dup_pquo(f, g, ZZ) == q
assert dup_prem(f, g, ZZ) == r
raises(ExactQuotientFailed, lambda: dup_pexquo(f, g, ZZ))
f = dup_normal([3,1,1,5], QQ)
g = dup_normal([5,-3,1], QQ)
q = dup_normal([15, 14], QQ)
r = dup_normal([52, 111], QQ)
assert dup_pdiv(f, g, QQ) == (q, r)
assert dup_pquo(f, g, QQ) == q
assert dup_prem(f, g, QQ) == r
raises(ExactQuotientFailed, lambda: dup_pexquo(f, g, QQ))
开发者ID:BDGLunde,项目名称:sympy,代码行数:24,代码来源:test_densearith.py
示例18: test_dup_add_term
def test_dup_add_term():
f = dup_normal([], ZZ)
assert dup_add_term(f, ZZ(0), 0, ZZ) == dup_normal([], ZZ)
assert dup_add_term(f, ZZ(1), 0, ZZ) == dup_normal([1], ZZ)
assert dup_add_term(f, ZZ(1), 1, ZZ) == dup_normal([1, 0], ZZ)
assert dup_add_term(f, ZZ(1), 2, ZZ) == dup_normal([1, 0, 0], ZZ)
f = dup_normal([1,1,1], ZZ)
assert dup_add_term(f, ZZ(1), 0, ZZ) == dup_normal([1, 1, 2], ZZ)
assert dup_add_term(f, ZZ(1), 1, ZZ) == dup_normal([1, 2, 1], ZZ)
assert dup_add_term(f, ZZ(1), 2, ZZ) == dup_normal([2, 1, 1], ZZ)
assert dup_add_term(f, ZZ(1), 3, ZZ) == dup_normal([1, 1, 1, 1], ZZ)
assert dup_add_term(f, ZZ(1), 4, ZZ) == dup_normal([1, 0, 1, 1, 1], ZZ)
assert dup_add_term(f, ZZ(1), 5, ZZ) == dup_normal([1, 0, 0, 1, 1, 1], ZZ)
assert dup_add_term(f, ZZ(1), 6, ZZ) == dup_normal([1, 0, 0, 0, 1, 1, 1], ZZ)
assert dup_add_term(f,ZZ(-1), 2, ZZ) == dup_normal([1, 1], ZZ)
开发者ID:BDGLunde,项目名称:sympy,代码行数:21,代码来源:test_densearith.py
示例19: test_dmp_zz_wang
def test_dmp_zz_wang():
p = ZZ(nextprime(dmp_zz_mignotte_bound(w_1, 2, ZZ)))
assert p == ZZ(6291469)
t_1, k_1, e_1 = dmp_normal([[1],[]], 1, ZZ), 1, ZZ(-14)
t_2, k_2, e_2 = dmp_normal([[1, 0]], 1, ZZ), 2, ZZ(3)
t_3, k_3, e_3 = dmp_normal([[1],[ 1, 0]], 1, ZZ), 2, ZZ(-11)
t_4, k_4, e_4 = dmp_normal([[1],[-1, 0]], 1, ZZ), 1, ZZ(-17)
T = [t_1, t_2, t_3, t_4]
K = [k_1, k_2, k_3, k_4]
E = [e_1, e_2, e_3, e_4]
T = zip(T, K)
A = [ZZ(-14), ZZ(3)]
S = dmp_eval_tail(w_1, A, 2, ZZ)
cs, s = dup_primitive(S, ZZ)
assert cs == 1 and s == S == \
dup_normal([1036728, 915552, 55748, 105621, -17304, -26841, -644], ZZ)
assert dmp_zz_wang_non_divisors(E, cs, 4, ZZ) == [7, 3, 11, 17]
assert dup_sqf_p(s, ZZ) and dup_degree(s) == dmp_degree(w_1, 2)
_, H = dup_zz_factor_sqf(s, ZZ)
h_1 = dup_normal([44, 42, 1], ZZ)
h_2 = dup_normal([126, -9, 28], ZZ)
h_3 = dup_normal([187, 0, -23], ZZ)
assert H == [h_1, h_2, h_3]
lc_1 = dmp_normal([[-4], [-4,0]], 1, ZZ)
lc_2 = dmp_normal([[-1,0,0], []], 1, ZZ)
lc_3 = dmp_normal([[1], [], [-1,0,0]], 1, ZZ)
LC = [lc_1, lc_2, lc_3]
assert dmp_zz_wang_lead_coeffs(w_1, T, cs, E, H, A, 2, ZZ) == (w_1, H, LC)
H_1 = [ dmp_normal(t, 0, ZZ) for t in [[44L,42L,1L],[126L,-9L,28L],[187L,0L,-23L]] ]
H_2 = [ dmp_normal(t, 1, ZZ) for t in [[[-4,-12],[-3,0],[1]],[[-9,0],[-9],[-2,0]],[[1,0,-9],[],[1,-9]]] ]
H_3 = [ dmp_normal(t, 1, ZZ) for t in [[[-4,-12],[-3,0],[1]],[[-9,0],[-9],[-2,0]],[[1,0,-9],[],[1,-9]]] ]
c_1 = dmp_normal([-70686,-5863,-17826,2009,5031,74], 0, ZZ)
c_2 = dmp_normal([[9,12,-45,-108,-324],[18,-216,-810,0],[2,9,-252,-288,-945],[-30,-414,0],[2,-54,-3,81],[12,0]], 1, ZZ)
c_3 = dmp_normal([[-36,-108,0],[-27,-36,-108],[-8,-42,0],[-6,0,9],[2,0]], 1, ZZ)
T_1 = [ dmp_normal(t, 0, ZZ) for t in [[-3,0],[-2],[1]] ]
T_2 = [ dmp_normal(t, 1, ZZ) for t in [[[-1,0],[]],[[-3],[]],[[-6]]] ]
T_3 = [ dmp_normal(t, 1, ZZ) for t in [[[]],[[]],[[-1]]] ]
assert dmp_zz_diophantine(H_1, c_1, [], 5, p, 0, ZZ) == T_1
assert dmp_zz_diophantine(H_2, c_2, [ZZ(-14)], 5, p, 1, ZZ) == T_2
assert dmp_zz_diophantine(H_3, c_3, [ZZ(-14)], 5, p, 1, ZZ) == T_3
factors = dmp_zz_wang_hensel_lifting(w_1, H, LC, A, p, 2, ZZ)
assert dmp_expand(factors, 2, ZZ) == w_1
开发者ID:ENuge,项目名称:sympy,代码行数:62,代码来源:test_factortools.py
示例20: init_normal_ANP
def init_normal_ANP(rep, mod, dom):
return ANP(dup_normal(rep, dom),
dup_normal(mod, dom), dom)
开发者ID:fxkr,项目名称:sympy,代码行数:3,代码来源:polyclasses.py
注:本文中的sympy.polys.densebasic.dup_normal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论