Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
AndrewVSutherland
GitHub Repository: AndrewVSutherland/lmfdb
Path: blob/main/scripts/hmf/make-lp-file.sage
1448 views
1
'''
2
script written just for use at June 2017 LMFDB workshop at Warwick. Output is text that defines the Hecke polynomials for weight [2,2] HMFs over readl quadratic fields
3
'''
4
import os
5
import subprocess
6
import pymongo
7
8
#P = subprocess.Popen(["ssh","mongo","-N"])
9
_C = None
10
11
def makeDBconnection():
12
global _C
13
14
_C = pymongo.MongoClient("localhost:37010")
15
#_C = pymongo.MongoClient("m0.lmfdb.xyz:27017")
16
_C.admin.authenticate("lmfdb","lmfdb")
17
18
def getDBconnection():
19
if _C is None:
20
makeDBconnection()
21
return _C
22
23
def get_hmf(label):
24
C = getDBconnection()
25
return C.hmfs.forms.find_one({ u'label' : label })
26
27
def get_hmf_field(label):
28
C = getDBconnection()
29
f = get_hmf(label)
30
F = C.hmfs.fields.find_one({u'label':f['field_label']})
31
return F
32
33
def get_field(label):
34
C = getDBconnection()
35
F = C.numberfields.fields.find_one({u'label':label})
36
return F
37
38
def make_lp(form_label):
39
f = get_hmf(form_label)
40
prec = 350
41
F_hmf = get_hmf_field(form_label)
42
R = QQ['x']
43
(x,) = R._first_ngens(1)
44
K = NumberField(R(str(f['hecke_polynomial']).replace('^', '**')), 'e')
45
# e = K.gens()[0]
46
for emb in range(K.degree()):
47
iota = K.complex_embeddings(prec)[emb] # a bit of overkill
48
49
# for level>1, calculate sign from Fricke involution and weight
50
ALeigs = [al[1].replace('^', '**') for al in f['AL_eigenvalues']]
51
# the above fixed a bug at
52
# L/ModularForm/GL2/TotallyReal/2.2.104.1/holomorphic/2.2.104.1-5.2-c/0/0/
53
# but now the sign is wrong (i.e., not of absolute value 1 *)
54
AL_signs = [iota(K(str(al))) for al in ALeigs]
55
# Compute Dirichlet coefficients
56
hecke_eigenvalues = [iota(K(str(ae))) for ae in f['hecke_eigenvalues']]
57
primes = [pp_str.split(', ') for pp_str in F_hmf['primes']]
58
primes = [[int(pp[0][1:]), int(pp[1])] for pp in primes]
59
primes = [[pp[0], pp[1], factor(pp[0])[0][1]] for pp in primes]
60
61
PP = primes[-1][0]
62
63
ppmidNN = [c[0].replace(' ','') for c in f['AL_eigenvalues']] # removed extraneous spaces
64
65
ratl_primes = [p for p in range(primes[-1][0] + 1) if is_prime(p)]
66
CC = ComplexField(prec)
67
RCC = CC['T']
68
(T,) = RCC._first_ngens(1)
69
heckepols = [RCC(1) for p in ratl_primes]
70
# !!! DANGER primes are stored as strings!!!
71
sanitized_F_hmf_primes = [pp.replace(' ','') for pp in F_hmf['primes']] # removed extraneous spaces
72
for l in range(len(hecke_eigenvalues)):
73
if sanitized_F_hmf_primes[l] in ppmidNN:
74
heckepols[ratl_primes.index(primes[l][1])] *= (1 - hecke_eigenvalues[l] * (T ** primes[l][2]))
75
else:
76
heckepols[ratl_primes.index(primes[l][1])] *= (1 - hecke_eigenvalues[l] * (T ** primes[l][2]) + primes[l][0]* (T ** (2 * primes[l][2])))
77
# polynomials are computed. Spit out to text file.
78
with open(form_label + '-lpoly-' + str(emb) + '.txt','w') as outfile:
79
for i in range(len(heckepols)):
80
poly = heckepols[i]
81
rat_p = ratl_primes[i]
82
dataline = str(rat_p)+','+str([[a.real_part(), a.imag_part()] for a in poly.coefficients(sparse = false)]) + '\n'
83
outfile.write(dataline)
84
85