本文整理汇总了Python中sympy.polys.densebasic.dup_normal函数的典型用法代码示例。如果您正苦于以下问题:Python dup_normal函数的具体用法?Python dup_normal怎么用?Python dup_normal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dup_normal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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)]
示例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)
示例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)
示例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)
示例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)
示例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)
示例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
示例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)]
示例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)
示例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)
示例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
示例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
示例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)