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) F_0 = dup_zz_factor(f, ZZ, cyclotomic=True) F_1 = dup_zz_factor(f, ZZ, cyclotomic=False) assert F_0 == F_1 == \ (1, [([1,-1], 1), ([1, 1], 1), ([1,-1, 1,-1, 1], 1), ([1, 1, 1, 1, 1], 1)]) f = dup_from_raw_dict({10: 1, 0: 1}, ZZ) F_0 = dup_zz_factor(f, ZZ, cyclotomic=True) F_1 = dup_zz_factor(f, ZZ, cyclotomic=False) assert F_0 == F_1 == \ (1, [([1, 0, 1], 1), ([1, 0, -1, 0, 1, 0, -1, 0, 1], 1)])
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) 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, 0, 1], 1), ([1, 0, -1, 0, 1, 0, -1, 0, 1], 1)]) config.setup('USE_CYCLOTOMIC_FACTOR')