Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
241818 views
1
#################################################################################
2
#
3
# (c) Copyright 2011 William Stein
4
#
5
# This file is part of PSAGE
6
#
7
# PSAGE is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# PSAGE is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#
20
#################################################################################
21
22
import sage.parallel.ncpus
23
from psage.lmfdb.auth import userpass
24
25
def populate_db(address, level_min, level_max, num_zeros=100,
26
ncpus=sage.parallel.ncpus.ncpus()):
27
"""
28
Compute and insert into the MongoDB database with the given
29
address the imaginary parts of the first num_zeros zeros of the
30
L-series of each optimal elliptic curve in the given level range.
31
32
Only curves with L0s not yet set are affected by this function.
33
The key on the database is "L0s".
34
"""
35
user, password = userpass()
36
37
import math, random
38
from sage.all import parallel, EllipticCurve
39
40
from sage.libs.lcalc.lcalc_Lfunction import Lfunction_from_elliptic_curve
41
42
level_min = int(level_min); level_max = int(level_max)
43
s = int(math.ceil((level_max - level_min)/float(ncpus)))
44
blocks = [(level_min+i*s, min(level_max,level_min+(i+1)*s)) for i in range(ncpus)]
45
46
@parallel(ncpus)
47
def f(l_min, l_max):
48
from pymongo import Connection
49
C = Connection(address).research
50
C.authenticate(user, password)
51
C = C.ellcurves
52
for v in C.find({'level':{'$gte':level_min, '$lt':level_max},
53
'number':1,
54
'L0s':{'$exists':False}}):
55
L = Lfunction_from_elliptic_curve(EllipticCurve(eval(v['weq'])), 10**5)
56
z = L.find_zeros_via_N(num_zeros)
57
L0s = dict([(str(i),float(z[i])) for i in range(len(z))])
58
C.update({'_id':v['_id']}, {'$set':{'L0s':L0s}})
59
60
for ans in f(blocks):
61
print ans
62
63
64
"""
65
EXAMPLE QUERIES:
66
67
from pymongo import Connection
68
db = Connection(port=int(29000)).research
69
e = db.ellcurves
70
v = e.find({'level':{'$lt':100r}, 'L0s':{'$exists':True}}, )
71
v.count()
72
7
73
74
This counts the number of optimal curves for which the 0-th zero (the
75
first one) is >1 and the number for which it is < 1.
76
77
sage: v = e.find({'level':{'$lt':100r}, 'L0s.0':{'$gt':int(1)}}, )
78
sage: v.count()
79
75
80
sage: v = e.find({'level':{'$lt':100r}, 'L0s.0':{'$lt':int(1)}}, )
81
sage: v.count()
82
17
83
84
"""
85
86
87