def test_dup_gcd(): assert dup_zz_heu_gcd([], [], ZZ) == ([], [], []) assert dup_rr_prs_gcd([], [], ZZ) == ([], [], []) assert dup_zz_heu_gcd([2], [], ZZ) == ([2], [1], []) assert dup_rr_prs_gcd([2], [], ZZ) == ([2], [1], []) assert dup_zz_heu_gcd([-2], [], ZZ) == ([2], [-1], []) assert dup_rr_prs_gcd([-2], [], ZZ) == ([2], [-1], []) assert dup_zz_heu_gcd([], [-2], ZZ) == ([2], [], [-1]) assert dup_rr_prs_gcd([], [-2], ZZ) == ([2], [], [-1]) assert dup_zz_heu_gcd([], [2, 4], ZZ) == ([2, 4], [], [1]) assert dup_rr_prs_gcd([], [2, 4], ZZ) == ([2, 4], [], [1]) assert dup_zz_heu_gcd([2, 4], [], ZZ) == ([2, 4], [1], []) assert dup_rr_prs_gcd([2, 4], [], ZZ) == ([2, 4], [1], []) assert dup_zz_heu_gcd([2], [2], ZZ) == ([2], [1], [1]) assert dup_rr_prs_gcd([2], [2], ZZ) == ([2], [1], [1]) assert dup_zz_heu_gcd([-2], [2], ZZ) == ([2], [-1], [1]) assert dup_rr_prs_gcd([-2], [2], ZZ) == ([2], [-1], [1]) assert dup_zz_heu_gcd([2], [-2], ZZ) == ([2], [1], [-1]) assert dup_rr_prs_gcd([2], [-2], ZZ) == ([2], [1], [-1]) assert dup_zz_heu_gcd([-2], [-2], ZZ) == ([2], [-1], [-1]) assert dup_rr_prs_gcd([-2], [-2], ZZ) == ([2], [-1], [-1]) assert dup_zz_heu_gcd([1, 2, 1], [1], ZZ) == ([1], [1, 2, 1], [1]) assert dup_rr_prs_gcd([1, 2, 1], [1], ZZ) == ([1], [1, 2, 1], [1]) assert dup_zz_heu_gcd([1, 2, 1], [2], ZZ) == ([1], [1, 2, 1], [2]) assert dup_rr_prs_gcd([1, 2, 1], [2], ZZ) == ([1], [1, 2, 1], [2]) assert dup_zz_heu_gcd([2, 4, 2], [2], ZZ) == ([2], [1, 2, 1], [1]) assert dup_rr_prs_gcd([2, 4, 2], [2], ZZ) == ([2], [1, 2, 1], [1]) assert dup_zz_heu_gcd([2], [2, 4, 2], ZZ) == ([2], [1], [1, 2, 1]) assert dup_rr_prs_gcd([2], [2, 4, 2], ZZ) == ([2], [1], [1, 2, 1]) assert dup_zz_heu_gcd([2, 4, 2], [1, 1], ZZ) == ([1, 1], [2, 2], [1]) assert dup_rr_prs_gcd([2, 4, 2], [1, 1], ZZ) == ([1, 1], [2, 2], [1]) assert dup_zz_heu_gcd([1, 1], [2, 4, 2], ZZ) == ([1, 1], [1], [2, 2]) assert dup_rr_prs_gcd([1, 1], [2, 4, 2], ZZ) == ([1, 1], [1], [2, 2]) f, g = [1, -31], [1, 0] assert dup_zz_heu_gcd(f, g, ZZ) == ([1], f, g) assert dup_rr_prs_gcd(f, g, ZZ) == ([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 dup_zz_heu_gcd(f, g, ZZ) == (h, cff, cfg) assert dup_rr_prs_gcd(f, g, ZZ) == (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 dup_zz_heu_gcd(f, g, ZZ) == (h, cff, cfg) assert dup_rr_prs_gcd(f, g, ZZ) == (h, cff, cfg) f = [1, 0, 1, 0, -3, -3, 8, 2, -5] g = [3, 0, 5, -0, -4, -9, 21] h = [1] cff = f cfg = g assert dup_zz_heu_gcd(f, g, ZZ) == (h, cff, cfg) assert dup_rr_prs_gcd(f, g, ZZ) == (h, cff, cfg) f = dup_normal([1, 0, 1, 0, -3, -3, 8, 2, -5], QQ) g = dup_normal([3, 0, 5, -0, -4, -9, 21], QQ) h = dup_normal([1], QQ) assert dup_qq_heu_gcd(f, g, QQ) == (h, cff, cfg) assert dup_ff_prs_gcd(f, g, QQ) == (h, cff, cfg) 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 ] f = dup_normal(f, ZZ) g = dup_normal(g, ZZ) assert dup_zz_heu_gcd(f, dup_diff(f, 1, ZZ), ZZ)[0] == g assert dup_rr_prs_gcd(f, dup_diff(f, 1, ZZ), ZZ)[0] == g f = [QQ(1, 2), QQ(1), QQ(1, 2)] g = [QQ(1, 2), QQ(1, 2)] h = [QQ(1), QQ(1)] assert dup_qq_heu_gcd(f, g, QQ) == (h, g, [QQ(1, 2)]) assert dup_ff_prs_gcd(f, g, QQ) == (h, g, [QQ(1, 2)])
def test_dup_gcd(): assert dup_zz_heu_gcd([], [], ZZ) == ([], [], []) assert dup_rr_prs_gcd([], [], ZZ) == ([], [], []) assert dup_zz_heu_gcd([2], [], ZZ) == ([2], [1], []) assert dup_rr_prs_gcd([2], [], ZZ) == ([2], [1], []) assert dup_zz_heu_gcd([-2], [], ZZ) == ([2], [-1], []) assert dup_rr_prs_gcd([-2], [], ZZ) == ([2], [-1], []) assert dup_zz_heu_gcd([], [-2], ZZ) == ([2], [], [-1]) assert dup_rr_prs_gcd([], [-2], ZZ) == ([2], [], [-1]) assert dup_zz_heu_gcd([], [2,4], ZZ) == ([2,4], [], [1]) assert dup_rr_prs_gcd([], [2,4], ZZ) == ([2,4], [], [1]) assert dup_zz_heu_gcd([2,4], [], ZZ) == ([2,4], [1], []) assert dup_rr_prs_gcd([2,4], [], ZZ) == ([2,4], [1], []) assert dup_zz_heu_gcd([2], [2], ZZ) == ([2], [1], [1]) assert dup_rr_prs_gcd([2], [2], ZZ) == ([2], [1], [1]) assert dup_zz_heu_gcd([-2], [2], ZZ) == ([2], [-1], [1]) assert dup_rr_prs_gcd([-2], [2], ZZ) == ([2], [-1], [1]) assert dup_zz_heu_gcd([2], [-2], ZZ) == ([2], [1], [-1]) assert dup_rr_prs_gcd([2], [-2], ZZ) == ([2], [1], [-1]) assert dup_zz_heu_gcd([-2], [-2], ZZ) == ([2], [-1], [-1]) assert dup_rr_prs_gcd([-2], [-2], ZZ) == ([2], [-1], [-1]) assert dup_zz_heu_gcd([1,2,1], [1], ZZ) == ([1], [1, 2, 1], [1]) assert dup_rr_prs_gcd([1,2,1], [1], ZZ) == ([1], [1, 2, 1], [1]) assert dup_zz_heu_gcd([1,2,1], [2], ZZ) == ([1], [1, 2, 1], [2]) assert dup_rr_prs_gcd([1,2,1], [2], ZZ) == ([1], [1, 2, 1], [2]) assert dup_zz_heu_gcd([2,4,2], [2], ZZ) == ([2], [1, 2, 1], [1]) assert dup_rr_prs_gcd([2,4,2], [2], ZZ) == ([2], [1, 2, 1], [1]) assert dup_zz_heu_gcd([2], [2,4,2], ZZ) == ([2], [1], [1, 2, 1]) assert dup_rr_prs_gcd([2], [2,4,2], ZZ) == ([2], [1], [1, 2, 1]) assert dup_zz_heu_gcd([2,4,2], [1,1], ZZ) == ([1, 1], [2, 2], [1]) assert dup_rr_prs_gcd([2,4,2], [1,1], ZZ) == ([1, 1], [2, 2], [1]) assert dup_zz_heu_gcd([1,1], [2,4,2], ZZ) == ([1, 1], [1], [2, 2]) assert dup_rr_prs_gcd([1,1], [2,4,2], ZZ) == ([1, 1], [1], [2, 2]) f, g = [1, -31], [1, 0] assert dup_zz_heu_gcd(f, g, ZZ) == ([1], f, g) assert dup_rr_prs_gcd(f, g, ZZ) == ([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 dup_zz_heu_gcd(f, g, ZZ) == (h, cff, cfg) assert dup_rr_prs_gcd(f, g, ZZ) == (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 dup_zz_heu_gcd(f, g, ZZ) == (h, cff, cfg) assert dup_rr_prs_gcd(f, g, ZZ) == (h, cff, cfg) f = [1,0,1,0,-3,-3,8,2,-5] g = [3,0,5,-0,-4,-9,21] h = [1] cff = f cfg = g assert dup_zz_heu_gcd(f, g, ZZ) == (h, cff, cfg) assert dup_rr_prs_gcd(f, g, ZZ) == (h, cff, cfg) f = dup_normal([1,0,1,0,-3,-3,8,2,-5], QQ) g = dup_normal([3,0,5,-0,-4,-9,21], QQ) h = dup_normal([1], QQ) assert dup_qq_heu_gcd(f, g, QQ) == (h, cff, cfg) assert dup_ff_prs_gcd(f, g, QQ) == (h, cff, cfg) 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] f = dup_normal(f, ZZ) g = dup_normal(g, ZZ) assert dup_zz_heu_gcd(f, dup_diff(f, 1, ZZ), ZZ)[0] == g assert dup_rr_prs_gcd(f, dup_diff(f, 1, ZZ), ZZ)[0] == g f = [QQ(1,2),QQ(1),QQ(1,2)] g = [QQ(1,2),QQ(1,2)] h = [QQ(1), QQ(1)] assert dup_qq_heu_gcd(f, g, QQ) == (h, g, [QQ(1,2)]) assert dup_ff_prs_gcd(f, g, QQ) == (h, g, [QQ(1,2)])