def test_zzx_heu_gcd():
    f = [-352518131239247345597970242177235495263669787845475025293906825864749649589178600387510272,
         0, 0, 0, 0, 0, 0,
         46818041807522713962450042363465092040687472354933295397472942006618953623327997952,
         0, 0, 0, 0, 0, 0,
         378182690892293941192071663536490788434899030680411695933646320291525827756032,
         0, 0, 0, 0, 0, 0,
         112806468807371824947796775491032386836656074179286744191026149539708928,
         0, 0, 0, 0, 0, 0,
         -12278371209708240950316872681744825481125965781519138077173235712,
         0, 0, 0, 0, 0, 0,
         289127344604779611146960547954288113529690984687482920704,
         0, 0, 0, 0, 0, 0,
         19007977035740498977629742919480623972236450681,
         0, 0, 0, 0, 0, 0,
         311973482284542371301330321821976049]

    g = [365431878023781158602430064717380211405897160759702125019136,
         0, 0, 0, 0, 0, 0,
         197599133478719444145775798221171663643171734081650688,
         0, 0, 0, 0, 0, 0,
         -9504116979659010018253915765478924103928886144,
         0, 0, 0, 0, 0, 0,
         -311973482284542371301330321821976049]

    assert zzx_heu_gcd(f, zzx_diff(f))[0] == g
Example #2
0
def test_zzx_heu_gcd():
    f = [
        -352518131239247345597970242177235495263669787845475025293906825864749649589178600387510272,
        0, 0, 0, 0, 0, 0,
        46818041807522713962450042363465092040687472354933295397472942006618953623327997952,
        0, 0, 0, 0, 0, 0,
        378182690892293941192071663536490788434899030680411695933646320291525827756032,
        0, 0, 0, 0, 0, 0,
        112806468807371824947796775491032386836656074179286744191026149539708928,
        0, 0, 0, 0, 0, 0,
        -12278371209708240950316872681744825481125965781519138077173235712, 0,
        0, 0, 0, 0, 0,
        289127344604779611146960547954288113529690984687482920704, 0, 0, 0, 0,
        0, 0, 19007977035740498977629742919480623972236450681, 0, 0, 0, 0, 0,
        0, 311973482284542371301330321821976049
    ]

    g = [
        365431878023781158602430064717380211405897160759702125019136, 0, 0, 0,
        0, 0, 0, 197599133478719444145775798221171663643171734081650688, 0, 0,
        0, 0, 0, 0, -9504116979659010018253915765478924103928886144, 0, 0, 0,
        0, 0, 0, -311973482284542371301330321821976049
    ]

    assert zzx_heu_gcd(f, zzx_diff(f))[0] == 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,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)
Example #5
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)