• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python densebasic.dup_from_raw_dict函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sympy.polys.densebasic.dup_from_raw_dict函数的典型用法代码示例。如果您正苦于以下问题:Python dup_from_raw_dict函数的具体用法?Python dup_from_raw_dict怎么用?Python dup_from_raw_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dup_from_raw_dict函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_dup_from_to_dict

def test_dup_from_to_dict():
    assert dup_from_raw_dict({}, ZZ) == []
    assert dup_from_dict({}, ZZ) == []

    assert dup_to_raw_dict([]) == {}
    assert dup_to_dict([]) == {}

    assert dup_to_raw_dict([], ZZ, zero=True) == {0: ZZ(0)}
    assert dup_to_dict([], ZZ, zero=True) == {(0,): ZZ(0)}

    f = [3,0,0,2,0,0,0,0,8]
    g = {8: 3, 5: 2, 0: 8}
    h = {(8,): 3, (5,): 2, (0,): 8}

    assert dup_from_raw_dict(g, ZZ) == f
    assert dup_from_dict(h, ZZ) == f

    assert dup_to_raw_dict(f) == g
    assert dup_to_dict(f) == h

    K = ZZ['x','y']

    f = [K([[3]]),K([[]]),K([[2]]),K([[]]),K([[]]),K([[8]])]
    g = {5: K([[3]]), 3: K([[2]]), 0: K([[8]])}
    h = {(5,): K([[3]]), (3,): K([[2]]), (0,): K([[8]])}

    assert dup_from_raw_dict(g, K) == f
    assert dup_from_dict(h, K) == f

    assert dup_to_raw_dict(f) == g
    assert dup_to_dict(f) == h
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:31,代码来源:test_densebasic.py


示例2: test_dup_from_to_dict

def test_dup_from_to_dict():
    assert dup_from_raw_dict({}, ZZ) == []
    assert dup_from_dict({}, ZZ) == []

    assert dup_to_raw_dict([]) == {}
    assert dup_to_dict([]) == {}

    assert dup_to_raw_dict([], ZZ, zero=True) == {0: ZZ(0)}
    assert dup_to_dict([], ZZ, zero=True) == {(0,): ZZ(0)}

    f = [3, 0, 0, 2, 0, 0, 0, 0, 8]
    g = {8: 3, 5: 2, 0: 8}
    h = {(8,): 3, (5,): 2, (0,): 8}

    assert dup_from_raw_dict(g, ZZ) == f
    assert dup_from_dict(h, ZZ) == f

    assert dup_to_raw_dict(f) == g
    assert dup_to_dict(f) == h

    R, x,y = ring("x,y", ZZ)
    K = R.to_domain()

    f = [R(3), R(0), R(2), R(0), R(0), R(8)]
    g = {5: R(3), 3: R(2), 0: R(8)}
    h = {(5,): R(3), (3,): R(2), (0,): R(8)}

    assert dup_from_raw_dict(g, K) == f
    assert dup_from_dict(h, K) == f

    assert dup_to_raw_dict(f) == g
    assert dup_to_dict(f) == h
开发者ID:AALEKH,项目名称:sympy,代码行数:32,代码来源:test_densebasic.py


示例3: test_dup_isolate_real_roots_list

def test_dup_isolate_real_roots_list():
    assert dup_isolate_real_roots_list([[1, 1,0], [1,0]], ZZ) == \
        [((-QQ(1), -QQ(1)), {0: 1}), ((QQ(0), QQ(0)), {0: 1, 1: 1})]
    assert dup_isolate_real_roots_list([[1,-1,0], [1,0]], ZZ) == \
        [((QQ(0), QQ(0)), {0: 1, 1: 1}), ((QQ(1), QQ(1)), {0: 1})]

    f = dup_from_raw_dict({5: ZZ(1), 0: -ZZ(200)}, ZZ)
    g = dup_from_raw_dict({5: ZZ(1), 0: -ZZ(201)}, ZZ)

    assert dup_isolate_real_roots_list([f, g], ZZ) == \
        [((QQ(75,26), QQ(101,35)), {0: 1}), ((QQ(283,98), QQ(26,9)), {1: 1})]

    f = dup_from_raw_dict({5: -QQ(1,200), 0: QQ(1)}, QQ)
    g = dup_from_raw_dict({5: -QQ(1,201), 0: QQ(1)}, QQ)

    assert dup_isolate_real_roots_list([f, g], QQ) == \
        [((QQ(75,26), QQ(101,35)), {0: 1}), ((QQ(283,98), QQ(26,9)), {1: 1})]

    assert dup_isolate_real_roots_list([[1,1], [1,2], [1,-1], [1,1], [1,-1], [1,-1]], ZZ) == \
        [((-QQ(2), -QQ(2)), {1: 1}), ((-QQ(1), -QQ(1)), {0: 1, 3: 1}), ((QQ(1), QQ(1)), {2: 1, 4: 1, 5: 1})]

    assert dup_isolate_real_roots_list([[1,1], [1,2], [1,-1], [1,1], [1,-1], [1,2]], ZZ) == \
        [((-QQ(2), -QQ(2)), {1: 1, 5: 1}), ((-QQ(1), -QQ(1)), {0: 1, 3: 1}), ((QQ(1), QQ(1)), {2: 1, 4: 1})]

    f, g = [1, 0, -4, 0, 4], [1, -1]

    assert dup_isolate_real_roots_list([f, g], ZZ, inf=QQ(7,4)) == []
    assert dup_isolate_real_roots_list([f, g], ZZ, inf=QQ(7,5)) == [((QQ(7,5), QQ(3,2)), {0: 2})]
    assert dup_isolate_real_roots_list([f, g], ZZ, sup=QQ(7,5)) == [((-2, -1), {0: 2}), ((1, 1), {1: 1})]
    assert dup_isolate_real_roots_list([f, g], ZZ, sup=QQ(7,4)) == [((-2, -1), {0: 2}), ((1, 1), {1: 1}), ((1, QQ(3,2)), {0: 2})]
    assert dup_isolate_real_roots_list([f, g], ZZ, sup=-QQ(7,4)) == []
    assert dup_isolate_real_roots_list([f, g], ZZ, sup=-QQ(7,5)) == [((-QQ(3,2), -QQ(7,5)), {0: 2})]
    assert dup_isolate_real_roots_list([f, g], ZZ, inf=-QQ(7,5)) == [((1, 1), {1: 1}), ((1, 2), {0: 2})]
    assert dup_isolate_real_roots_list([f, g], ZZ, inf=-QQ(7,4)) == [((-QQ(3,2), -1), {0: 2}), ((1, 1), {1: 1}), ((1, 2), {0: 2})]

    f, g = [2, 0, -1], [1, 0, -2]

    assert dup_isolate_real_roots_list([f, g], ZZ) == \
        [((-QQ(2), -QQ(1)), {1: 1}), ((-QQ(1), QQ(0)), {0: 1}), ((QQ(0), QQ(1)), {0: 1}), ((QQ(1), QQ(2)), {1: 1})]
    assert dup_isolate_real_roots_list([f, g], ZZ, strict=True) == \
        [((-QQ(3,2), -QQ(4,3)), {1: 1}), ((-QQ(1), -QQ(2,3)), {0: 1}), ((QQ(2,3), QQ(1)), {0: 1}), ((QQ(4,3), QQ(3,2)), {1: 1})]

    f, g = [1, 0, -2], [1, -1, -2, 2]

    assert dup_isolate_real_roots_list([f, g], ZZ) == \
        [((-QQ(2), -QQ(1)), {1: 1, 0: 1}), ((QQ(1), QQ(1)), {1: 1}), ((QQ(1), QQ(2)), {1: 1, 0: 1})]

    f, g = [1, 0, -2, 0], [1, -1, -2, 2, 0, 0]

    assert dup_isolate_real_roots_list([f, g], ZZ) == \
        [((-QQ(2), -QQ(1)), {1: 1, 0: 1}), ((QQ(0), QQ(0)), {0: 1, 1: 2}), ((QQ(1), QQ(1)), {1: 1}), ((QQ(1), QQ(2)), {1: 1, 0: 1})]

    f, g = [1, -3, -1, 11, -8, -8, 12, -4, 0, 0], [1, -2, 3, -4, 2, 0]

    assert dup_isolate_real_roots_list([f, g], ZZ, basis=False) == \
        [((-2, -1), {0: 2}), ((0, 0), {0: 2, 1: 1}), ((1, 1), {0: 3, 1: 2}), ((1, 2), {0: 2})]
    assert dup_isolate_real_roots_list([f, g], ZZ, basis=True) == \
        [((-2, -1), {0: 2}, [1, 0, -2]), ((0, 0), {0: 2, 1: 1}, [1, 0]), ((1, 1), {0: 3, 1: 2}, [1, -1]), ((1, 2), {0: 2}, [1, 0, -2])]

    raises(DomainError, "dup_isolate_real_roots_list([[EX(1), EX(2)]], EX)")
开发者ID:101man,项目名称:sympy,代码行数:60,代码来源:test_rootisolation.py


示例4: test_dup_zz_hensel_lift

def test_dup_zz_hensel_lift():
    f = dup_from_raw_dict({4:1, 0:-1}, ZZ)

    f1 = dup_from_raw_dict({1:1, 0:-1}, ZZ)
    f2 = dup_from_raw_dict({1:1, 0:-2}, ZZ)
    f3 = dup_from_raw_dict({1:1, 0: 2}, ZZ)
    f4 = dup_from_raw_dict({1:1, 0: 1}, ZZ)

    ff_list = dup_zz_hensel_lift(5, f, [f1, f2, f3, f4], 4, ZZ)

    assert dup_to_raw_dict(ff_list[0]) == {0: -1,   1: 1}
    assert dup_to_raw_dict(ff_list[1]) == {0: -182, 1: 1}
    assert dup_to_raw_dict(ff_list[2]) == {0:  182, 1: 1}
    assert dup_to_raw_dict(ff_list[3]) == {0:  1,   1: 1}
开发者ID:ENuge,项目名称:sympy,代码行数:14,代码来源:test_factortools.py


示例5: _dup_right_decompose

def _dup_right_decompose(f, s, K):
    """Helper function for :func:`_dup_decompose`."""
    n = len(f) - 1
    lc = dup_LC(f, K)

    f = dup_to_raw_dict(f)
    g = { s: K.one }

    r = n // s

    for i in range(1, s):
        coeff = K.zero

        for j in range(0, i):
            if not n + j - i in f:
                continue

            if not s - j in g:
                continue

            fc, gc = f[n + j - i], g[s - j]
            coeff += (i - r*j)*fc*gc

        g[s - i] = K.quo(coeff, i*r*lc)

    return dup_from_raw_dict(g, K)
开发者ID:asmeurer,项目名称:sympy,代码行数:26,代码来源:densetools.py


示例6: test_dup_integrate

def test_dup_integrate():
    assert dup_integrate([], 1, QQ) == []
    assert dup_integrate([], 2, QQ) == []

    assert dup_integrate([QQ(1)], 1, QQ) == [QQ(1), QQ(0)]
    assert dup_integrate([QQ(1)], 2, QQ) == [QQ(1, 2), QQ(0), QQ(0)]

    assert dup_integrate([QQ(1), QQ(2), QQ(3)], 0, QQ) == [QQ(1), QQ(2), QQ(3)]
    assert dup_integrate([QQ(1), QQ(2), QQ(3)], 1, QQ) == [QQ(1, 3), QQ(1), QQ(3), QQ(0)]
    assert dup_integrate([QQ(1), QQ(2), QQ(3)], 2, QQ) == [QQ(1, 12), QQ(1, 3), QQ(3, 2), QQ(0), QQ(0)]
    assert dup_integrate([QQ(1), QQ(2), QQ(3)], 3, QQ) == [QQ(1, 60), QQ(1, 12), QQ(1, 2), QQ(0), QQ(0), QQ(0)]

    assert dup_integrate(dup_from_raw_dict({29: QQ(17)}, QQ), 3, QQ) == dup_from_raw_dict({32: QQ(17, 29760)}, QQ)

    assert dup_integrate(dup_from_raw_dict({29: QQ(17), 5: QQ(1, 2)}, QQ), 3, QQ) == dup_from_raw_dict(
        {32: QQ(17, 29760), 8: QQ(1, 672)}, QQ
    )
开发者ID:hitej,项目名称:meta-core,代码行数:17,代码来源:test_densetools.py


示例7: test_dup_zz_hensel_step

def test_dup_zz_hensel_step():
    f = dup_from_raw_dict({4:1, 0:-1}, ZZ)

    g = dup_from_raw_dict({3:1, 2:2, 1:-1, 0:-2}, ZZ)
    h = dup_from_raw_dict({1:1, 0:-2}, ZZ)
    s = dup_from_raw_dict({0:-2}, ZZ)
    t = dup_from_raw_dict({2:2, 1:-2, 0:-1}, ZZ)

    G, H, S, T = dup_zz_hensel_step(5, f, g, h, s, t, ZZ)

    assert G == dup_from_raw_dict({3:1, 2:7, 1:-1, 0:-7}, ZZ)
    assert H == dup_from_raw_dict({1:1, 0:-7}, ZZ)
    assert S == dup_from_raw_dict({0:8}, ZZ)
    assert T == dup_from_raw_dict({2:-8, 1:-12, 0:-1}, ZZ)
开发者ID:ENuge,项目名称:sympy,代码行数:14,代码来源:test_factortools.py


示例8: _dup_left_decompose

def _dup_left_decompose(f, h, K):
    """Helper function for :func:`_dup_decompose`."""
    g, i = {}, 0

    while f:
        q, r = dup_div(f, h, K)

        if dup_degree(r) > 0:
            return None
        else:
            g[i] = dup_LC(r, K)
            f, i = q, i + 1

    return dup_from_raw_dict(g, K)
开发者ID:asmeurer,项目名称:sympy,代码行数:14,代码来源:densetools.py


示例9: test_dup_deflate

def test_dup_deflate():
    assert dup_deflate([], ZZ) == (1, [])
    assert dup_deflate([2], ZZ) == (1, [2])
    assert dup_deflate([1, 2, 3], ZZ) == (1, [1, 2, 3])
    assert dup_deflate([1, 0, 2, 0, 3], ZZ) == (2, [1, 2, 3])

    assert dup_deflate(dup_from_raw_dict({7: 1, 1: 1}, ZZ), ZZ) == (1, [1, 0, 0, 0, 0, 0, 1, 0])
    assert dup_deflate(dup_from_raw_dict({7: 1, 0: 1}, ZZ), ZZ) == (7, [1, 1])
    assert dup_deflate(dup_from_raw_dict({7: 1, 3: 1}, ZZ), ZZ) == (1, [1, 0, 0, 0, 1, 0, 0, 0])

    assert dup_deflate(dup_from_raw_dict({7: 1, 4: 1}, ZZ), ZZ) == (1, [1, 0, 0, 1, 0, 0, 0, 0])
    assert dup_deflate(dup_from_raw_dict({8: 1, 4: 1}, ZZ), ZZ) == (4, [1, 1, 0])

    assert dup_deflate(dup_from_raw_dict({8: 1}, ZZ), ZZ) == (8, [1, 0])
    assert dup_deflate(dup_from_raw_dict({7: 1}, ZZ), ZZ) == (7, [1, 0])
    assert dup_deflate(dup_from_raw_dict({1: 1}, ZZ), ZZ) == (1, [1, 0])
开发者ID:hector1618,项目名称:sympy,代码行数:16,代码来源:test_densebasic.py


示例10: test_dup_zz_cyclotomic_factor

def test_dup_zz_cyclotomic_factor():
    assert dup_zz_cyclotomic_factor([], ZZ) is None
    assert dup_zz_cyclotomic_factor([1], ZZ) is None

    f = dup_from_raw_dict({10:2, 0:-1}, ZZ)
    assert dup_zz_cyclotomic_factor(f, ZZ) is None
    f = dup_from_raw_dict({10:1, 0:-3}, ZZ)
    assert dup_zz_cyclotomic_factor(f, ZZ) is None
    f = dup_from_raw_dict({10:1, 5:1, 0:-1}, ZZ)
    assert dup_zz_cyclotomic_factor(f, ZZ) is None

    f = dup_from_raw_dict({1:1,0:1}, ZZ)
    assert dup_zz_cyclotomic_factor(f, ZZ) == \
         [[1, 1]]

    f = dup_from_raw_dict({1:1,0:-1}, ZZ)
    assert dup_zz_cyclotomic_factor(f, ZZ) == \
        [[1, -1]]

    f = dup_from_raw_dict({2:1,0:1}, ZZ)
    assert dup_zz_cyclotomic_factor(f, ZZ) == \
        [[1, 0, 1]]

    f = dup_from_raw_dict({2:1,0:-1}, ZZ)
    assert dup_zz_cyclotomic_factor(f, ZZ) == \
        [[1,-1],
         [1, 1]]

    f = dup_from_raw_dict({27:1,0:1}, ZZ)
    assert dup_zz_cyclotomic_factor(f, ZZ) == \
        [[1, 1],
         [1, -1, 1],
         [1, 0, 0, -1, 0, 0, 1],
         [1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]

    f = dup_from_raw_dict({27:1,0:-1}, ZZ)
    assert dup_zz_cyclotomic_factor(f, ZZ) == \
        [[1, -1],
         [1, 1, 1],
         [1, 0, 0, 1, 0, 0, 1],
         [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]
开发者ID:ENuge,项目名称:sympy,代码行数:41,代码来源:test_factortools.py


示例11: dmp_fateman_poly_F_3

def dmp_fateman_poly_F_3(n, K):
    """Fateman's GCD benchmark: sparse inputs (deg f ~ vars f) """
    u = dup_from_raw_dict({n+1: K.one}, K)

    for i in xrange(0, n-1):
        u = dmp_add_term([u], dmp_one(i, K), n+1, i+1, K)

    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
开发者ID:addisonc,项目名称:sympy,代码行数:17,代码来源:specialpolys.py


示例12: test_dup_zz_factor

def test_dup_zz_factor():
    assert dup_zz_factor([], ZZ) == (0, [])
    assert dup_zz_factor([7], ZZ) == (7, [])
    assert dup_zz_factor([-7], ZZ) == (-7, [])

    assert dup_zz_factor_sqf([], ZZ) == (0, [])
    assert dup_zz_factor_sqf([7], ZZ) == (7, [])
    assert dup_zz_factor_sqf([-7], ZZ) == (-7, [])

    assert dup_zz_factor([2,4], ZZ) == \
        (2, [([1, 2], 1)])
    assert dup_zz_factor_sqf([2,4], ZZ) == \
        (2, [([1, 2], 1)])

    f = [1,0,0,1,1]

    for i in xrange(0, 20):
        assert dup_zz_factor(f, ZZ) == (1, [(f, 1)])

    assert dup_zz_factor([1,2,2], ZZ) == \
        (1, [([1,2,2], 1)])

    assert dup_zz_factor([18,12,2], ZZ) == \
        (2, [([3, 1], 2)])

    assert dup_zz_factor([-9,0,1], ZZ) == \
        (-1, [([3,-1], 1),
              ([3, 1], 1)])

    assert dup_zz_factor_sqf([-9,0,1], ZZ) == \
        (-1, [[3,-1],
              [3, 1]])

    assert dup_zz_factor([1,-6,11,-6], ZZ) == \
        (1, [([1,-3], 1),
             ([1,-2], 1),
             ([1,-1], 1)])

    assert dup_zz_factor_sqf([1,-6,11,-6], ZZ) == \
        (1, [[1,-3],
             [1,-2],
             [1,-1]])

    assert dup_zz_factor([3,10,13,10], ZZ) == \
        (1, [([1,2], 1),
             ([3,4,5], 1)])

    assert dup_zz_factor_sqf([3,10,13,10], ZZ) == \
        (1, [[1,2],
             [3,4,5]])

    assert dup_zz_factor([-1,0,0,0,1,0,0], ZZ) == \
        (-1, [([1,-1], 1),
              ([1, 1], 1),
              ([1, 0], 2),
              ([1, 0, 1], 1)])

    f = [1080, 5184, 2099, 744, 2736, -648, 129, 0, -324]

    assert dup_zz_factor(f, ZZ) == \
        (1, [([5, 24, 9, 0, 12], 1),
             ([216, 0, 31, 0, -27], 1)])

    f = [-29802322387695312500000000000000000000,
          0, 0, 0, 0,
          2980232238769531250000000000000000,
          0, 0, 0, 0,
          1743435859680175781250000000000,
          0, 0, 0, 0,
          114142894744873046875000000,
          0, 0, 0, 0,
          -210106372833251953125,
          0, 0, 0, 0,
          95367431640625]

    assert dup_zz_factor(f, ZZ) == \
        (-95367431640625, [([5, -1], 1),
                           ([100, 10, -1], 2),
                           ([625, 125, 25, 5, 1], 1),
                           ([10000, -3000, 400, -20, 1], 2),
                           ([10000,  2000, 400,  30, 1], 2)])

    f = dup_from_raw_dict({10:1, 0:-1}, ZZ)

    config.setup('USE_CYCLOTOMIC_FACTOR', True)
    F_0 = dup_zz_factor(f, ZZ)

    config.setup('USE_CYCLOTOMIC_FACTOR', False)
    F_1 = dup_zz_factor(f, ZZ)

    assert F_0 == F_1 == \
        (1, [([1,-1], 1),
             ([1, 1], 1),
             ([1,-1, 1,-1, 1], 1),
             ([1, 1, 1, 1, 1], 1)])

    config.setup('USE_CYCLOTOMIC_FACTOR')

    f = dup_from_raw_dict({10:1, 0:1}, ZZ)

#.........这里部分代码省略.........
开发者ID:ENuge,项目名称:sympy,代码行数:101,代码来源:test_factortools.py



注:本文中的sympy.polys.densebasic.dup_from_raw_dict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python densebasic.dup_inflate函数代码示例发布时间:2022-05-27
下一篇:
Python densebasic.dup_degree函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap