Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
241818 views
1
"""
2
Queries
3
4
This file contains code that carries out interesting queries
5
regarding the database of elliptic curves.
6
"""
7
8
def counts_collection(address='localhost:29000'):
9
from psage.lmfdb.auth import userpass
10
user, password = userpass()
11
from pymongo import Connection
12
from pymongo.connection import DuplicateKeyError
13
C = Connection(address).research
14
C.authenticate(user, password)
15
return C.ellcurves
16
17
def create_counts_table(levels, address, verbose=0):
18
"""
19
QUESTION: What proportion of curves in the database have
20
squarefree conductor, as a function of the conductor?
21
22
To answer, make another table ellcurves.counts with documents:
23
24
{'_id':N, 'c':number_of_isogeny_classes_of_curves_of_conductor_N, 'ss':True}
25
26
where 'ss':True is set only if N is squarefree.
27
28
Once we have this table, the rest should be relatively easy.
29
"""
30
db_counts = get_ellcurves(address).counts
31
32
from sage.all import is_squarefree
33
i = 0
34
35
for N in levels:
36
N = int(N)
37
c = ellcurves.find({'level':N, 'number':1}).count()
38
doc = {'_id':N, 'c':c}
39
if is_squarefree(N):
40
doc['ss'] = True
41
try:
42
db_counts.insert(doc, safe=True)
43
except DuplicateKeyError:
44
if verbose and i%verbose == 0:
45
print '[%s]'%N,
46
else:
47
if verbose and i%verbose == 0:
48
print N,
49
i += 1
50
import sys; sys.stdout.flush()
51
52
def counts_intlist(Nmax):
53
"""
54
Return an Intlist v such that for N<=Nmax, we have v[N] = # of
55
isogeny classes of curves of conductor N in the database.
56
"""
57
Nmax = int(Nmax)
58
db_counts = get_ellcurves(address).counts
59
from sage.all import stats
60
v = stats.IntList(Nmax + 1)
61
query = {'_id':{'$lte':Nmax}, 'c':{'$exists':True}}
62
for c in db_counts.find(query):
63
v[c['_id']] = c['c']
64
65
return v
66
67
68
69
70
71
def create_disc_counts_table(levels, address, verbose=0):
72
"""
73
QUESTION: What proportion of curves in the database have
74
squarefree conductor, as a function of the conductor?
75
76
To answer, make another table ellcurves.counts with documents:
77
78
{'_id':N, 'c':number_of_isogeny_classes_of_curves_of_conductor_N, 'ss':True}
79
80
where 'ss':True is set only if N is squarefree.
81
82
Once we have this table, the rest should be relatively easy.
83
"""
84
db_counts = get_ellcurves(address).disc_counts
85
86
# TODO
87
88