def testEasyCase(self): # Q_rt_minus_1 [1, 0, 1] field = algfield.NumberField(self.Q_rt_minus_1) # p=2 Q_rt_minus_1_2_index = [(2, 1)] # ramify Q_rt_minus_1_2_prime = 2 * module.Ideal( matrix.unitMatrix(field.degree), field, field.integer_ring()) result_e_f, result_mul = self.result_transform(prime_decomp(2, self.Q_rt_minus_1)) self.assertEqual(result_e_f, Q_rt_minus_1_2_index) self.assertEqual(result_mul, Q_rt_minus_1_2_prime) # p=3 Q_rt_minus_1_3_index = [(1, 2)] # inert Q_rt_minus_1_3_prime = 3 * module.Ideal( matrix.unitMatrix(field.degree), field, field.integer_ring()) result_e_f, result_mul = self.result_transform(prime_decomp(3, self.Q_rt_minus_1)) self.assertEqual(result_e_f, Q_rt_minus_1_3_index) self.assertEqual(result_mul, Q_rt_minus_1_3_prime) # p=5 Q_rt_minus_1_5_index = [(1, 1), (1, 1)] # split Q_rt_minus_1_5_prime = 5 * module.Ideal( matrix.unitMatrix(field.degree), field, field.integer_ring()) result_e_f, result_mul = self.result_transform(prime_decomp(5, self.Q_rt_minus_1)) self.assertEqual(result_e_f, Q_rt_minus_1_5_index) self.assertEqual(result_mul, Q_rt_minus_1_5_prime) # Q_cb_2 [-2, 0, 0, 1] field = algfield.NumberField(self.Q_cb_2) # p=3 Q_cb_2_3_index = [(3, 1)] # ramify Q_cb_2_3_prime = 3 * module.Ideal( matrix.unitMatrix(field.degree), field, field.integer_ring()) result_e_f, result_mul = self.result_transform(prime_decomp(3, self.Q_cb_2)) self.assertEqual(result_e_f, Q_cb_2_3_index) self.assertEqual(result_mul, Q_cb_2_3_prime) # p=5 Q_cb_2_5_index = [(1, 1), (1, 2)] # split & inert Q_cb_2_5_prime = 5 * module.Ideal( matrix.unitMatrix(field.degree), field, field.integer_ring()) result_e_f, result_mul = self.result_transform(prime_decomp(5, self.Q_cb_2)) self.assertEqual(result_e_f, Q_cb_2_5_index) self.assertEqual(result_mul, Q_cb_2_5_prime) # p=31 Q_cb_2_31_index = [(1, 1), (1, 1), (1, 1)] # split Q_cb_2_31_prime = 31 * module.Ideal( matrix.unitMatrix(field.degree), field, field.integer_ring()) result_e_f, result_mul = self.result_transform(prime_decomp(31, self.Q_cb_2)) self.assertEqual(result_e_f, Q_cb_2_31_index) self.assertEqual(result_mul, Q_cb_2_31_prime)
def _main_prime_decomp(p, polynomial): """ main step of prime decomposition """ field = algfield.NumberField(polynomial) n = field.degree int_basis = field.integer_ring() base_multiply = module._base_multiplication(int_basis, field) H_lst = _squarefree_decomp(p, field, base_multiply) # step 2-5 done_list = [] for j in range(len(H_lst)): H_j = H_lst[j] # step 7 if H_j != None and H_j.column == n: #rank(H_j) continue L = [H_j] while L: H = L.pop() A, gamma_multiply = _separable_algebra( p, H, base_multiply) # step 8, 9 sol = _check_H(p, H, field, gamma_multiply) # step 10-11 if isinstance(sol, tuple): done_list.append((sol[0], j + 1, sol[1])) else: L += _splitting_squarefree(p, H, base_multiply, A, gamma_multiply, sol) # step 12-15 return done_list
def testMainCase(self): # cubic_first [1, 9, 0, 3] field = algfield.NumberField(self.cubic_first) # p=3 cubic_first_3_index = [(1, 1), (2, 1)] # split & ramify cubic_first_3_prime = 3 * module.Ideal( matrix.unitMatrix(field.degree), field, field.integer_ring()) result_e_f, result_mul = self.result_transform(prime_decomp(3, self.cubic_first)) self.assertEqual(result_e_f, cubic_first_3_index) self.assertEqual(result_mul, cubic_first_3_prime) # cubic_second [1, 8, 0, 3] field = algfield.NumberField(self.cubic_second) # p=5 cubic_second_5_index = [(1, 1), (1, 2)] # split & inert cubic_second_5_prime = 5 * module.Ideal( matrix.unitMatrix(field.degree), field, field.integer_ring()) result_e_f, result_mul = self.result_transform(prime_decomp(5, self.cubic_second)) self.assertEqual(result_e_f, cubic_second_5_index) self.assertEqual(result_mul, cubic_second_5_prime) # sextic_first [7, 6, 5, 4, 3, 2, 1] field = algfield.NumberField(self.sextic_first) # p=2 sextic_first_2_index = [(2, 1), (4, 1)] # split & ramify sextic_first_2_prime = 2 * module.Ideal( matrix.unitMatrix(field.degree), field, field.integer_ring()) result_e_f, result_mul = self.result_transform(prime_decomp(2, self.sextic_first)) self.assertEqual(result_e_f, sextic_first_2_index) self.assertEqual(result_mul, sextic_first_2_prime) # sextic_second [6480, 1296, -252, 36, -7, 1] field = algfield.NumberField(self.sextic_second) # p=2 sextic_second_2_index = [(1, 1), (1, 4)] # split & ramify sextic_second_2_prime = 2 * module.Ideal( matrix.unitMatrix(field.degree), field, field.integer_ring()) result_e_f, result_mul = self.result_transform(prime_decomp(2, self.sextic_second)) self.assertEqual(result_e_f, sextic_second_2_index) self.assertEqual(result_mul, sextic_second_2_prime) # p=3 sextic_second_3_index = [(1, 1), (1, 1), (1, 1), (1, 2)] # split & inert sextic_second_3_prime = 3 * module.Ideal( matrix.unitMatrix(field.degree), field, field.integer_ring()) result_e_f, result_mul = self.result_transform(prime_decomp(3, self.sextic_second)) self.assertEqual(result_e_f, sextic_second_3_index) self.assertEqual(result_mul, sextic_second_3_prime)
def setUp(self): self.K = algfield.NumberField([-2,0,1]) self.KI = algfield.NumberField([2,0,1]) self.F = algfield.NumberField([-3,0,1]) self.G = algfield.NumberField([-2,0,0,1]) self.CF1 = algfield.NumberField([101,20,1])#cyclotomic field self.CF2 = algfield.NumberField([14521,-5302,725,-44,1])
def prime_decomp(p, polynomial): """ Return prime decomposition of (p) over Q[x]/(polynomial). This method returns a list of (P_k, e_k, f_k), where P_k is an instance of Ideal_with_generator, e_k is the ramification index of P_k, f_k is the residue degree of P_k. """ field = algfield.NumberField(polynomial) field_disc = field.field_discriminant() if (field.disc() // field_disc) % p != 0: return _easy_prime_decomp(p, polynomial) else: return _main_prime_decomp(p, polynomial)