aboutsummaryrefslogtreecommitdiff
path: root/parameters_Q4_old.sage
diff options
context:
space:
mode:
Diffstat (limited to 'parameters_Q4_old.sage')
-rw-r--r--parameters_Q4_old.sage123
1 files changed, 123 insertions, 0 deletions
diff --git a/parameters_Q4_old.sage b/parameters_Q4_old.sage
new file mode 100644
index 0000000..d96fd8c
--- /dev/null
+++ b/parameters_Q4_old.sage
@@ -0,0 +1,123 @@
1# Computes the l-divisibility parameters of G over Q4, given a good basis gb
2# over Q for G. Returns a list of pairs (di,hi).
3# If l is odd it just uses the good basis given to compute the parameters.
4def parameters_Q4( gb, l ):
5 # Converts from "good basis format" to simple list
6 b = []
7 for x in gb:
8 b += x
9 ret = []
10
11 if l != 2:
12 for i in range( len( gb ) ):
13 for j in gb[i]:
14 ret.append( (i,0) )
15 return ret
16 else:
17 R.<y> = PolynomialRing( QQ )
18 pol = R(y^2+1)
19 Q4.<eye> = NumberField( pol ) # I already use i for other things
20
21 # Factorize basis elements over Q4 and so on.
22 d = []
23 B = []
24 h = []
25 ideals_list = set()
26 M = [] # Exponent matrix of the Bi's
27
28 # Pre-process to find all ideals appearing in the factorization and fix
29 # a chosen generator for each of them. This is important in order to
30 # compute the "sign" (h-parameter) of an element with respect to it Bi.
31 for g in b:
32 factorization_list = list( Q4.ideal(g).factor() )
33 ideals_list |= set( [ x[0] for x in factorization_list ] )
34 ideals_list = list( ideals_list )
35 # Chooses a generator of each principal ideal in the list
36 irreducibles_list = [ J.gens_reduced()[0] for J in ideals_list ]
37
38 # Compute the Q4-parameters of the given basis b. Also computes the
39 # exponent matrix of the Bi's
40 for g in b:
41 factorization_list = list( Q4.ideal(g).factor() )
42 exps = [ x[1] for x in factorization_list ]
43 d.append( divisibility( exps, l ) )
44 Bg = 1
45 for j in range(len(factorization_list)):
46 a = 0
47 for i in range( len( ideals_list ) ):
48 if ideals_list[i] == factorization_list[j][0]:
49 a = irreducibles_list[i]
50 break
51 Bg *= a ^ (exps[j]/(l^d[-1]))
52 B.append(Bg)
53 u = g / (Bg^(l^d[-1]))
54 if not u.is_unit():
55 print "Error: g is not the right power of the computed Bg."
56 print "g:", g, ", Bg:", Bg, ", exponent:", l^d[-1]
57 if u == 1:
58 h.append( 0 )
59 elif u == -1:
60 h.append( 1 )
61 else:
62 h.append( 2 )
63
64 # Make the exponent matrix M (for now as a list of rows)
65 for g in B:
66 row = [0] * len(ideals_list)
67 for i in range(len(ideals_list)):
68 I = ideals_list[i]
69 ee = 1
70 while (I^ee).divides(g):
71 ee += 1
72 row[i] = ee-1
73 M.append(row)
74
75 # If the Bi's are not strongly independent, apply the algorithm (only
76 # once) to produce a new basis. The new basis has maximal parameters.
77 coeffs = find_combination( matrix(M), l )
78 if coeffs != []:
79
80 maxi = -1
81 maxd = -1
82 for i in range(len(d)):
83 if d[i] > maxd and coeffs[i] != 0:
84 maxd = d[i]
85 maxi = i
86
87 x = [(a/coeffs[maxi]).lift() for a in coeffs] # Now a vector of int
88
89 new_element = 1
90 for i in range(len(d)):
91 new_element *= b[i]^( x[i] * l^(d[maxi]-d[i]) )
92
93 b[maxi] = new_element
94
95 # Compute new B, d and so on.
96 factorization_list = list( Q4.ideal(b[maxi]).factor() )
97 exps = [ x[1] for x in factorization_list ]
98 d[maxi] = divisibility( exps, l )
99 Bg = 1
100
101 for j in range(len(factorization_list)):
102 a = 0
103 for i in range( len( ideals_list ) ):
104 if ideals_list[i] == factorization_list[j][0]:
105 a = irreducibles_list[i]
106 break
107 Bg *= a ^ (exps[j]/(l^d[maxi]))
108 B[maxi] = Bg
109 M[maxi] = [ x[1] for x in list( Q4.ideal(Bg).factor() ) ]
110 u = b[maxi] / (Bg^(l^d[maxi]))
111 if not u.is_unit():
112 print "Error: new element is not the right power of B."
113 print "New el.:", b[maxi], ", B:", Bg, ", exponent:", l^d[maxi]
114 if u == 1:
115 h[maxi] = 0
116 elif u == -1:
117 h[maxi] = 1
118 else:
119 h[maxi] = 2
120
121 return [(d[i],h[i]) for i in range(len(d))]
122
123

Generated with cgit - Back to sebastiano.tronto.net