本文整理汇总了Python中sympy.polys.densebasic.dmp_normal函数的典型用法代码示例。如果您正苦于以下问题:Python dmp_normal函数的具体用法?Python dmp_normal怎么用?Python dmp_normal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dmp_normal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dmp_rr_div
def test_dmp_rr_div():
raises(ZeroDivisionError, lambda: dmp_rr_div([[1,2],[3]], [[]], 1, ZZ))
f = dmp_normal([[1], [], [1,0,0]], 1, ZZ)
g = dmp_normal([[1], [-1,0]], 1, ZZ)
q = dmp_normal([[1], [1, 0]], 1, ZZ)
r = dmp_normal([[2, 0, 0]], 1, ZZ)
assert dmp_rr_div(f, g, 1, ZZ) == (q, r)
f = dmp_normal([[1], [], [1,0,0]], 1, ZZ)
g = dmp_normal([[-1], [1,0]], 1, ZZ)
q = dmp_normal([[-1], [-1, 0]], 1, ZZ)
r = dmp_normal([[2, 0, 0]], 1, ZZ)
assert dmp_rr_div(f, g, 1, ZZ) == (q, r)
f = dmp_normal([[1], [], [1,0,0]], 1, ZZ)
g = dmp_normal([[2], [-2,0]], 1, ZZ)
q, r = [[]], f
assert dmp_rr_div(f, g, 1, ZZ) == (q, r)
示例2: test_dmp_quo_ground
def test_dmp_quo_ground():
f = dmp_normal([[6],[2],[8]], 1, ZZ)
assert dmp_quo_ground(f, ZZ(1), 1, ZZ) == f
assert dmp_quo_ground(f, ZZ(2), 1, ZZ) == dmp_normal([[3],[1],[4]], 1, ZZ)
assert dmp_normal(dmp_quo_ground(f, ZZ(3), 1, ZZ), 1, ZZ) == dmp_normal([[2],[],[2]], 1, ZZ)
示例3: test_dmp_ground_extract
def test_dmp_ground_extract():
f = dmp_normal([[2930944], [], [2198208], [], [549552], [], [45796]], 1, ZZ)
g = dmp_normal([[17585664], [], [8792832], [], [1099104], []], 1, ZZ)
F = dmp_normal([[64], [], [48], [], [12], [], [1]], 1, ZZ)
G = dmp_normal([[384], [], [192], [], [24], []], 1, ZZ)
assert dmp_ground_extract(f, g, 1, ZZ) == (45796, F, G)
示例4: test_dmp_permute
def test_dmp_permute():
f = dmp_normal([[1,0,0],[],[1,0],[],[1]], 1, ZZ)
g = dmp_normal([[1,0,0,0,0],[1,0,0],[1]], 1, ZZ)
assert dmp_permute(f, [0, 1], 1, ZZ) == f
assert dmp_permute(g, [0, 1], 1, ZZ) == g
assert dmp_permute(f, [1, 0], 1, ZZ) == g
assert dmp_permute(g, [1, 0], 1, ZZ) == f
示例5: test_dmp_swap
def test_dmp_swap():
f = dmp_normal([[1,0,0],[],[1,0],[],[1]], 1, ZZ)
g = dmp_normal([[1,0,0,0,0],[1,0,0],[1]], 1, ZZ)
assert dmp_swap(f, 1, 1, 1, ZZ) == f
assert dmp_swap(f, 0, 1, 1, ZZ) == g
assert dmp_swap(g, 0, 1, 1, ZZ) == f
raises(IndexError, "dmp_swap(f, -1, -7, 1, ZZ)")
示例6: test_dmp_diff
def test_dmp_diff():
assert dmp_diff([], 1, 0, ZZ) == []
assert dmp_diff([[]], 1, 1, ZZ) == [[]]
assert dmp_diff([[[]]], 1, 2, ZZ) == [[[]]]
assert dmp_diff([[[1], [2]]], 1, 2, ZZ) == [[[]]]
assert dmp_diff([[[1]], [[]]], 1, 2, ZZ) == [[[1]]]
assert dmp_diff([[[3]], [[1]], [[]]], 1, 2, ZZ) == [[[6]], [[1]]]
assert dmp_diff([1, -1, 0, 0, 2], 1, 0, ZZ) == \
dup_diff([1, -1, 0, 0, 2], 1, ZZ)
assert dmp_diff(f_6, 0, 3, ZZ) == f_6
assert dmp_diff(f_6, 1, 3, ZZ) == dmp_diff(f_6, 1, 3, ZZ)
assert dmp_diff(
f_6, 2, 3, ZZ) == dmp_diff(dmp_diff(f_6, 1, 3, ZZ), 1, 3, ZZ)
assert dmp_diff(f_6, 3, 3, ZZ) == dmp_diff(
dmp_diff(dmp_diff(f_6, 1, 3, ZZ), 1, 3, ZZ), 1, 3, ZZ)
K = FF(23)
F_6 = dmp_normal(f_6, 3, K)
assert dmp_diff(F_6, 0, 3, K) == F_6
assert dmp_diff(F_6, 1, 3, K) == dmp_diff(F_6, 1, 3, K)
assert dmp_diff(F_6, 2, 3, K) == dmp_diff(dmp_diff(F_6, 1, 3, K), 1, 3, K)
assert dmp_diff(F_6, 3, 3, K) == dmp_diff(
dmp_diff(dmp_diff(F_6, 1, 3, K), 1, 3, K), 1, 3, K)
示例7: test_dmp_ff_div
def test_dmp_ff_div():
raises(ZeroDivisionError, lambda: dmp_ff_div([[1,2],[3]], [[]], 1, QQ))
f = dmp_normal([[1], [], [1,0,0]], 1, QQ)
g = dmp_normal([[1], [-1,0]], 1, QQ)
q = [[QQ(1, 1)], [QQ(1, 1), QQ(0, 1)]]
r = [[QQ(2, 1), QQ(0, 1), QQ(0, 1)]]
assert dmp_ff_div(f, g, 1, QQ) == (q, r)
f = dmp_normal([[1], [], [1,0,0]], 1, QQ)
g = dmp_normal([[-1], [1,0]], 1, QQ)
q = [[QQ(-1, 1)], [QQ(-1, 1), QQ(0, 1)]]
r = [[QQ(2, 1), QQ(0, 1), QQ(0, 1)]]
assert dmp_ff_div(f, g, 1, QQ) == (q, r)
f = dmp_normal([[1], [], [1,0,0]], 1, QQ)
g = dmp_normal([[2], [-2,0]], 1, QQ)
q = [[QQ(1, 2)], [QQ(1, 2), QQ(0, 1)]]
r = [[QQ(2, 1), QQ(0, 1), QQ(0, 1)]]
assert dmp_ff_div(f, g, 1, QQ) == (q, r)
示例8: test_dmp_pdiv
def test_dmp_pdiv():
f = dmp_normal([[1], [], [1,0,0]], 1, ZZ)
g = dmp_normal([[1], [-1,0]], 1, ZZ)
q = dmp_normal([[1], [1, 0]], 1, ZZ)
r = dmp_normal([[2, 0, 0]], 1, ZZ)
assert dmp_pdiv(f, g, 1, ZZ) == (q, r)
assert dmp_pquo(f, g, 1, ZZ) == q
assert dmp_prem(f, g, 1, ZZ) == r
raises(ExactQuotientFailed, lambda: dmp_pexquo(f, g, 1, ZZ))
f = dmp_normal([[1], [], [1,0,0]], 1, ZZ)
g = dmp_normal([[2], [-2,0]], 1, ZZ)
q = dmp_normal([[2], [2, 0]], 1, ZZ)
r = dmp_normal([[8, 0, 0]], 1, ZZ)
assert dmp_pdiv(f, g, 1, ZZ) == (q, r)
assert dmp_pquo(f, g, 1, ZZ) == q
assert dmp_prem(f, g, 1, ZZ) == r
raises(ExactQuotientFailed, lambda: dmp_pexquo(f, g, 1, ZZ))
示例9: test_dmp_ground_trunc
def test_dmp_ground_trunc():
assert dmp_ground_trunc(f_0, ZZ(3), 2, ZZ) == \
dmp_normal(
[[[1, -1, 0], [-1]], [[]], [[1, -1, 0], [1, -1, 1], [1]]], 2, ZZ)
示例10: init_normal_DMF
def init_normal_DMF(num, den, lev, dom):
return DMF(dmp_normal(num, lev, dom),
dmp_normal(den, lev, dom), dom, lev)
示例11: init_normal_DMP
def init_normal_DMP(rep, lev, dom):
return DMP(dmp_normal(rep, lev, dom), dom, lev)
示例12: test_dmp_subresultants
def test_dmp_subresultants():
assert dmp_resultant([[]], [[]], 1, ZZ) == []
assert dmp_prs_resultant([[]], [[]], 1, ZZ)[0] == []
assert dmp_zz_collins_resultant([[]], [[]], 1, ZZ) == []
assert dmp_qq_collins_resultant([[]], [[]], 1, ZZ) == []
assert dmp_resultant([[ZZ(1)]], [[]], 1, ZZ) == []
assert dmp_resultant([[ZZ(1)]], [[]], 1, ZZ) == []
assert dmp_resultant([[ZZ(1)]], [[]], 1, ZZ) == []
assert dmp_resultant([[]], [[ZZ(1)]], 1, ZZ) == []
assert dmp_prs_resultant([[]], [[ZZ(1)]], 1, ZZ)[0] == []
assert dmp_zz_collins_resultant([[]], [[ZZ(1)]], 1, ZZ) == []
assert dmp_qq_collins_resultant([[]], [[ZZ(1)]], 1, ZZ) == []
f = dmp_normal([[3,0],[],[-1,0,0,-4]], 1, ZZ)
g = dmp_normal([[1],[1,0,0,0],[-9]], 1, ZZ)
a = dmp_normal([[3,0,0,0,0],[1,0,-27,4]], 1, ZZ)
b = dmp_normal([[-3,0,0,-12,1,0,-54,8,729,-216,16]], 1, ZZ)
r = dmp_LC(b, ZZ)
assert dmp_subresultants(f, g, 1, ZZ) == [f, g, a, b]
assert dmp_resultant(f, g, 1, ZZ) == r
assert dmp_prs_resultant(f, g, 1, ZZ)[0] == r
assert dmp_zz_collins_resultant(f, g, 1, ZZ) == r
assert dmp_qq_collins_resultant(f, g, 1, ZZ) == r
f = dmp_normal([[-1],[],[],[5]], 1, ZZ)
g = dmp_normal([[3,1],[],[]], 1, ZZ)
a = dmp_normal([[45,30,5]], 1, ZZ)
b = dmp_normal([[675,675,225,25]], 1, ZZ)
r = dmp_LC(b, ZZ)
assert dmp_subresultants(f, g, 1, ZZ) == [f, g, a]
assert dmp_resultant(f, g, 1, ZZ) == r
assert dmp_prs_resultant(f, g, 1, ZZ)[0] == r
assert dmp_zz_collins_resultant(f, g, 1, ZZ) == r
assert dmp_qq_collins_resultant(f, g, 1, ZZ) == r
f = [[[[[6]]]], [[[[-3]]], [[[-2]], [[]]]], [[[[1]], [[]]], [[[]]]]]
g = [[[[[1]]]], [[[[-1], [-1, 0]]]], [[[[1, 0], []]]]]
r = [[[[1]], [[-3], [-3, 0]], [[9, 0], []]], [[[-2], [-2, 0]], [[6],
[12, 0], [6, 0, 0]], [[-18, 0], [-18, 0, 0], []]], [[[4, 0],
[]], [[-12, 0], [-12, 0, 0], []], [[36, 0, 0], [], []]]]
assert dmp_zz_collins_resultant(f, g, 4, ZZ) == r
f = [[[[[QQ(1,1)]]]], [[[[QQ(-1,2)]]], [[[QQ(-1,3)]], [[]]]], [[[[QQ(1,6)]], [[]]], [[[]]]]]
g = [[[[[QQ(1,1)]]]], [[[[QQ(-1,1)], [QQ(-1,1), QQ(0, 1)]]]], [[[[QQ(1,1), QQ(0,1)], []]]]]
r = [[[[QQ(1,36)]], [[QQ(-1,12)], [QQ(-1,12), QQ(0,1)]], [[QQ(1,4), QQ(0,1)], []]],
[[[QQ(-1,18)], [QQ(-1,18), QQ(0,1)]], [[QQ(1,6)], [QQ(1,3), QQ(0,1)], [QQ(1,6),
QQ(0,1), QQ(0,1)]], [[QQ(-1,2), QQ(0,1)], [QQ(-1,2), QQ(0,1), QQ(0,1)], []]],
[[[QQ(1,9), QQ(0,1)], []], [[QQ(-1,3), QQ(0,1)], [QQ(-1,3), QQ(0,1), QQ(0,1)], []],
[[QQ(1,1), QQ(0,1), QQ(0,1)], [], []]]]
assert dmp_qq_collins_resultant(f, g, 4, QQ) == r
示例13: import
dmp_div, dmp_rem, dmp_quo, dmp_exquo,
dup_max_norm, dmp_max_norm,
dup_l1_norm, dmp_l1_norm,
dup_expand, dmp_expand,
)
from sympy.polys.polyerrors import (
ExactQuotientFailed,
)
from sympy.polys.specialpolys import f_0
from sympy.polys.domains import FF, ZZ, QQ
from sympy.utilities.pytest import raises
F_0 = dmp_mul_ground(dmp_normal(f_0, 2, QQ), QQ(1,7), 2, QQ)
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)
示例14: test_dmp_normal
def test_dmp_normal():
assert dmp_normal([[0],[],[0,2,1],[0],[11],[]], 1, ZZ) == \
[[ZZ(2),ZZ(1)],[],[ZZ(11)],[]]
示例15: dmp_add_term
v = dmp_add_term(u, dmp_ground(K(2), n-2), 0, n, K)
f = dmp_sqr(dmp_add_term([dmp_neg(v, n-1, K)], dmp_one(n-1, K), n+1, n, K), n, K)
g = dmp_sqr(dmp_add_term([v], dmp_one(n-1, K), n+1, n, K), n, K)
v = dmp_add_term(u, dmp_one(n-2, K), 0, n-1, K)
h = dmp_sqr(dmp_add_term([v], dmp_one(n-1, K), n+1, n, K), n, K)
return dmp_mul(f, h, n, K), dmp_mul(g, h, n, K), h
# A few useful polynomials from Wang's paper ('78).
f_0 = dmp_normal([
[[1,2,3], [2]],
[[3]],
[[4,5,6], [1,2,1], [1]]
], 2, ZZ)
f_1 = dmp_normal([
[[1, 0], []],
[[1, 0, 1], [20, 30], [1, 10, 0]],
[[1, 0], [30, 20], [1, 10, 1, 610], [20, 230, 300]],
[[1, 10, 0], [30, 320, 200], [600, 6000]]
], 2, ZZ)
f_2 = dmp_normal([
[[1], [1, 0], [1, 0, 0], [1, 0, 0, 0]],
[[]],
[[1], [1, 90], [90, 0]],
[[1, -11], [], [1, -11, 0, 0]],