CoCalc Shared Fileswww / cgi-bin / mfd / cremona.pyOpen in CoCalc with one click!
Author: William A. Stein
1
########################################################################
2
# cremona.py -- import all of Cremona's latest data into the
3
# Modular Forms Explorer
4
#
5
# William Stein, January 10, 2001
6
#
7
########################################################################
8
9
import constants, mfd, misc, string
10
11
CREMONA = "/home/was/www/cremona/"
12
13
CURVES = ["curves.1-8000", "curves.8001-12000"]
14
DEGPHI = ["degphi.1-8000"]
15
GENS = ["gens.1-8000", "gens.8001-12000"]
16
APLIST = ["aplist.1-12000"]
17
ALLBIGSHA = ["allbigsha.1-8000", "allbigsha.8001-12000"]
18
ALLBSD = ["allbsd.1-8000", "allbsd.8001-12000"]
19
ALLCURVES = ["allcurves.1-8000", "allcurves.8001-12000"]
20
ALLGENS = ["allgens.1-8000", "allgens.8001-12000"]
21
COUNT = ["count.1-12000"]
22
23
def load_data(files):
24
data = ""
25
for fname in files:
26
data = data + open(CREMONA+fname,"r").read()
27
return string.split(data,"\n")
28
29
def add_curve(N, iso, a_invariants, rank, torsion, degphi):
30
print "adding curves ", N, iso
31
stein = misc.cremona_to_stein(N, iso)
32
print "using iso = ",stein[1]
33
f = mfd.ModSym(N,2,stein[1])
34
f.set_dimension(1)
35
f.set_hecke_field('x-1')
36
a_invariants = '{' + a_invariants[1:-1] + '}'
37
f.set_a_invariants(a_invariants)
38
f.set_mwrank(rank)
39
f.set_torsion_size(torsion)
40
f.set_modular_degree(degphi)
41
42
def curves(first, last):
43
data = load_data(CURVES)
44
for E in data:
45
fields = string.split(E)
46
if len(fields)==0:
47
return
48
N = int(fields[0])
49
if N >= first and N <= last:
50
add_curve(N, fields[1], fields[3], fields[4], fields[5], fields[6])
51
if N > last:
52
return
53
54
PRIMES = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
55
56
def aplist_helper(fields):
57
t = "{"
58
atkin = "{"
59
N = int(fields[0])
60
for i in range(0,25):
61
ap = fields[i+2]
62
wp = ""
63
if ap == "+" or ap == "-":
64
wp = ap
65
if N%(PRIMES[i]*PRIMES[i]) == 0:
66
ap = "0"
67
elif ap == "+":
68
ap = "-1"
69
elif ap == "-":
70
ap = "+1"
71
if atkin == "{":
72
atkin = atkin + str(int(wp+"1"))
73
else:
74
atkin = atkin + "," + str(int(wp+"1"))
75
if t == "{":
76
t = t + ap
77
else:
78
t = t + "," + ap
79
80
for i in range(27,len(fields)):
81
wp = fields[i][:1]
82
if atkin == "{":
83
atkin = atkin + str(int(wp+"1"))
84
else:
85
atkin = atkin + "," + str(int(wp+"1"))
86
87
t = t + "}"
88
atkin = atkin + "}"
89
return [t, atkin]
90
91
def aplist(first, last):
92
data = load_data(APLIST)
93
for E in data:
94
fields = string.split(E)
95
if len(fields) == 0:
96
return
97
N = int(fields[0])
98
if N > last:
99
return
100
if N >= first:
101
print N
102
stein = misc.cremona_to_stein(N,fields[1])
103
f = mfd.ModSym(N,2,stein[1])
104
if f.traces() == constants.not_computed or f.atkin_lehner() == constants.not_computed:
105
x = aplist_helper(fields)
106
print "x = ",x
107
t = x[0]
108
atkin = x[1]
109
f.set_traces(t)
110
f.set_atkin_lehner(atkin)
111
else:
112
print "skipping ",N
113
114
115
# degphi is NOT TESTED -- don't run, since it's already done by the CURVES file.
116
def degphi(first, last):
117
data = load_data(DEGPHI)
118
for E in data:
119
fields = string.split(E)
120
if len(fields) == 0:
121
return
122
N = int(fields[0])
123
if N > last:
124
return
125
if N >= first:
126
print N
127
stein = misc.cremona_to_stein(N,fields[1][:-1])
128
f = mfd.ModSym(N,2, stein[1])
129
if f.modular_degree() == constants.not_computed:
130
degree = fields[2] # don't change to string, since could be bigger than PYTHON string
131
primes = fields[3]
132
print "setting deg =", degree, " and primes =", primes
133
f.set_modular_degree(degree)
134
f.set_modular_degree_primes(primes)
135
else:
136
print "skipping level",N
137
138
139
def gens(first, last):
140
data = load_data(GENS)
141
for E in data:
142
fields = string.split(E)
143
if len(fields) == 0:
144
return
145
N = int(fields[0])
146
if N > last:
147
return
148
if N >= first:
149
print N
150
stein = misc.cremona_to_stein(N,int(fields[1]))
151
f = mfd.ModSym(N,2,stein[1])
152
if f.mw_generators() == constants.not_computed:
153
gens = "{"
154
for i in range(5,len(fields)):
155
x = fields[i]
156
x = string.replace(x, ":",",")
157
x = string.replace(x, "[", "{")
158
x = string.replace(x, "]", "}")
159
if gens != "{":
160
gens = gens + ","
161
gens = gens + x
162
gens = gens + "}"
163
print "Adding",gens
164
f.set_mw_generators(gens)
165
else:
166
print "skipping level",N
167
168
169
def allbsd_helper(f, fields):
170
om = fields[7] # real period
171
L = fields[8] # L^(r)(E,1) leading value
172
R = fields[9] # regulator
173
S = fields[10]
174
if string.find(S,".") != -1:
175
S = str(int(round(float(S))))
176
177
f.set_real_volume(om)
178
f.set_leading_coefficient(L)
179
f.set_regulator(R)
180
f.set_sha_an(S)
181
182
def allbsd(first, last):
183
data = load_data(ALLBSD)
184
for E in data:
185
fields = string.split(E)
186
if len(fields) == 0:
187
return
188
N = int(fields[0])
189
if N > last:
190
return
191
if fields[2] == "1" and N >= first: # take only the optimal ones in the appropriate range
192
print N
193
stein = misc.cremona_to_stein(N,fields[1])
194
f = mfd.ModSym(N,2,stein[1])
195
allbsd_helper(f, fields)
196
197
198