def test_zzx_gcd():
    assert zzx_heu_gcd([], []) == ([], [], [])
    assert zzx_mod_gcd([], []) == ([], [], [])

    assert zzx_heu_gcd([2], []) == ([2], [1], [])
    assert zzx_mod_gcd([2], []) == ([2], [1], [])

    assert zzx_heu_gcd([], [2,4]) == ([2,4], [], [1])
    assert zzx_mod_gcd([], [2,4]) == ([2,4], [], [1])

    assert zzx_heu_gcd([2,4], []) == ([2,4], [1], [])
    assert zzx_mod_gcd([2,4], []) == ([2,4], [1], [])

    assert zzx_heu_gcd([2], [2]) == ([2], [1], [1])
    assert zzx_mod_gcd([2], [2]) == ([2], [1], [1])

    assert zzx_heu_gcd([1,2,1], [1]) == ([1], [1, 2, 1], [1])
    assert zzx_mod_gcd([1,2,1], [1]) == ([1], [1, 2, 1], [1])

    assert zzx_heu_gcd([1,2,1], [2]) == ([1], [1, 2, 1], [2])
    assert zzx_mod_gcd([1,2,1], [2]) == ([1], [1, 2, 1], [2])

    assert zzx_heu_gcd([2,4,2], [2]) == ([2], [1, 2, 1], [1])
    assert zzx_mod_gcd([2,4,2], [2]) == ([2], [1, 2, 1], [1])

    assert zzx_heu_gcd([2], [2,4,2]) == ([2], [1], [1, 2, 1])
    assert zzx_mod_gcd([2], [2,4,2]) == ([2], [1], [1, 2, 1])

    assert zzx_heu_gcd([2,4,2], [1,1]) == ([1, 1], [2, 2], [1])
    assert zzx_mod_gcd([2,4,2], [1,1]) == ([1, 1], [2, 2], [1])

    assert zzx_heu_gcd([1,1], [2,4,2]) == ([1, 1], [1], [2, 2])
    assert zzx_mod_gcd([1,1], [2,4,2]) == ([1, 1], [1], [2, 2])

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

    assert zzx_heu_gcd(f, g) == ([1], f, g)
    assert zzx_mod_gcd(f, g) == ([1], f, g)

    f = [1,8,21,22,8]
    g = [1,6,11,6]

    h = [1,3,2]

    cff = [1,5,4]
    cfg = [1,3]

    assert zzx_heu_gcd(f, g) == (h, cff, cfg)
    assert zzx_mod_gcd(f, g) == (h, cff, cfg)

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

    h = [1,0,2]

    cff = [1,0,-2]
    cfg = [1,0, 2]

    assert zzx_heu_gcd(f, g) == (h, cff, cfg)
    assert zzx_mod_gcd(f, g) == (h, cff, cfg)

    assert zzx_gcd(f, g) == h
    assert zzx_cofactors(f, g) == (h, cff, cfg)

    f,g,h = zzX_fateman_poly_F_3(4)
    H, cff, cfg = zzX_cofactors(f, g)

    assert H == h and zzX_mul(H, cff) == f \
                  and zzX_mul(H, cfg) == g
Beispiel #2
0
def test_zzx_gcd():
    assert zzx_heu_gcd([], []) == ([], [], [])
    assert zzx_mod_gcd([], []) == ([], [], [])

    assert zzx_heu_gcd([2], []) == ([2], [1], [])
    assert zzx_mod_gcd([2], []) == ([2], [1], [])

    assert zzx_heu_gcd([], [2, 4]) == ([2, 4], [], [1])
    assert zzx_mod_gcd([], [2, 4]) == ([2, 4], [], [1])

    assert zzx_heu_gcd([2, 4], []) == ([2, 4], [1], [])
    assert zzx_mod_gcd([2, 4], []) == ([2, 4], [1], [])

    assert zzx_heu_gcd([2], [2]) == ([2], [1], [1])
    assert zzx_mod_gcd([2], [2]) == ([2], [1], [1])

    assert zzx_heu_gcd([1, 2, 1], [1]) == ([1], [1, 2, 1], [1])
    assert zzx_mod_gcd([1, 2, 1], [1]) == ([1], [1, 2, 1], [1])

    assert zzx_heu_gcd([1, 2, 1], [2]) == ([1], [1, 2, 1], [2])
    assert zzx_mod_gcd([1, 2, 1], [2]) == ([1], [1, 2, 1], [2])

    assert zzx_heu_gcd([2, 4, 2], [2]) == ([2], [1, 2, 1], [1])
    assert zzx_mod_gcd([2, 4, 2], [2]) == ([2], [1, 2, 1], [1])

    assert zzx_heu_gcd([2], [2, 4, 2]) == ([2], [1], [1, 2, 1])
    assert zzx_mod_gcd([2], [2, 4, 2]) == ([2], [1], [1, 2, 1])

    assert zzx_heu_gcd([2, 4, 2], [1, 1]) == ([1, 1], [2, 2], [1])
    assert zzx_mod_gcd([2, 4, 2], [1, 1]) == ([1, 1], [2, 2], [1])

    assert zzx_heu_gcd([1, 1], [2, 4, 2]) == ([1, 1], [1], [2, 2])
    assert zzx_mod_gcd([1, 1], [2, 4, 2]) == ([1, 1], [1], [2, 2])

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

    assert zzx_heu_gcd(f, g) == ([1], f, g)
    assert zzx_mod_gcd(f, g) == ([1], f, g)

    f = [1, 8, 21, 22, 8]
    g = [1, 6, 11, 6]

    h = [1, 3, 2]

    cff = [1, 5, 4]
    cfg = [1, 3]

    assert zzx_heu_gcd(f, g) == (h, cff, cfg)
    assert zzx_mod_gcd(f, g) == (h, cff, cfg)

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

    h = [1, 0, 2]

    cff = [1, 0, -2]
    cfg = [1, 0, 2]

    assert zzx_heu_gcd(f, g) == (h, cff, cfg)
    assert zzx_mod_gcd(f, g) == (h, cff, cfg)

    assert zzx_gcd(f, g) == h
    assert zzx_cofactors(f, g) == (h, cff, cfg)

    f, g, h = zzX_fateman_poly_F_3(4)
    H, cff, cfg = zzX_cofactors(f, g)

    assert H == h and zzX_mul(H, cff) == f \
                  and zzX_mul(H, cfg) == g
def test_zzx_gcd():
    assert zzx_heu_gcd([], []) == ([], [], [])
    assert zzx_mod_gcd([], []) == ([], [], [])

    assert zzx_heu_gcd([2], []) == ([2], [1], [])
    assert zzx_mod_gcd([2], []) == ([2], [1], [])

    assert zzx_heu_gcd([2], [2]) == ([2], [1], [1])
    assert zzx_mod_gcd([2], [2]) == ([2], [1], [1])

    assert zzx_heu_gcd([1,2,1], [1]) == ([1], [1, 2, 1], [1])
    assert zzx_mod_gcd([1,2,1], [1]) == ([1], [1, 2, 1], [1])

    assert zzx_heu_gcd([1,2,1], [2]) == ([1], [1, 2, 1], [2])
    assert zzx_mod_gcd([1,2,1], [2]) == ([1], [1, 2, 1], [2])

    assert zzx_heu_gcd([2,4,2], [2]) == ([2], [1, 2, 1], [1])
    assert zzx_mod_gcd([2,4,2], [2]) == ([2], [1, 2, 1], [1])

    assert zzx_heu_gcd([2], [2,4,2]) == ([2], [1], [1, 2, 1])
    assert zzx_mod_gcd([2], [2,4,2]) == ([2], [1], [1, 2, 1])

    assert zzx_heu_gcd([2,4,2], [1,1]) == ([1, 1], [2, 2], [1])
    assert zzx_mod_gcd([2,4,2], [1,1]) == ([1, 1], [2, 2], [1])

    assert zzx_heu_gcd([1,1], [2,4,2]) == ([1, 1], [1], [2, 2])
    assert zzx_mod_gcd([1,1], [2,4,2]) == ([1, 1], [1], [2, 2])

    f = [1,8,21,22,8]
    g = [1,6,11,6]

    h = [1,3,2]

    cff = [1,5,4]
    cfg = [1,3]

    assert zzx_heu_gcd(f, g) == (h, cff, cfg)
    assert zzx_mod_gcd(f, g) == (h, cff, cfg)

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

    h = [1,0,2]

    cff = [1,0,-2]
    cfg = [1,0, 2]

    assert zzx_heu_gcd(f, g) == (h, cff, cfg)
    assert zzx_mod_gcd(f, g) == (h, cff, cfg)
def test_zzx_gcd():
    assert zzx_heu_gcd([], []) == ([], [], [])
    assert zzx_mod_gcd([], []) == ([], [], [])

    assert zzx_heu_gcd([2], []) == ([2], [1], [])
    assert zzx_mod_gcd([2], []) == ([2], [1], [])

    assert zzx_heu_gcd([2], [2]) == ([2], [1], [1])
    assert zzx_mod_gcd([2], [2]) == ([2], [1], [1])

    assert zzx_heu_gcd([1, 2, 1], [1]) == ([1], [1, 2, 1], [1])
    assert zzx_mod_gcd([1, 2, 1], [1]) == ([1], [1, 2, 1], [1])

    assert zzx_heu_gcd([1, 2, 1], [2]) == ([1], [1, 2, 1], [2])
    assert zzx_mod_gcd([1, 2, 1], [2]) == ([1], [1, 2, 1], [2])

    assert zzx_heu_gcd([2, 4, 2], [2]) == ([2], [1, 2, 1], [1])
    assert zzx_mod_gcd([2, 4, 2], [2]) == ([2], [1, 2, 1], [1])

    assert zzx_heu_gcd([2], [2, 4, 2]) == ([2], [1], [1, 2, 1])
    assert zzx_mod_gcd([2], [2, 4, 2]) == ([2], [1], [1, 2, 1])

    assert zzx_heu_gcd([2, 4, 2], [1, 1]) == ([1, 1], [2, 2], [1])
    assert zzx_mod_gcd([2, 4, 2], [1, 1]) == ([1, 1], [2, 2], [1])

    assert zzx_heu_gcd([1, 1], [2, 4, 2]) == ([1, 1], [1], [2, 2])
    assert zzx_mod_gcd([1, 1], [2, 4, 2]) == ([1, 1], [1], [2, 2])

    f = [1, 8, 21, 22, 8]
    g = [1, 6, 11, 6]

    h = [1, 3, 2]

    cff = [1, 5, 4]
    cfg = [1, 3]

    assert zzx_heu_gcd(f, g) == (h, cff, cfg)
    assert zzx_mod_gcd(f, g) == (h, cff, cfg)

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

    h = [1, 0, 2]

    cff = [1, 0, -2]
    cfg = [1, 0, 2]

    assert zzx_heu_gcd(f, g) == (h, cff, cfg)
    assert zzx_mod_gcd(f, g) == (h, cff, cfg)