def test_dmp_zz_factor():
    assert dmp_zz_factor([], 0, ZZ) == (0, [])
    assert dmp_zz_factor([7], 0, ZZ) == (7, [])
    assert dmp_zz_factor([-7], 0, ZZ) == (-7, [])

    assert dmp_zz_factor([[]], 1, ZZ) == (0, [])
    assert dmp_zz_factor([[7]], 1, ZZ) == (7, [])
    assert dmp_zz_factor([[-7]], 1, ZZ) == (-7, [])

    assert dmp_zz_factor([[1], []], 1, ZZ) == \
        (1, [([[1], []], 1)])

    assert dmp_zz_factor([[4], []], 1, ZZ) == \
        (4, [([[1], []], 1)])

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

    assert dmp_zz_factor([[1, 0], [1]], 1, ZZ) == \
        (1, [([[1, 0], [1]], 1)])

    assert dmp_zz_factor([[1,0,1]], 1, ZZ) == \
        (1, [([[1, 0, 1]], 1)])

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

    assert dmp_zz_factor([[1, 6, 9], [], [-1]], 1, ZZ) == \
        (1, [([[1, 3], [-1]], 1), ([[1, 3], [1]], 1)])

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

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

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

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

    assert dmp_zz_factor(f_1, 2, ZZ) == \
        (1, [([[[1]], [[1, 0], [20]]], 1),
             ([[[1], []], [[1, 10]]],  1),
             ([[[1, 0]], [[1], [30]]], 1)])

    assert dmp_zz_factor(f_2, 2, ZZ) == \
        (1, [([[[1], [], [1, 0, 0]], [[]], [[1], [90]]], 1),
             ([[[1], [1, 0]], [[]], [[]], [[1, -11]]],   1)])

    assert dmp_zz_factor(f_3, 2, ZZ) == \
        (1, [([[[1], [], []], [[1, 0, 0, 0, 1]], [[1, 0]]], 1),
             ([[[1]], [[]], [[1, 0], []], [[1], [1, 0, 0, 0], []]], 1)])

    assert dmp_zz_factor(f_4, 2, ZZ) == \
        (-1, [([[[1], [], [], []], [[1, 0, 0]]], 1),
              ([[[1, 0]], [[]], [[1, 0, 0], [], [], [], [5]]], 1),
              ([[[1], []], [[]], [[]], [[-1, 0, -3]]], 1),
              ([[[1], [], [], [], []], [[]], [[]], [[1, 0, 0]]], 1)])

    assert dmp_zz_factor(f_5, 2, ZZ) == \
        (-1, [([[[1]], [[1], [-1, 0]]], 3)])

    assert dmp_zz_factor(f_6, 3, ZZ) == \
        (1, [([[[[47]], [[]]], [[[1, 0, 0], [], [], [-1, 0, 0]]]], 1),
             ([[[[45]]], [[[]]], [[[]]], [[[-9]], [[-1]], [[]], [[3], [], [2, 0], []]]], 1)])

    assert dmp_zz_factor(w_1, 2, ZZ) == \
        (1, [([[[1], [], [-1, 0, 0]], [[]], [[1], [-1, 0, 0]]], 1),
             ([[[1, 0, 0], []], [[3, 0]], [[2], []]], 1),
             ([[[4], [4, 0]], [[1, 0], []], [[-1]]], 1)])

    f = [[-12, 0], [], [], [], [240, 0, 0, 0], [], [-768, 0, 0, 0, 0], [],
         [1080, 0, 0, 0, 0, 0], [], [-768, 0, 0, 0, 0, 0, 0], [],
         [240, 0, 0, 0, 0, 0, 0, 0], [], [], [],
         [-12, 0, 0, 0, 0, 0, 0, 0, 0, 0]]

    assert dmp_zz_factor(f, 1, ZZ) == \
        (-12, [([[1, 0]], 1),
               ([[1], [], [-1, 0]], 6),
               ([[1], [], [6, 0], [], [1, 0, 0]], 1)])
Beispiel #2
0
def test_dmp_zz_factor():
    assert dmp_zz_factor([], 0, ZZ) == (0, [])
    assert dmp_zz_factor([7], 0, ZZ) == (7, [])
    assert dmp_zz_factor([-7], 0, ZZ) == (-7, [])

    assert dmp_zz_factor([[]], 1, ZZ) == (0, [])
    assert dmp_zz_factor([[7]], 1, ZZ) == (7, [])
    assert dmp_zz_factor([[-7]], 1, ZZ) == (-7, [])

    assert dmp_zz_factor([[1], []], 1, ZZ) == \
        (1, [([[1], []], 1)])

    assert dmp_zz_factor([[4], []], 1, ZZ) == \
        (4, [([[1], []], 1)])

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

    assert dmp_zz_factor([[1, 0], [1]], 1, ZZ) == \
        (1, [([[1, 0], [1]], 1)])

    assert dmp_zz_factor([[1,0,1]], 1, ZZ) == \
        (1, [([[1, 0, 1]], 1)])

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

    assert dmp_zz_factor([[1, 6, 9], [], [-1]], 1, ZZ) == \
        (1, [([[1, 3], [-1]], 1), ([[1, 3], [1]], 1)])

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

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

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

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

    assert dmp_zz_factor(f_1, 2, ZZ) == \
        (1, [([[[1]], [[1, 0], [20]]], 1),
             ([[[1], []], [[1, 10]]],  1),
             ([[[1, 0]], [[1], [30]]], 1)])

    assert dmp_zz_factor(f_2, 2, ZZ) == \
        (1, [([[[1], [], [1, 0, 0]], [[]], [[1], [90]]], 1),
             ([[[1], [1, 0]], [[]], [[]], [[1, -11]]],   1)])

    assert dmp_zz_factor(f_3, 2, ZZ) == \
        (1, [([[[1], [], []], [[1, 0, 0, 0, 1]], [[1, 0]]], 1),
             ([[[1]], [[]], [[1, 0], []], [[1], [1, 0, 0, 0], []]], 1)])

    assert dmp_zz_factor(f_4, 2, ZZ) == \
        (-1, [([[[1], [], [], []], [[1, 0, 0]]], 1),
              ([[[1, 0]], [[]], [[1, 0, 0], [], [], [], [5]]], 1),
              ([[[1], []], [[]], [[]], [[-1, 0, -3]]], 1),
              ([[[1], [], [], [], []], [[]], [[]], [[1, 0, 0]]], 1)])

    assert dmp_zz_factor(f_5, 2, ZZ) == \
        (-1, [([[[1]], [[1], [-1, 0]]], 3)])

    assert dmp_zz_factor(f_6, 3, ZZ) == \
        (1, [([[[[47]], [[]]], [[[1, 0, 0], [], [], [-1, 0, 0]]]], 1),
             ([[[[45]]], [[[]]], [[[]]], [[[-9]], [[-1]], [[]], [[3], [], [2, 0], []]]], 1)])

    assert dmp_zz_factor(w_1, 2, ZZ) == \
        (1, [([[[1], [], [-1, 0, 0]], [[]], [[1], [-1, 0, 0]]], 1),
             ([[[1, 0, 0], []], [[3, 0]], [[2], []]], 1),
             ([[[4], [4, 0]], [[1, 0], []], [[-1]]], 1)])

    f = [[-12, 0], [],
         [], [],
         [240, 0, 0, 0], [],
         [-768, 0, 0, 0, 0], [],
         [1080, 0, 0, 0, 0, 0], [],
         [-768, 0, 0, 0, 0, 0, 0], [],
         [240, 0, 0, 0, 0, 0, 0, 0], [],
         [], [],
         [-12, 0, 0, 0, 0, 0, 0, 0, 0, 0]]

    assert dmp_zz_factor(f, 1, ZZ) == \
        (-12, [([[1, 0]], 1),
               ([[1], [], [-1, 0]], 6),
               ([[1], [], [6, 0], [], [1, 0, 0]], 1)])