Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
AndrewVSutherland
GitHub Repository: AndrewVSutherland/lmfdb
Path: blob/main/scripts/lattices/add_q_expansion_theta.py
1127 views
1
# -*- coding: utf-8 -*-
2
r""" Check presence if the first 150 coefficients of the q expansion of the theta series attached to an integral lattice are stored, and adds them otherwise.
3
4
Initial version: Samuele Anni
5
6
"""
7
8
import os
9
from sage.all import gp, matrix
10
11
12
from pymongo.mongo_client import MongoClient
13
C= MongoClient(port=37010)
14
import yaml
15
pw_dict = yaml.load(open(os.path.join(os.getcwd(), "passwords.yaml")))
16
username = pw_dict['data']['username']
17
password = pw_dict['data']['password']
18
C['Lattices'].authenticate('editor', password)
19
lat = C.Lattices.lat
20
21
22
def check_add_qexp(dim, min_det=1, max_det=None, fix=False):
23
query = {}
24
query['dim'] = int(dim)
25
query['det'] = {'$gte' : int(min_det)}
26
if max_det:
27
query['det']['$lte'] = int(max_det)
28
else:
29
max_det = "infinity"
30
lat_set = lat.find(query)
31
print("%s lattices to examine of dimension %s and determinant between %s and %s."
32
% (lat_set.count(), dim, min_det, max_det))
33
if lat_set.count() == 0:
34
return None
35
print("checking whether the q expansion is stored...")
36
for l in lat_set:
37
print("Testing lattice %s" % l['label'])
38
if l['theta_series'] == "":
39
print("q expansion NOT stored")
40
if fix:
41
M=l['gram']
42
exp=[int(i) for i in gp("Vec(1+2*'x*Ser(qfrep("+str(gp(matrix(M)))+",150,0)))")]
43
lat.update({'label': l['label']}, {"$set": {'theta_series': exp}}, upsert=True)
44
print("Fixed lattice %s" % l['label'])
45
else:
46
print("q expansion stored")
47
48
49