aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parameters_Q4_new.sage60
-rw-r--r--parameters_Q4_old.sage123
2 files changed, 0 insertions, 183 deletions
diff --git a/parameters_Q4_new.sage b/parameters_Q4_new.sage
deleted file mode 100644
index 554cc0a..0000000
--- a/parameters_Q4_new.sage
+++ /dev/null
@@ -1,60 +0,0 @@
1# Returns the l-dvisibility parameters of G over Q, given a good basis gb of G,
2# as a list of pairs (di,hi).
3def parameters_Q( gb, l ):
4 ret = []
5 for i in range( len( gb ) ):
6 for j in gb[i]:
7 ret.append( (i,0) )
8 return ret
9
10# Computes the l-divisibility parameters of G over Q4, given a good basis gb
11# over Q for G. Returns a list of pairs (di,hi).
12# If l is odd it just uses the good basis given to compute the parameters.
13# If l=2, it uses the results of PST-2.
14def parameters_Q4_new( gb, l ):
15 if l != 2:
16 return parameters_Q( gb, l )
17 else:
18 # Converts from "good basis format" to simple list
19 b = []
20 for x in gb:
21 b += x
22
23 M = exponent_matrix( b )
24
25 # Thanks to my terrible notation, the elements of b are what are called
26 # g_i in the article, while the elements of bb will be the b_i's.
27 bb = [ abs(b[i]) ^ (2^(-divisibility(M[i],2))) for i in range(len(b)) ]
28
29 # Computing a combination of bb elements of the form 2 * square.
30 MM = exponent_matrix( bb + [2] ).change_ring( GF( 2 ) )
31
32 for a in MM.kernel().basis():
33 if a[-1] != 0:
34 # the vector a[0:-1] gives the coefficients for a combination
35 # of the b_i's of the form 2 * square
36
37 # Basis elements that actually appear in the combination
38 c = [ b[i] for i in range(len(a[0:-1])) if a[i] != 0 ]
39
40 # Return the parameters, changing only the ones fo the element
41 # of highest divisibility that appears in the combination.
42 ret = []
43 div_max = -1
44 ind_max = -1
45 for i in range(len(b)):
46 ret.append( (divisibility(M[i],2), 1-max(0,sgn(b[i]))) )
47 if a[i] != 0 and ret[i][0] > div_max:
48 div_max = ret[i][0]
49 ind_max = i
50 d1, h1 = ret[ind_max]
51 if d1 == 1:
52 h1 = 1 - h1
53 elif d1 == 0:
54 h1 = 2
55 ret[ind_max] = ( d1+1, h1 )
56
57 return ret
58
59 return parameters_Q( gb, 2 )
60
diff --git a/parameters_Q4_old.sage b/parameters_Q4_old.sage
deleted file mode 100644
index d96fd8c..0000000
--- a/parameters_Q4_old.sage
+++ /dev/null
@@ -1,123 +0,0 @@
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