Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
AndrewVSutherland
GitHub Repository: AndrewVSutherland/lmfdb
Path: blob/main/scripts/hmf/recompute_AL_modp.py
1452 views
1
# -*- coding: utf-8 -*-
2
3
from sage.misc.preparser import preparse
4
from sage.interfaces.magma import magma
5
from sage.all import PolynomialRing, Rationals
6
from lmfdb.base import getDBConnection
7
C = getDBConnection()
8
9
hmf_forms = C.hmfs.forms
10
hmf_fields = C.hmfs.fields
11
fields = C.numberfields.fields
12
13
P = PolynomialRing(Rationals(), 3, ['w', 'e', 'x'])
14
w, e, x = P.gens()
15
16
17
def recompute_AL(field_label=None, skip_odd=False):
18
if field_label is None:
19
S = hmf_forms.find({"AL_eigenvalues_fixed": None})
20
else:
21
S = hmf_forms.find({"field_label": field_label, "AL_eigenvalues_fixed": None})
22
S = S.sort("label")
23
24
field_label = None
25
26
magma.eval('SetVerbose("ModFrmHil", 1);')
27
28
v = next(S)
29
while True:
30
NN_label = v["level_label"]
31
v_label = v["label"]
32
33
print(v_label)
34
35
if field_label is None or not field_label == v["field_label"]:
36
field_label = v["field_label"]
37
print("...new field " + field_label)
38
39
F = fields.find_one({"label": field_label})
40
F_hmf = hmf_fields.find_one({"label": field_label})
41
42
magma.eval('P<x> := PolynomialRing(Rationals());')
43
magma.eval('F<w> := NumberField(Polynomial(' + str(F["coefficients"]) + '));')
44
magma.eval('ZF := Integers(F);')
45
magma.eval('ideals_str := [' + ','.join([st for st in F_hmf["ideals"]]) + '];')
46
magma.eval('ideals := [ideal<ZF | {F!x : x in I}> : I in ideals_str];')
47
48
magma.eval('primes_str := [' + ','.join([st for st in F_hmf["primes"]]) + '];')
49
magma.eval('primes := [ideal<ZF | {F!x : x in I}> : I in primes_str];')
50
51
magma.eval('classno := NarrowClassNumber(F);')
52
53
if skip_odd and F["degree"] % 2 == 1 and v["level_norm"] > 300:
54
print("...level norm > 300, skipping!")
55
try:
56
v = next(S)
57
continue
58
except StopIteration:
59
break
60
61
NN_index = NN_label[NN_label.index('.') + 1:]
62
magma.eval(
63
'NN := [I : I in ideals | Norm(I) eq ' + str(v["level_norm"]) + '][' + str(NN_index) + '];')
64
magma.eval('Mfull := HilbertCuspForms(F, NN);')
65
magma.eval('M := NewSubspace(Mfull);')
66
magma.eval('O := QuaternionOrder(M); B := Algebra(O); DD := Discriminant(B);')
67
68
if v["hecke_polynomial"] != 'x':
69
magma.eval('fpol := ' + v["hecke_polynomial"] + ';')
70
magma.eval('K<e> := NumberField(fpol);')
71
else:
72
magma.eval('fpol := x;')
73
magma.eval('K := Rationals(); e := 1;')
74
75
magma.eval('hecke_eigenvalues := [' + ','.join([st for st in v["hecke_eigenvalues"]]) + '];')
76
77
print("...Hecke eigenvalues loaded...")
78
79
magma.eval('denom := Lcm([Denominator(a) : a in hecke_eigenvalues]); q := NextPrime(200);')
80
magma.eval(
81
'while #Roots(fpol, GF(q)) eq 0 or Valuation(denom,q) gt 0 do q := NextPrime(q); end while;')
82
magma.eval('if K cmpeq Rationals() then mk := hom<K -> GF(q) | >; else mk := hom<K -> GF(q) | Roots(fpol,GF(q))[1][1]>; end if;')
83
84
magma.eval(
85
'_<xQ> := PolynomialRing(Rationals()); rootsofunity := [r[1] : r in Roots(xQ^(2*classno)-1,K)];')
86
87
magma.eval('s := 0; KT := []; '
88
'while KT cmpeq [] or Dimension(KT) gt 1 do '
89
' s +:= 1; '
90
' if s gt Min(50,#hecke_eigenvalues) then '
91
' q := NextPrime(q); while #Roots(fpol, GF(q)) eq 0 or Valuation(denom,q) gt 0 do q := NextPrime(q); end while; '
92
' if K cmpeq Rationals() then mk := hom<K -> GF(q) | >; else mk := hom<K -> GF(q) | Roots(fpol,GF(q))[1][1]>; end if; '
93
' s := 1; '
94
' KT := []; '
95
' end if; '
96
' pp := primes[s]; '
97
' if Valuation(NN, pp) eq 0 then '
98
' T_pp := HeckeOperator(M, pp); '
99
' T_pp := Matrix(Nrows(T_pp),Ncols(T_pp),[mk(c) : c in Eltseq(T_pp)]); '
100
' a_pp := hecke_eigenvalues[s]; '
101
' if KT cmpeq [] then '
102
' KT := Kernel(T_pp-mk(a_pp)); '
103
' else '
104
' KT := KT meet Kernel(T_pp-mk(a_pp)); '
105
' end if; '
106
' end if; '
107
'end while;')
108
magma.eval('assert Dimension(KT) eq 1;')
109
110
print("...dimension 1 subspace found...")
111
112
magma.eval('NNfact := [pp : pp in Factorization(NN) | pp[1] in primes];')
113
magma.eval('f := Vector(Basis(KT)[1]); '
114
'AL_eigenvalues := []; '
115
'for pp in NNfact do '
116
' if Valuation(DD,pp[1]) gt 0 then U_pp := -HeckeOperator(M, pp[1]); '
117
' else U_pp := AtkinLehnerOperator(M, pp[1]); end if; '
118
' U_pp := Matrix(Nrows(U_pp),Ncols(U_pp),[mk(c) : c in Eltseq(U_pp)]); '
119
' U_ppf := f*U_pp; found := false; '
120
' for mu in rootsofunity do '
121
' if U_ppf eq mk(mu)*f then Append(~AL_eigenvalues, mu); found := true; end if; '
122
' end for; '
123
' assert found; '
124
'end for;')
125
126
print("...AL eigenvalues computed!")
127
128
AL_ind = eval(preparse(magma.eval('[Index(primes,pp[1])-1 : pp in NNfact]')))
129
AL_eigenvalues_jv = eval(preparse(magma.eval('AL_eigenvalues')))
130
AL_eigenvalues = [[F_hmf["primes"][AL_ind[i]], AL_eigenvalues_jv[i]] for i in range(len(AL_ind))]
131
pps_exps = eval(preparse(magma.eval('[pp[2] : pp in NNfact]')))
132
133
hecke_eigenvalues = v["hecke_eigenvalues"]
134
for j in range(len(AL_ind)):
135
s = AL_ind[j]
136
try:
137
if pps_exps[j] >= 2:
138
hecke_eigenvalues[s] = '0'
139
else:
140
hecke_eigenvalues[s] = str(-AL_eigenvalues[j][1])
141
except IndexError:
142
pass
143
144
AL_eigenvalues = [[a[0], str(a[1])] for a in AL_eigenvalues]
145
146
v["hecke_eigenvalues"] = hecke_eigenvalues
147
v["AL_eigenvalues"] = AL_eigenvalues
148
v["AL_eigenvalues_fixed"] = 'done'
149
hmf_forms.save(v)
150
151
v = next(S)
152
153