def download_search(info): dltype = info["Submit"] delim = "bracket" com = r"\\" # single line comment start com1 = "" # multiline comment start com2 = "" # multiline comment end filename = "elliptic_curves.gp" mydate = time.strftime("%d %B %Y") if dltype == "sage": com = "#" filename = "elliptic_curves.sage" if dltype == "magma": com = "" com1 = "/*" com2 = "*/" delim = "magma" filename = "elliptic_curves.m" s = com1 + "\n" s += com + " Elliptic curves downloaded from the LMFDB downloaded on %s.\n" % (mydate) s += com + " Below is a list called data. Each entry has the form:\n" s += com + " [[field_poly],[Weierstrass Coefficients, constant first in increasing degree]]\n" s += "\n" + com2 s += "\n" if dltype == "magma": s += "P<x> := PolynomialRing(Rationals()); \n" s += "data := [" elif dltype == "sage": s += "x = polygen(QQ) \n" s += "data = [ " else: s += "data = [ " s += "\\\n" nf_dict = {} res = db_ecnf().find(ast.literal_eval(info["query"])) for f in res: nf = str(f["field_label"]) # look up number field and see if we already have the min poly if nf in nf_dict: poly = nf_dict[nf] else: poly = str(WebNumberField(f["field_label"]).poly()) nf_dict[nf] = poly entry = str(f["ainvs"]) entry = entry.replace("u", "") entry = entry.replace("'", "") s += "[[" + poly + "], " + entry + "],\\\n" s = s[:-3] s += "]\n" if delim == "brace": s = s.replace("[", "{") s = s.replace("]", "}") if delim == "magma": s = s.replace("[", "[*") s = s.replace("]", "*]") s += ";" strIO = StringIO.StringIO() strIO.write(s) strIO.seek(0) return send_file(strIO, attachment_filename=filename, as_attachment=True)
def __init__(self): logger.debug("Constructing an instance of ECstats") self.ecdb = db_ecnf() self._counts = {} self._stats = {} self._dstats = {} self._sigstats = {}
def make_torsion_growth(self): try: tor_gro = self.tor_gro self.torsion_growth_data_exists = True except AttributeError: self.torsion_growth_data_exists = False return self.tg = tg = {} tg['data'] = tgextra = [] # find all base-changes of this curve in the database, if any from lmfdb.ecnf.WebEllipticCurve import db_ecnf bcs = [ res['label'] for res in db_ecnf().find({'base_change': self.lmfdb_label}, projection={ 'label': True, '_id': False }) ] bcfs = [lab.split("-")[0] for lab in bcs] for F, T in tor_gro.items(): tg1 = {} tg1['bc'] = "Not in database" if ":" in F: F = F.replace(":", ".") field_data = nf_display_knowl(F, getDBConnection(), field_pretty(F)) deg = int(F.split(".")[0]) bcc = [x for x, y in zip(bcs, bcfs) if y == F] if bcc: from lmfdb.ecnf.main import split_full_label F, NN, I, C = split_full_label(bcc[0]) tg1['bc'] = bcc[0] tg1['bc_url'] = url_for('ecnf.show_ecnf', nf=F, conductor_label=NN, class_label=I, number=C) else: field_data = web_latex_split_on_pm( coeff_to_poly(string2list(F))) deg = F.count(",") tg1['d'] = deg tg1['f'] = field_data tg1['t'] = '\(' + ' \\times '.join( ['\Z/{}\Z'.format(n) for n in T.split(",")]) + '\)' tg1['m'] = 0 tgextra.append(tg1) tgextra.sort(key=lambda x: x['d']) tg['n'] = len(tgextra) lastd = 1 for tg1 in tgextra: d = tg1['d'] if d != lastd: tg1['m'] = len([x for x in tgextra if x['d'] == d]) lastd = d tg['maxd'] = max(db_ecstats().find_one({'_id': 'torsion_growth'})['degrees'])
def show_ecnf1(nf): if nf == "1.1.1.1": return redirect(url_for("ec.rational_elliptic_curves", **request.args)) if request.args: return elliptic_curve_search(data=request.args) start = 0 count = 50 try: nf_label = nf_string_to_label(nf) except ValueError: return search_input_error() query = {'field_label': nf_label} cursor = db_ecnf().find(query) nres = cursor.count() if (start >= nres): start -= (1 + (start - nres) / count) * count if (start < 0): start = 0 res = cursor.sort([('field_label', ASC), ('conductor_norm', ASC), ('conductor_label', ASC), ('iso_nlabel', ASC), ('number', ASC)]).skip(start).limit(count) bread = [('Elliptic Curves', url_for(".index")), (nf_label, url_for('.show_ecnf1', nf=nf_label))] res = list(res) for e in res: e['field_knowl'] = nf_display_knowl(e['field_label'], getDBConnection(), field_pretty(e['field_label'])) info = {} info['field'] = nf_label info['query'] = query info['curves'] = res # [ECNF(e) for e in res] info['number'] = nres info['start'] = start info['count'] = count info['more'] = int(start + count < nres) info['field_pretty'] = field_pretty info['web_ainvs'] = web_ainvs #don't risk recomputing all the ecnf stats just to show curves for a single number field #if nf_label: #info['stats'] = ecnf_field_summary(nf_label) if nres == 1: info['report'] = 'unique match' else: if nres > count or start != 0: info['report'] = 'displaying matches %s-%s of %s' % ( start + 1, min(nres, start + count), nres) else: info['report'] = 'displaying all %s matches' % nres t = 'Elliptic Curves over %s' % field_pretty(nf_label) return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t, learnmore=learnmore_list())
def random_curve(): E = random_object_from_collection(db_ecnf()) return redirect( url_for(".show_ecnf", nf=E['field_label'], conductor_label=E['conductor_label'], class_label=E['iso_label'], number=E['number']), 307)
def index(): # if 'jump' in request.args: # return show_ecnf1(request.args['label']) if len(request.args) > 0: return elliptic_curve_search(data=request.args) bread = get_bread() data = {} nfs = db_ecnf().distinct("field_label") nfs = ["2.0.4.1", "2.2.5.1", "3.1.23.1"] data["fields"] = [(nf, field_pretty(nf)) for nf in nfs if int(nf.split(".")[2]) < 200] return render_template("ecnf-index.html", title="Elliptic Curves over Number Fields", data=data, bread=bread)
def by_label(label): """ Searches for a specific elliptic curve isogeny class in the curves collection by its label, which can be either a full curve label (including the field_label component) or a full class label. In either case the data will be obtained from the curve in the database with number 1 in the class. """ #print "label = %s" % label try: if label[-1].isdigit(): data = db_ecnf().find_one({"label": label}) else: data = db_ecnf().find_one({"label": label + "1"}) except AttributeError: return "Invalid label" # caller must catch this and raise an error if data: return ECNF_isoclass(data) return "Class not found" # caller must catch this and raise an error
def show_ecnf1(nf): if nf == "1.1.1.1": return redirect(url_for("ec.rational_elliptic_curves", **request.args)) if request.args: return elliptic_curve_search(data=request.args) start = 0 count = 50 nf_label = parse_field_string(nf) query = {"field_label": nf_label} cursor = db_ecnf().find(query) nres = cursor.count() if start >= nres: start -= (1 + (start - nres) / count) * count if start < 0: start = 0 res = ( cursor.sort( [ ("field_label", ASC), ("conductor_norm", ASC), ("conductor_label", ASC), ("iso_label", ASC), ("number", ASC), ] ) .skip(start) .limit(count) ) bread = [("Elliptic Curves", url_for(".index")), (nf_label, url_for(".show_ecnf1", nf=nf_label))] res = list(res) for e in res: e["field_knowl"] = nf_display_knowl(e["field_label"], getDBConnection(), e["field_label"]) info = {} info["field"] = nf_label info["query"] = query info["curves"] = res # [ECNF(e) for e in res] info["number"] = nres info["start"] = start info["count"] = count info["more"] = int(start + count < nres) info["field_pretty"] = field_pretty info["web_ainvs"] = web_ainvs if nres == 1: info["report"] = "unique match" else: if nres > count or start != 0: info["report"] = "displaying matches %s-%s of %s" % (start + 1, min(nres, start + count), nres) else: info["report"] = "displaying all %s matches" % nres t = "Elliptic Curves over %s" % field_pretty(nf_label) return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
def random_curve(): E = random_object_from_collection(db_ecnf()) return redirect( url_for( ".show_ecnf", nf=E["field_label"], conductor_label=E["conductor_label"], class_label=E["iso_label"], number=E["number"], ), 301, )
def show_ecnf1(nf): if nf == "1.1.1.1": return redirect(url_for("ec.rational_elliptic_curves", **request.args)) if request.args: return elliptic_curve_search(data=request.args) start = 0 count = 50 try: nf_label = nf_string_to_label(nf) except ValueError: return search_input_error() query = {'field_label': nf_label} cursor = db_ecnf().find(query) nres = cursor.count() if(start >= nres): start -= (1 + (start - nres) / count) * count if(start < 0): start = 0 res = cursor.sort([('field_label', ASC), ('conductor_norm', ASC), ('conductor_label', ASC), ('iso_nlabel', ASC), ('number', ASC)]).skip(start).limit(count) bread = [('Elliptic Curves', url_for(".index")), (nf_label, url_for('.show_ecnf1', nf=nf_label))] res = list(res) for e in res: e['field_knowl'] = nf_display_knowl(e['field_label'], getDBConnection(), field_pretty(e['field_label'])) info = {} info['field'] = nf_label info['query'] = query info['curves'] = res # [ECNF(e) for e in res] info['number'] = nres info['start'] = start info['count'] = count info['more'] = int(start + count < nres) info['field_pretty'] = field_pretty info['web_ainvs'] = web_ainvs #don't risk recomputing all the ecnf stats just to show curves for a single number field #if nf_label: #info['stats'] = ecnf_field_summary(nf_label) if nres == 1: info['report'] = 'unique match' else: if nres > count or start != 0: info['report'] = 'displaying matches %s-%s of %s' % (start + 1, min(nres, start + count), nres) else: info['report'] = 'displaying all %s matches' % nres t = 'Elliptic Curves over %s' % field_pretty(nf_label) return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t, learnmore=learnmore_list())
def download_ECNF_all(nf,conductor_label,class_label,number): conductor_label = unquote(conductor_label) conductor_label = convert_IQF_label(nf,conductor_label) try: nf_label = nf_string_to_label(nf) except ValueError: return search_input_error() label = "".join(["-".join([nf_label, conductor_label, class_label]), number]) data = db_ecnf().find_one({'label':label}, {'_id':False}) if data is None: return search_input_error() import json response = make_response(json.dumps(data)) response.headers['Content-type'] = 'text/plain' return response
def make_torsion_growth(self): try: tor_gro = self.tor_gro self.torsion_growth_data_exists = True except AttributeError: self.torsion_growth_data_exists = False return self.tg = tg = {} tg['data'] = tgextra = [] # find all base-changes of this curve in the database, if any from lmfdb.ecnf.WebEllipticCurve import db_ecnf bcs = [res['label'] for res in db_ecnf().find({'base_change': self.lmfdb_label}, projection={'label': True, '_id': False})] bcfs = [lab.split("-")[0] for lab in bcs] for F, T in tor_gro.items(): tg1 = {} tg1['bc'] = "Not in database" if ":" in F: F = F.replace(":",".") field_data = nf_display_knowl(F, getDBConnection(), field_pretty(F)) deg = int(F.split(".")[0]) bcc = [x for x,y in zip(bcs, bcfs) if y==F] if bcc: from lmfdb.ecnf.main import split_full_label F, NN, I, C = split_full_label(bcc[0]) tg1['bc'] = bcc[0] tg1['bc_url'] = url_for('ecnf.show_ecnf', nf=F, conductor_label=NN, class_label=I, number=C) else: field_data = web_latex_split_on_pm(coeff_to_poly(string2list(F))) deg = F.count(",") tg1['d'] = deg tg1['f'] = field_data tg1['t'] = '\(' + ' \\times '.join(['\Z/{}\Z'.format(n) for n in T.split(",")]) + '\)' tg1['m'] = 0 tgextra.append(tg1) tgextra.sort(key = lambda x: x['d']) tg['n'] = len(tgextra) lastd = 1 for tg1 in tgextra: d = tg1['d'] if d!=lastd: tg1['m'] = len([x for x in tgextra if x['d']==d]) lastd = d tg['maxd'] = max(db_ecstats().find_one({'_id': 'torsion_growth'})['degrees'])
def show_ecnf1(nf): if request.args: return elliptic_curve_search(data=request.args) start = 0 count = 20 query = {'field_label' : nf} cursor = db_ecnf().find(query) nres = cursor.count() if(start >= nres): start -= (1 + (start - nres) / count) * count if(start < 0): start = 0 res = cursor.sort([('field_label', ASC), ('conductor_norm', ASC), ('conductor_label', ASC), ('iso_label', ASC), ('number', ASC)]).skip(start).limit(count) bread = [('Elliptic Curves', url_for(".index")), (nf, url_for('.show_ecnf1', nf=nf))] res = list(res) for e in res: e['field_knowl'] = nf_display_knowl(e['field_label'], getDBConnection(), e['field_label']) info = {} info['field'] = nf info['query'] = query info['curves'] = res # [ECNF(e) for e in res] info['number'] = nres info['start'] = start info['count'] = count info['field_pretty'] = field_pretty info['web_ainvs'] = web_ainvs if nres == 1: info['report'] = 'unique match' else: if nres > count or start != 0: info['report'] = 'displaying matches %s-%s of %s' % (start + 1, min(nres, start + count), nres) else: info['report'] = 'displaying all %s matches' % nres t = 'Elliptic Curves over %s' % field_pretty(nf) return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
def make_class(self): # Create a list of the curves in the class from the database self.db_curves = [ c for c in db_ecnf().find({ 'field_label': self.field_label, 'conductor_norm': self.conductor_norm, 'conductor_label': self.conductor_label, 'iso_nlabel': self.iso_nlabel }).sort('number') ] # Rank or bounds try: self.rk = web_latex(self.db_curves[0]['rank']) except KeyError: self.rk = "?" try: self.rk_bnds = "%s...%s" % tuple(self.db_curves[0]['rank_bounds']) except KeyError: self.rank_bounds = [0, Infinity] self.rk_bnds = "not recorded" # Extract the isogeny degree matrix from the database if not hasattr(self, 'isogeny_matrix'): # this would happen if the class is initiated with a curve # which is not #1 in its class: self.isogeny_matrix = self.db_curves[0].isogeny_matrix self.isogeny_matrix = Matrix(self.isogeny_matrix) self.one_deg = ZZ(self.class_deg).is_prime() # Create isogeny graph: self.graph = make_graph(self.isogeny_matrix) P = self.graph.plot(edge_labels=True) self.graph_img = encode_plot(P) self.graph_link = '<img src="%s" width="200" height="150"/>' % self.graph_img self.isogeny_matrix_str = latex(Matrix(self.isogeny_matrix)) self.field = FIELD(self.field_label) self.field_name = field_pretty(self.field_label) self.field_knowl = nf_display_knowl(self.field_label, lmfdb.base.getDBConnection(), self.field_name) def curve_url(c): return url_for(".show_ecnf", nf=c['field_label'], conductor_label=c['conductor_label'], class_label=c['iso_label'], number=c['number']) self.curves = [[ c['short_label'], curve_url(c), web_ainvs(self.field_label, c['ainvs']) ] for c in self.db_curves] self.urls = {} self.urls['class'] = url_for(".show_ecnf_isoclass", nf=self.field_label, conductor_label=self.conductor_label, class_label=self.iso_label) self.urls['conductor'] = url_for(".show_ecnf_conductor", nf=self.field_label, conductor_label=self.conductor_label) self.urls['field'] = url_for('.show_ecnf1', nf=self.field_label) sig = self.signature totally_real = sig[1] == 0 imag_quadratic = sig == [0, 1] if totally_real: self.hmf_label = "-".join( [self.field_label, self.conductor_label, self.iso_label]) self.urls['hmf'] = url_for('hmf.render_hmf_webpage', field_label=self.field_label, label=self.hmf_label) if sig[0] <= 2: self.urls['Lfunction'] = url_for( "l_functions.l_function_ecnf_page", field_label=self.field_label, conductor_label=self.conductor_label, isogeny_class_label=self.iso_label) elif self.abs_disc**2 * self.conductor_norm < 40000: # we shouldn't trust the Lfun computed on the fly for large conductor self.urls['Lfunction'] = url_for( "l_functions.l_function_hmf_page", field=self.field_label, label=self.hmf_label, character='0', number='0') if imag_quadratic: self.bmf_label = "-".join( [self.field_label, self.conductor_label, self.iso_label]) self.bmf_url = url_for('bmf.render_bmf_webpage', field_label=self.field_label, level_label=self.conductor_label, label_suffix=self.iso_label) self.urls['Lfunction'] = url_for( "l_functions.l_function_ecnf_page", field_label=self.field_label, conductor_label=self.conductor_label, isogeny_class_label=self.iso_label) self.friends = [] if totally_real: self.friends += [('Hilbert Modular Form ' + self.hmf_label, self.urls['hmf'])] if imag_quadratic: #self.friends += [('Bianchi Modular Form %s not available' % self.bmf_label, '')] self.friends += [('Bianchi Modular Form %s' % self.bmf_label, self.bmf_url)] if 'Lfunction' in self.urls: self.friends += [('L-function', self.urls['Lfunction'])] else: self.friends += [('L-function not available', "")] self.properties = [('Base field', self.field_name), ('Label', self.class_label), (None, self.graph_link), ('Conductor', '%s' % self.conductor_label)] if self.rk != '?': self.properties += [('Rank', '%s' % self.rk)] else: if self.rk_bnds == 'not recorded': self.properties += [('Rank', '%s' % self.rk_bnds)] else: self.properties += [('Rank bounds', '%s' % self.rk_bnds)] self.bread = [('Elliptic Curves ', url_for(".index")), (self.field_label, self.urls['field']), (self.conductor_label, self.urls['conductor']), ('isogeny class %s' % self.short_label, self.urls['class'])]
def make_class(self): # Create a list of the curves in the class from the database self.db_curves = [c for c in db_ecnf().find( {'field_label': self.field_label, 'conductor_norm': self.conductor_norm, 'conductor_label': self.conductor_label, 'iso_nlabel': self.iso_nlabel}).sort('number')] # Rank or bounds try: self.rk = web_latex(self.db_curves[0]['rank']) except KeyError: self.rk = "?" try: self.rk_bnds = "%s...%s" % tuple(self.db_curves[0]['rank_bounds']) except KeyError: self.rank_bounds = [0, sage.rings.infinity.Infinity] self.rk_bnds = "not recorded" # Extract the isogeny degree matrix from the database if possible, else create it if hasattr(self, 'isogeny_matrix'): from sage.matrix.all import Matrix self.isogeny_matrix = Matrix(self.isogeny_matrix) else: self.isogeny_matrix = make_iso_matrix(self.db_curves) # Create isogeny graph: self.graph = make_graph(self.isogeny_matrix) P = self.graph.plot(edge_labels=True) self.graph_img = encode_plot(P) self.graph_link = '<img src="%s" width="200" height="150"/>' % self.graph_img self.isogeny_matrix_str = latex(matrix(self.isogeny_matrix)) self.field = field_pretty(self.field_label) self.field_knowl = nf_display_knowl(self.field_label, lmfdb.base.getDBConnection(), self.field) def curve_url(c): return url_for(".show_ecnf", nf=c['field_label'], conductor_label=c['conductor_label'], class_label=c['iso_label'], number=c['number']) self.curves = [[c['short_label'], curve_url(c), web_ainvs(self.field_label,c['ainvs'])] for c in self.db_curves] self.urls = {} self.urls['class'] = url_for(".show_ecnf_isoclass", nf=self.field_label, conductor_label=self.conductor_label, class_label=self.iso_label) self.urls['conductor'] = url_for(".show_ecnf_conductor", nf=self.field_label, conductor_label=self.conductor_label) self.urls['field'] = url_for('.show_ecnf1', nf=self.field_label) sig = self.signature totally_real = sig[1] == 0 imag_quadratic = sig == [0,1] if totally_real: self.hmf_label = "-".join([self.field_label, self.conductor_label, self.iso_label]) self.urls['hmf'] = url_for('hmf.render_hmf_webpage', field_label=self.field_label, label=self.hmf_label) self.urls['Lfunction'] = url_for("l_functions.l_function_hmf_page", field=self.field_label, label=self.hmf_label, character='0', number='0') if imag_quadratic: self.bmf_label = "-".join([self.field_label, self.conductor_label, self.iso_label]) self.friends = [] if totally_real: self.friends += [('Hilbert Modular Form ' + self.hmf_label, self.urls['hmf'])] self.friends += [('L-function', self.urls['Lfunction'])] if imag_quadratic: self.friends += [('Bianchi Modular Form %s not available' % self.bmf_label, '')] self.properties = [('Base field', self.field), ('Label', self.class_label), (None, self.graph_link), ('Conductor', '%s' % self.conductor_label) ] if self.rk != '?': self.properties += [('Rank', '%s' % self.rk)] else: if self.rk_bnds == 'not recorded': self.properties += [('Rank', '%s' % self.rk_bnds)] else: self.properties += [('Rank bounds', '%s' % self.rk_bnds)] self.bread = [('Elliptic Curves ', url_for(".index")), (self.field_label, self.urls['field']), (self.conductor_label, self.urls['conductor']), ('isogeny class %s' % self.short_label, self.urls['class'])]
def download_search(info): dltype = info['Submit'] delim = 'bracket' com = r'\\' # single line comment start com1 = '' # multiline comment start com2 = '' # multiline comment end filename = 'elliptic_curves.gp' mydate = time.strftime("%d %B %Y") if dltype == 'sage': com = '#' filename = 'elliptic_curves.sage' if dltype == 'magma': com = '' com1 = '/*' com2 = '*/' delim = 'magma' filename = 'elliptic_curves.m' s = com1 + "\n" s += com + ' Elliptic curves downloaded from the LMFDB downloaded on %s.\n'%(mydate) s += com + ' Below is a list called data. Each entry has the form:\n' s += com + ' [[field_poly],[Weierstrass Coefficients, constant first in increasing degree]]\n' s += '\n' + com2 s += '\n' if dltype == 'magma': s += 'P<x> := PolynomialRing(Rationals()); \n' s += 'data := [' elif dltype == 'sage': s += 'x = polygen(QQ) \n' s += 'data = [ ' else: s += 'data = [ ' s += '\\\n' nf_dict = {} res = db_ecnf().find(ast.literal_eval(info["query"])) for f in res: nf = str(f['field_label']) # look up number field and see if we already have the min poly if nf in nf_dict: poly = nf_dict[nf] else: poly = str(WebNumberField(f['field_label']).poly()) nf_dict[nf] = poly entry = str(f['ainvs']) entry = entry.replace('u','') entry = entry.replace('\'','') s += '[[' + poly + '], ' + entry + '],\\\n' s = s[:-3] s += ']\n' if delim == 'brace': s = s.replace('[', '{') s = s.replace(']', '}') if delim == 'magma': s = s.replace('[', '[*') s = s.replace(']', '*]') s += ';' strIO = StringIO.StringIO() strIO.write(s) strIO.seek(0) return send_file(strIO, attachment_filename=filename, as_attachment=True)
def download_search(info): dltype = info['Submit'] delim = 'bracket' com = r'\\' # single line comment start com1 = '' # multiline comment start com2 = '' # multiline comment end filename = 'elliptic_curves.gp' mydate = time.strftime("%d %B %Y") if dltype == 'sage': com = '#' filename = 'elliptic_curves.sage' if dltype == 'magma': com = '' com1 = '/*' com2 = '*/' delim = 'magma' filename = 'elliptic_curves.m' s = com1 + "\n" s += com + ' Elliptic curves downloaded from the LMFDB downloaded on %s.\n' % ( mydate) s += com + ' Below is a list called data. Each entry has the form:\n' s += com + ' [[field_poly],[Weierstrass Coefficients, constant first in increasing degree]]\n' s += '\n' + com2 s += '\n' if dltype == 'magma': s += 'P<x> := PolynomialRing(Rationals()); \n' s += 'data := [' elif dltype == 'sage': s += 'x = polygen(QQ) \n' s += 'data = [ ' else: s += 'data = [ ' s += '\\\n' nf_dict = {} res = db_ecnf().find(ast.literal_eval(info["query"])) for f in res: nf = str(f['field_label']) # look up number field and see if we already have the min poly if nf in nf_dict: poly = nf_dict[nf] else: poly = str(WebNumberField(f['field_label']).poly()) nf_dict[nf] = poly entry = str(f['ainvs']) entry = entry.replace('u', '') entry = entry.replace('\'', '') entry = entry.replace(';', '],[') s += '[[' + poly + '], [[' + entry + ']]],\\\n' s = s[:-3] s += ']\n' if delim == 'brace': s = s.replace('[', '{') s = s.replace(']', '}') if delim == 'magma': s = s.replace('[', '[*') s = s.replace(']', '*]') s += ';' strIO = StringIO.StringIO() strIO.write(s) strIO.seek(0) return send_file(strIO, attachment_filename=filename, as_attachment=True, add_etags=False)
def elliptic_curve_search(**args): info = to_dict(args["data"]) if "download" in info and info["download"] != 0: return download_search(info) if not "query" in info: info["query"] = {} bread = [("Elliptic Curves", url_for(".index")), ("Search Results", ".")] if "jump" in info: label = info.get("label", "").replace(" ", "") # This label should be a full isogeny class label or a full # curve label (including the field_label component) try: nf, cond_label, iso_label, number = split_full_label(label.strip()) except ValueError: info["err"] = "" return search_input_error(info, bread) return show_ecnf(nf, cond_label, iso_label, number) query = {} try: parse_ints(info, query, "conductor_norm") parse_noop(info, query, "conductor_label") parse_nf_string(info, query, "field", name="base number field", qfield="field_label") parse_nf_elt(info, query, "jinv", name="j-invariant") parse_ints(info, query, "torsion", name="Torsion order", qfield="torsion_order") parse_bracketed_posints(info, query, "torsion_structure", maxlength=2) if "torsion_structure" in query and not "torsion_order" in query: query["torsion_order"] = reduce(mul, [int(n) for n in query["torsion_structure"]], 1) except ValueError: return search_input_error(info, bread) if "include_isogenous" in info and info["include_isogenous"] == "off": info["number"] = 1 query["number"] = 1 if "include_base_change" in info and info["include_base_change"] == "off": query["base_change"] = [] else: info["include_base_change"] = "on" if "include_Q_curves" in info: if info["include_Q_curves"] == "exclude": query["q_curve"] = False elif info["include_Q_curves"] == "only": query["q_curve"] = True if "include_cm" in info: if info["include_cm"] == "exclude": query["cm"] = 0 elif info["include_cm"] == "only": query["cm"] = {"$ne": 0} info["query"] = query count = parse_count(info, 50) start = parse_start(info) # make the query and trim results according to start/count: cursor = db_ecnf().find(query) nres = cursor.count() if start >= nres: start -= (1 + (start - nres) / count) * count if start < 0: start = 0 res = ( cursor.sort( [ ("field_label", ASC), ("conductor_norm", ASC), ("conductor_label", ASC), ("iso_nlabel", ASC), ("number", ASC), ] ) .skip(start) .limit(count) ) res = list(res) for e in res: e["numb"] = str(e["number"]) e["field_knowl"] = nf_display_knowl(e["field_label"], getDBConnection(), field_pretty(e["field_label"])) info["curves"] = res # [ECNF(e) for e in res] info["number"] = nres info["start"] = start info["count"] = count info["more"] = int(start + count < nres) info["field_pretty"] = field_pretty info["web_ainvs"] = web_ainvs if nres == 1: info["report"] = "unique match" else: if nres > count or start != 0: info["report"] = "displaying matches %s-%s of %s" % (start + 1, min(nres, start + count), nres) else: info["report"] = "displaying all %s matches" % nres t = "Elliptic Curve search results" return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
def elliptic_curve_search(**args): info = to_dict(args['data']) if 'jump' in info: label = info.get('label', '').replace(" ", "") # This label should be a full isogeny class label or a full # curve label (including the field_label component) try: nf, cond_label, iso_label, number = split_full_label(label) except IndexError: if not 'query' in info: info['query'] = {} bread = [("Elliptic Curves", url_for(".index"))] info['err'] = 'No elliptic curve in the database has label %s.' % label return search_input_error(info, bread) return show_ecnf(nf, cond_label, iso_label, number) query = {} bread = [('Elliptic Curves', url_for(".index")), ('Search Results', '.')] if 'conductor_norm' in info: Nnorm = clean_input(info['conductor_norm']) Nnorm = Nnorm.replace('..', '-').replace(' ', '') tmp = parse_range2(Nnorm, 'conductor_norm') if tmp[0] == '$or' and '$or' in query: newors = [] for y in tmp[1]: oldors = [dict.copy(x) for x in query['$or']] for x in oldors: x.update(y) newors.extend(oldors) tmp[1] = newors query[tmp[0]] = tmp[1] if 'conductor_label' in info: query['conductor_label'] = info['conductor_label'] if 'jinv' in info: query['jinv'] = info['jinv'] if info.get('torsion'): ran = info['torsion'] = clean_input(info['torsion']) ran = ran.replace('..', '-').replace(' ', '') if not LIST_RE.match(ran): info['err'] = 'Error parsing input for the torsion order. It needs to be an integer (such as 5), a range of integers (such as 2-10 or 2..10), or a comma-separated list of these (such as 4,9,16 or 4-25, 81-121).' return search_input_error(info, bread) # Past input check tmp = parse_range2(ran, 'torsion_order') # work around syntax for $or # we have to foil out multiple or conditions if tmp[0] == '$or' and '$or' in query: newors = [] for y in tmp[1]: oldors = [dict.copy(x) for x in query['$or']] for x in oldors: x.update(y) newors.extend(oldors) tmp[1] = newors query[tmp[0]] = tmp[1] if 'torsion_structure' in info and info['torsion_structure']: info['torsion_structure'] = clean_input(info['torsion_structure']) if not TORS_RE.match(info['torsion_structure']): info['err'] = 'Error parsing input for the torsion structure. It needs to be one or more integers in square brackets, such as [6], [2,2], or [2,4]. Moreover, each integer should be bigger than 1, and each divides the next.' return search_input_error(info, bread) query['torsion_structure'] = parse_list(info['torsion_structure']) if 'include_isogenous' in info and info['include_isogenous'] == 'off': query['number'] = 1 if 'include_base_change' in info and info['include_base_change'] == 'off': query['base_change'] = [] else: info['include_base_change'] = "on" if 'field' in info: query['field_label'] = parse_field_string(info['field']) info['query'] = query # process count and start if not default: count_default = 50 if info.get('count'): try: count = int(info['count']) except: count = count_default else: count = count_default start_default = 0 if info.get('start'): try: start = int(info['start']) if(start < 0): start += (1 - (start + 1) / count) * count except: start = start_default else: start = start_default # make the query and trim results according to start/count: cursor = db_ecnf().find(query) nres = cursor.count() if(start >= nres): start -= (1 + (start - nres) / count) * count if(start < 0): start = 0 res = cursor.sort([('field_label', ASC), ('conductor_norm', ASC), ('conductor_label', ASC), ('iso_label', ASC), ('number', ASC)]).skip(start).limit(count) res = list(res) for e in res: e['numb'] = str(e['number']) e['field_knowl'] = nf_display_knowl(e['field_label'], getDBConnection(), e['field_label']) info['curves'] = res # [ECNF(e) for e in res] info['number'] = nres info['start'] = start info['count'] = count info['more'] = int(start + count < nres) info['field_pretty'] = field_pretty info['web_ainvs'] = web_ainvs if nres == 1: info['report'] = 'unique match' else: if nres > count or start != 0: info['report'] = 'displaying matches %s-%s of %s' % (start + 1, min(nres, start + count), nres) else: info['report'] = 'displaying all %s matches' % nres t = 'Elliptic Curve search results' return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
def make_class(self): # Create a list of the curves in the class from the database self.db_curves = [c for c in db_ecnf().find( {'field_label': self.field_label, 'conductor_norm': self.conductor_norm, 'conductor_label': self.conductor_label, 'iso_nlabel': self.iso_nlabel}).sort('number')] # Rank or bounds try: self.rk = web_latex(self.db_curves[0]['rank']) except KeyError: self.rk = "?" try: self.rk_bnds = "%s...%s" % tuple(self.db_curves[0]['rank_bounds']) except KeyError: self.rank_bounds = [0, Infinity] self.rk_bnds = "not recorded" # Extract the isogeny degree matrix from the database if not hasattr(self, 'isogeny_matrix'): # this would happen if the class is initiated with a curve # which is not #1 in its class: self.isogeny_matrix = self.db_curves[0].isogeny_matrix self.isogeny_matrix = Matrix(self.isogeny_matrix) self.one_deg = ZZ(self.class_deg).is_prime() # Create isogeny graph: self.graph = make_graph(self.isogeny_matrix) P = self.graph.plot(edge_labels=True) self.graph_img = encode_plot(P) self.graph_link = '<img src="%s" width="200" height="150"/>' % self.graph_img self.isogeny_matrix_str = latex(Matrix(self.isogeny_matrix)) self.field = FIELD(self.field_label) self.field_name = field_pretty(self.field_label) self.field_knowl = nf_display_knowl(self.field_label, lmfdb.base.getDBConnection(), self.field_name) def curve_url(c): return url_for(".show_ecnf", nf=c['field_label'], conductor_label=c['conductor_label'], class_label=c['iso_label'], number=c['number']) self.curves = [[c['short_label'], curve_url(c), web_ainvs(self.field_label,c['ainvs'])] for c in self.db_curves] self.urls = {} self.urls['class'] = url_for(".show_ecnf_isoclass", nf=self.field_label, conductor_label=self.conductor_label, class_label=self.iso_label) self.urls['conductor'] = url_for(".show_ecnf_conductor", nf=self.field_label, conductor_label=self.conductor_label) self.urls['field'] = url_for('.show_ecnf1', nf=self.field_label) sig = self.signature totally_real = sig[1] == 0 imag_quadratic = sig == [0,1] if totally_real: self.hmf_label = "-".join([self.field_label, self.conductor_label, self.iso_label]) self.urls['hmf'] = url_for('hmf.render_hmf_webpage', field_label=self.field_label, label=self.hmf_label) if sig[0] <= 2: self.urls['Lfunction'] = url_for("l_functions.l_function_ecnf_page", field_label=self.field_label, conductor_label=self.conductor_label, isogeny_class_label=self.iso_label) elif self.abs_disc ** 2 * self.conductor_norm < 40000: # we shouldn't trust the Lfun computed on the fly for large conductor self.urls['Lfunction'] = url_for("l_functions.l_function_hmf_page", field=self.field_label, label=self.hmf_label, character='0', number='0') if imag_quadratic: self.bmf_label = "-".join([self.field_label, self.conductor_label, self.iso_label]) self.bmf_url = url_for('bmf.render_bmf_webpage', field_label=self.field_label, level_label=self.conductor_label, label_suffix=self.iso_label) self.urls['Lfunction'] = url_for("l_functions.l_function_ecnf_page", field_label=self.field_label, conductor_label=self.conductor_label, isogeny_class_label=self.iso_label) self.friends = [] if totally_real: self.friends += [('Hilbert Modular Form ' + self.hmf_label, self.urls['hmf'])] if imag_quadratic: #self.friends += [('Bianchi Modular Form %s not available' % self.bmf_label, '')] self.friends += [('Bianchi Modular Form %s' % self.bmf_label, self.bmf_url)] if 'Lfunction' in self.urls: self.friends += [('L-function', self.urls['Lfunction'])] else: self.friends += [('L-function not available', "")] self.properties = [('Base field', self.field_name), ('Label', self.class_label), (None, self.graph_link), ('Conductor', '%s' % self.conductor_label) ] if self.rk != '?': self.properties += [('Rank', '%s' % self.rk)] else: if self.rk_bnds == 'not recorded': self.properties += [('Rank', '%s' % self.rk_bnds)] else: self.properties += [('Rank bounds', '%s' % self.rk_bnds)] self.bread = [('Elliptic Curves ', url_for(".index")), (self.field_label, self.urls['field']), (self.conductor_label, self.urls['conductor']), ('isogeny class %s' % self.short_label, self.urls['class'])]
def random_curve(): from sage.misc.prandom import randint n = get_stats().counts()['ncurves'] n = randint(0,n-1) E = db_ecnf().find()[n] return redirect(url_for(".show_ecnf", nf=E['field_label'], conductor_label=E['conductor_label'], class_label=E['iso_label'], number=E['number']), 301)
def elliptic_curve_search(**args): info = to_dict(args["data"]) if "jump" in info: label = info.get("label", "").replace(" ", "") # This label should be a full isogeny class label or a full # curve label (including the field_label component) label_parts = label.split("-", 2) nf = label_parts[0] cond_label = label_parts[1] cur_label = label_parts[2] return show_ecnf(nf, cond_label, cur_label) ##!!! query = {} if "conductor_norm" in info: Nnorm = clean_input(info["conductor_norm"]) Nnorm = Nnorm.replace("..", "-").replace(" ", "") tmp = parse_range2(Nnorm, "conductor_norm") if tmp[0] == "$or" and "$or" in query: newors = [] for y in tmp[1]: oldors = [dict.copy(x) for x in query["$or"]] for x in oldors: x.update(y) newors.extend(oldors) tmp[1] = newors query[tmp[0]] = tmp[1] if "conductor_label" in info: query["conductor_label"] = info["conductor_label"] if "include_isogenous" in info and info["include_isogenous"] == "off": query["number"] = 1 if "field" in info: query["field_label"] = info["field"] info["query"] = query # process count and start if not default: count_default = 50 if info.get("count"): try: count = int(info["count"]) except: count = count_default else: count = count_default start_default = 0 if info.get("start"): try: start = int(info["start"]) if start < 0: start += (1 - (start + 1) / count) * count except: start = start_default else: start = start_default # make the query and trim results according to start/count: cursor = db_ecnf().find(query) nres = cursor.count() if start >= nres: start -= (1 + (start - nres) / count) * count if start < 0: start = 0 res = ( cursor.sort( [ ("field_label", ASC), ("conductor_norm", ASC), ("conductor_label", ASC), ("iso_label", ASC), ("number", ASC), ] ) .skip(start) .limit(count) ) bread = [("Elliptic Curves", url_for(".index")), ("Search Results", ".")] res = list(res) for e in res: e["numb"] = str(e["number"]) e["field_knowl"] = nf_display_knowl(e["field_label"], getDBConnection(), e["field_label"]) info["curves"] = res # [ECNF(e) for e in res] info["number"] = nres info["start"] = start info["count"] = count info["more"] = int(start + count < nres) info["field_pretty"] = field_pretty info["web_ainvs"] = web_ainvs if nres == 1: info["report"] = "unique match" else: if nres > count or start != 0: info["report"] = "displaying matches %s-%s of %s" % (start + 1, min(nres, start + count), nres) else: info["report"] = "displaying all %s matches" % nres t = "Elliptic Curve search results" return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
def elliptic_curve_search(**args): info = to_dict(args['data']) if 'jump' in info: label = info.get('label', '').replace(" ", "") label_parts = label.split("-",1) nf = label_parts[0] label = label_parts[1] return show_ecnf(nf,label) query = {} if 'conductor_norm' in info: Nnorm = clean_input(info['conductor_norm']) Nnorm = Nnorm.replace('..', '-').replace(' ', '') tmp = parse_range2(Nnorm, 'conductor_norm') if tmp[0] == '$or' and '$or' in query: newors = [] for y in tmp[1]: oldors = [dict.copy(x) for x in query['$or']] for x in oldors: x.update(y) newors.extend(oldors) tmp[1] = newors query[tmp[0]] = tmp[1] if 'include_isogenous' in info and info['include_isogenous'] == 'off': query['number'] = 1 if 'field' in info: query['field_label'] = info['field'] info['query'] = query # process count and start if not default: count_default = 20 if info.get('count'): try: count = int(info['count']) except: count = count_default else: count = count_default start_default = 0 if info.get('start'): try: start = int(info['start']) if(start < 0): start += (1 - (start + 1) / count) * count except: start = start_default else: start = start_default # make the query and trim results according to start/count: cursor = db_ecnf().find(query) nres = cursor.count() if(start >= nres): start -= (1 + (start - nres) / count) * count if(start < 0): start = 0 res = cursor.sort([('field_label', ASC), ('conductor_norm', ASC), ('conductor_label', ASC), ('iso_label', ASC), ('number', ASC)]).skip(start).limit(count) bread = []#[('Elliptic Curves over Number Fields', url_for(".elliptic_curve_search")), ] bread = [('Elliptic Curves', url_for(".index")), ('Search Results', '.')] res = list(res) for e in res: e['field_knowl'] = nf_display_knowl(e['field_label'], getDBConnection(), e['field_label']) info['curves'] = res # [ECNF(e) for e in res] info['number'] = nres info['start'] = start info['count'] = count info['field_pretty'] = field_pretty info['web_ainvs'] = web_ainvs if nres == 1: info['report'] = 'unique match' else: if nres > count or start != 0: info['report'] = 'displaying matches %s-%s of %s' % (start + 1, min(nres, start + count), nres) else: info['report'] = 'displaying all %s matches' % nres t = 'Elliptic Curve search results' return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
def elliptic_curve_search(**args): info = to_dict(args["data"]) if "jump" in info: label = info.get("label", "").replace(" ", "") # This label should be a full isogeny class label or a full # curve label (including the field_label component) try: nf, cond_label, iso_label, number = split_full_label(label) except IndexError: if not "query" in info: info["query"] = {} bread = [("Elliptic Curves", url_for(".index"))] info["err"] = "No elliptic curve in the database has label %s." % label return search_input_error(info, bread) return show_ecnf(nf, cond_label, iso_label, number) query = {} bread = [("Elliptic Curves", url_for(".index")), ("Search Results", ".")] if "conductor_norm" in info: Nnorm = clean_input(info["conductor_norm"]) Nnorm = Nnorm.replace("..", "-").replace(" ", "") tmp = parse_range2(Nnorm, "conductor_norm") if tmp[0] == "$or" and "$or" in query: newors = [] for y in tmp[1]: oldors = [dict.copy(x) for x in query["$or"]] for x in oldors: x.update(y) newors.extend(oldors) tmp[1] = newors query[tmp[0]] = tmp[1] if "conductor_label" in info: query["conductor_label"] = info["conductor_label"] if "jinv" in info: query["jinv"] = info["jinv"] if info.get("torsion"): ran = info["torsion"] = clean_input(info["torsion"]) ran = ran.replace("..", "-").replace(" ", "") if not LIST_RE.match(ran): info[ "err" ] = "Error parsing input for the torsion order. It needs to be an integer (such as 5), a range of integers (such as 2-10 or 2..10), or a comma-separated list of these (such as 4,9,16 or 4-25, 81-121)." return search_input_error(info, bread) # Past input check tmp = parse_range2(ran, "torsion_order") # work around syntax for $or # we have to foil out multiple or conditions if tmp[0] == "$or" and "$or" in query: newors = [] for y in tmp[1]: oldors = [dict.copy(x) for x in query["$or"]] for x in oldors: x.update(y) newors.extend(oldors) tmp[1] = newors query[tmp[0]] = tmp[1] if "torsion_structure" in info and info["torsion_structure"]: res = parse_torsion_structure(info["torsion_structure"], 2) if "Error" in res: info["err"] = res return search_input_error(info, bread) # update info for repeat searches info["torsion_structure"] = str(res).replace(" ", "") query["torsion_structure"] = [int(r) for r in res] if "include_isogenous" in info and info["include_isogenous"] == "off": query["number"] = 1 if "include_base_change" in info and info["include_base_change"] == "off": query["base_change"] = [] else: info["include_base_change"] = "on" if "field" in info: query["field_label"] = parse_field_string(info["field"]) info["query"] = query # process count and start if not default: count_default = 50 if info.get("count"): try: count = int(info["count"]) except: count = count_default else: count = count_default start_default = 0 if info.get("start"): try: start = int(info["start"]) if start < 0: start += (1 - (start + 1) / count) * count except: start = start_default else: start = start_default # make the query and trim results according to start/count: cursor = db_ecnf().find(query) nres = cursor.count() if start >= nres: start -= (1 + (start - nres) / count) * count if start < 0: start = 0 res = ( cursor.sort( [ ("field_label", ASC), ("conductor_norm", ASC), ("conductor_label", ASC), ("iso_label", ASC), ("number", ASC), ] ) .skip(start) .limit(count) ) res = list(res) for e in res: e["numb"] = str(e["number"]) e["field_knowl"] = nf_display_knowl(e["field_label"], getDBConnection(), e["field_label"]) info["curves"] = res # [ECNF(e) for e in res] info["number"] = nres info["start"] = start info["count"] = count info["more"] = int(start + count < nres) info["field_pretty"] = field_pretty info["web_ainvs"] = web_ainvs if nres == 1: info["report"] = "unique match" else: if nres > count or start != 0: info["report"] = "displaying matches %s-%s of %s" % (start + 1, min(nres, start + count), nres) else: info["report"] = "displaying all %s matches" % nres t = "Elliptic Curve search results" return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
def elliptic_curve_search(info): if info.get('download') == '1' and info.get('Submit') and info.get( 'query'): return download_search(info) if not 'query' in info: info['query'] = {} bread = info.get('bread', [('Elliptic Curves', url_for(".index")), ('Search Results', '.')]) if 'jump' in info: label = info.get('label', '').replace(" ", "") # This label should be a full isogeny class label or a full # curve label (including the field_label component) try: nf, cond_label, iso_label, number = split_full_label(label.strip()) except ValueError: info['err'] = '' return search_input_error(info, bread) return redirect( url_for(".show_ecnf", nf=nf, conductor_label=cond_label, class_label=iso_label, number=number), 301) query = {} if 'jinv' in info: if info.get('field', '').strip() == '2.2.5.1': info['jinv'] = info['jinv'].replace('phi', 'a') if info.get('field', '').strip() == '2.0.4.1': info['jinv'] = info['jinv'].replace('i', 'a') try: parse_ints(info, query, 'conductor_norm') parse_noop(info, query, 'conductor_label') parse_nf_string(info, query, 'field', name="base number field", qfield='field_label') parse_nf_elt(info, query, 'jinv', name='j-invariant') parse_ints(info, query, 'torsion', name='Torsion order', qfield='torsion_order') parse_bracketed_posints(info, query, 'torsion_structure', maxlength=2) if 'torsion_structure' in query and not 'torsion_order' in query: query['torsion_order'] = reduce( mul, [int(n) for n in query['torsion_structure']], 1) parse_ints(info, query, field='isodeg', qfield='isogeny_degrees') except (TypeError, ValueError): return search_input_error(info, bread) if query.get('jinv'): query['jinv'] = ','.join(query['jinv']) if query.get('field_label') == '1.1.1.1': return redirect(url_for("ec.rational_elliptic_curves", **request.args), 301) if 'include_isogenous' in info and info['include_isogenous'] == 'off': info['number'] = 1 query['number'] = 1 if 'include_base_change' in info and info['include_base_change'] == 'off': query['base_change'] = [] else: info['include_base_change'] = "on" if 'include_Q_curves' in info: if info['include_Q_curves'] == 'exclude': query['q_curve'] = False elif info['include_Q_curves'] == 'only': query['q_curve'] = True if 'include_cm' in info: if info['include_cm'] == 'exclude': query['cm'] = 0 elif info['include_cm'] == 'only': query['cm'] = {'$ne': 0} info['query'] = query count = parse_count(info, 50) start = parse_start(info) # make the query and trim results according to start/count: cursor = db_ecnf().find(query) nres = cursor.count() if (start >= nres): start -= (1 + (start - nres) / count) * count if (start < 0): start = 0 res = cursor.sort([('field_label', ASC), ('conductor_norm', ASC), ('conductor_label', ASC), ('iso_nlabel', ASC), ('number', ASC)]).skip(start).limit(count) res = list(res) for e in res: e['numb'] = str(e['number']) e['field_knowl'] = nf_display_knowl(e['field_label'], getDBConnection(), field_pretty(e['field_label'])) info['curves'] = res # [ECNF(e) for e in res] info['number'] = nres info['start'] = start info['count'] = count info['more'] = int(start + count < nres) info['field_pretty'] = field_pretty info['web_ainvs'] = web_ainvs if nres == 1: info['report'] = 'unique match' else: if nres > count or start != 0: info['report'] = 'displaying matches %s-%s of %s' % ( start + 1, min(nres, start + count), nres) else: info['report'] = 'displaying all %s matches' % nres t = info.get('title', 'Elliptic Curve search results') return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
def render_hmf_webpage(**args): if 'data' in args: data = args['data'] label = data['label'] else: label = str(args['label']) data = get_hmf(label) if data is None: flash(Markup("Error: <span style='color:black'>%s</span> is not a valid Hilbert modular form label. It must be of the form (number field label) - (level label) - (orbit label) separated by dashes, such as 2.2.5.1-31.1-a" % args['label']), "error") return search_input_error() info = {} try: info['count'] = args['count'] except KeyError: info['count'] = 10 hmf_field = get_hmf_field(data['field_label']) gen_name = findvar(hmf_field['ideals']) nf = WebNumberField(data['field_label'], gen_name=gen_name) info['hmf_field'] = hmf_field info['field'] = nf info['base_galois_group'] = nf.galois_string() info['field_degree'] = nf.degree() info['field_disc'] = str(nf.disc()) info['field_poly'] = teXify_pol(str(nf.poly())) info.update(data) info['downloads'] = [ ('Download to Magma', url_for(".render_hmf_webpage_download", field_label=info['field_label'], label=info['label'], download_type='magma')), ('Download to Sage', url_for(".render_hmf_webpage_download", field_label=info['field_label'], label=info['label'], download_type='sage')) ] if hmf_field['narrow_class_no'] == 1 and nf.disc()**2 * data['level_norm'] < 40000: info['friends'] = [('L-function', url_for("l_functions.l_function_hmf_page", field=info['field_label'], label=info['label'], character='0', number='0'))] else: info['friends'] = [('L-function not available', "")] if data['dimension'] == 1: # Try to attach associated elliptic curve lab = split_class_label(info['label']) ec_from_hmf = db_ecnf().find_one({"label": label + '1'}) if ec_from_hmf == None: info['friends'] += [('Elliptic curve not available', "")] else: info['friends'] += [('Isogeny class ' + info['label'], url_for("ecnf.show_ecnf_isoclass", nf=lab[0], conductor_label=lab[1], class_label=lab[2]))] bread = [("Modular Forms", url_for('mf.modular_form_main_page')), ('Hilbert Modular Forms', url_for(".hilbert_modular_form_render_webpage")), ('%s' % data['label'], ' ')] t = "Hilbert Cusp Form %s" % info['label'] forms_space = db_forms().find( {'field_label': data['field_label'], 'level_ideal': data['level_ideal']},{'dimension':True}) dim_space = 0 for v in forms_space: dim_space += v['dimension'] info['newspace_dimension'] = dim_space # Get hecke_polynomial, hecke_eigenvalues and AL_eigenvalues try: numeigs = request.args['numeigs'] numeigs = int(numeigs) except: numeigs = 20 info['numeigs'] = numeigs hecke_pol = data['hecke_polynomial'] eigs = data['hecke_eigenvalues'] eigs = eigs[:min(len(eigs), numeigs)] AL_eigs = data['AL_eigenvalues'] primes = hmf_field['primes'] n = min(len(eigs), len(primes)) info['eigs'] = [{'eigenvalue': add_space_if_positive(teXify_pol(eigs[i])), 'prime_ideal': teXify_pol(primes[i]), 'prime_norm': primes[i][1:primes[i].index(',')]} for i in range(n)] try: display_eigs = request.args['display_eigs'] if display_eigs in ['True', 'true', '1', 'yes']: display_eigs = True else: display_eigs = False except KeyError: display_eigs = False if 'numeigs' in request.args: display_eigs = True info['hecke_polynomial'] = web_latex_split_on_pm(teXify_pol(hecke_pol)) if not AL_eigs: # empty list if data['level_norm']==1: # OK, no bad primes info['AL_eigs'] = 'none' else: # not OK, AL eigs are missing info['AL_eigs'] = 'missing' else: info['AL_eigs'] = [{'eigenvalue': teXify_pol(al[1]), 'prime_ideal': teXify_pol(al[0]), 'prime_norm': al[0][1:al[0].index(',')]} for al in data['AL_eigenvalues']] max_eig_len = max([len(eig['eigenvalue']) for eig in info['eigs']]) display_eigs = display_eigs or (max_eig_len<=300) info['display_eigs'] = display_eigs if not display_eigs: for eig in info['eigs']: if len(eig['eigenvalue']) > 300: eig['eigenvalue'] = '...' info['level_ideal'] = teXify_pol(info['level_ideal']) if 'is_CM' in data: is_CM = data['is_CM'] else: is_CM = '?' info['is_CM'] = is_CM if 'is_base_change' in data: is_base_change = data['is_base_change'] else: is_base_change = '?' info['is_base_change'] = is_base_change if 'q_expansions' in data: info['q_expansions'] = data['q_expansions'] properties2 = [('Base field', '%s' % info['field'].field_pretty()), ('Weight', '%s' % data['weight']), ('Level norm', '%s' % data['level_norm']), ('Level', '$' + teXify_pol(data['level_ideal']) + '$'), ('Label', '%s' % data['label']), ('Dimension', '%s' % data['dimension']), ('CM', is_CM), ('Base change', is_base_change) ] return render_template("hilbert_modular_form.html", downloads=info["downloads"], info=info, properties2=properties2, credit=hmf_credit, title=t, bread=bread, friends=info['friends'], learnmore=learnmore_list())
def render_hmf_webpage(**args): C = getDBConnection() if 'data' in args: data = args['data'] label = data['label'] else: label = str(args['label']) data = C.hmfs.forms.find_one({'label': label}) if data is None: return "No such form" info = {} try: info['count'] = args['count'] except KeyError: info['count'] = 10 try: numeigs = request.args['numeigs'] numeigs = int(numeigs) except: numeigs = 20 hmf_field = C.hmfs.fields.find_one({'label': data['field_label']}) gen_name = findvar(hmf_field['ideals']) nf = WebNumberField(data['field_label'], gen_name=gen_name) info['hmf_field'] = hmf_field info['field'] = nf info['base_galois_group'] = nf.galois_string() info['field_degree'] = nf.degree() info['field_disc'] = str(nf.disc()) info['field_poly'] = teXify_pol(str(nf.poly())) info.update(data) info['downloads'] = [('Download to Magma', url_for(".render_hmf_webpage_download", field_label=info['field_label'], label=info['label'], download_type='magma')), ('Download to Sage', url_for(".render_hmf_webpage_download", field_label=info['field_label'], label=info['label'], download_type='sage'))] if hmf_field['narrow_class_no'] == 1 and nf.disc( )**2 * data['level_norm'] < 40000: info['friends'] = [('L-function', url_for("l_functions.l_function_hmf_page", field=info['field_label'], label=info['label'], character='0', number='0'))] else: info['friends'] = [('L-function not available', "")] if data['dimension'] == 1: # Try to attach associated elliptic curve lab = split_class_label(info['label']) ec_from_hmf = db_ecnf().find_one({"label": label + '1'}) if ec_from_hmf == None: info['friends'] += [('Elliptic curve not available', "")] else: info['friends'] += [('Isogeny class ' + info['label'], url_for("ecnf.show_ecnf_isoclass", nf=lab[0], conductor_label=lab[1], class_label=lab[2]))] bread = [('Hilbert Modular Forms', url_for(".hilbert_modular_form_render_webpage")), ('%s' % data['label'], ' ')] t = "Hilbert Cusp Form %s" % info['label'] forms_space = C.hmfs.forms.find({ 'field_label': data['field_label'], 'level_ideal': data['level_ideal'] }) dim_space = 0 for v in forms_space: dim_space += v['dimension'] info['newspace_dimension'] = dim_space w = polygen(QQ, 'w') e = polygen(QQ, 'e') eigs = data['hecke_eigenvalues'] eigs = eigs[:min(len(eigs), numeigs)] primes = hmf_field['primes'] n = min(len(eigs), len(primes)) info['eigs'] = [{ 'eigenvalue': teXify_pol(eigs[i]), 'prime_ideal': teXify_pol(primes[i]), 'prime_norm': primes[i][1:primes[i].index(',')] } for i in range(n)] try: display_eigs = request.args['display_eigs'] if display_eigs in ['True', 'true', '1', 'yes']: display_eigs = True else: display_eigs = False except KeyError: display_eigs = False if 'numeigs' in request.args: display_eigs = True info['hecke_polynomial'] = teXify_pol(info['hecke_polynomial']) if 'AL_eigenvalues_fixed' in data: if data['AL_eigenvalues_fixed'] == 'done': info['AL_eigs'] = [{ 'eigenvalue': teXify_pol(al[1]), 'prime_ideal': teXify_pol(al[0]), 'prime_norm': al[0][1:al[0].index(',')] } for al in data['AL_eigenvalues']] else: info['AL_eigs'] = [{'eigenvalue': '?', 'prime_ideal': '?'}] else: info['AL_eigs'] = [{'eigenvalue': '?', 'prime_ideal': '?'}] info['AL_eigs_count'] = len(info['AL_eigs']) != 0 max_eig_len = max([len(eig['eigenvalue']) for eig in info['eigs']]) display_eigs = display_eigs or (max_eig_len <= 300) if not display_eigs: for eig in info['eigs']: if len(eig['eigenvalue']) > 300: eig['eigenvalue'] = '...' for eig in info['AL_eigs']: if len(eig['eigenvalue']) > 300: eig['eigenvalue'] = '...' info['level_ideal'] = teXify_pol(info['level_ideal']) if 'is_CM' in data: is_CM = data['is_CM'] else: is_CM = '?' info['is_CM'] = is_CM if 'is_base_change' in data: is_base_change = data['is_base_change'] else: is_base_change = '?' info['is_base_change'] = is_base_change if 'q_expansions' in data: info['q_expansions'] = data['q_expansions'] properties2 = [('Base field', '%s' % info['field'].field_pretty()), ('Weight', '%s' % data['weight']), ('Level norm', '%s' % data['level_norm']), ('Level', '$' + teXify_pol(data['level_ideal']) + '$'), ('Label', '%s' % data['label']), ('Dimension', '%s' % data['dimension']), ('CM', is_CM), ('Base change', is_base_change)] return render_template("hilbert_modular_form.html", downloads=info["downloads"], info=info, properties2=properties2, credit=hmf_credit, title=t, bread=bread, friends=info['friends'], learnmore=learnmore_list())
def make_class(self): # Create a list of the curves in the class from the database self.db_curves = [ c for c in db_ecnf().find({ 'field_label': self.field_label, 'conductor_norm': self.conductor_norm, 'conductor_label': self.conductor_label, 'iso_nlabel': self.iso_nlabel }).sort('number') ] # Rank or bounds try: self.rk = web_latex(self.db_curves[0]['rank']) except KeyError: self.rk = "?" try: self.rk_bnds = "%s...%s" % tuple(self.db_curves[0]['rank_bounds']) except KeyError: self.rank_bounds = [0, sage.rings.infinity.Infinity] self.rk_bnds = "not recorded" # Extract the isogeny degree matrix from the database if possible, else create it if hasattr(self, 'isogeny_matrix'): from sage.matrix.all import Matrix self.isogeny_matrix = Matrix(self.isogeny_matrix) else: self.isogeny_matrix = make_iso_matrix(self.db_curves) # Create isogeny graph: self.graph = make_graph(self.isogeny_matrix) P = self.graph.plot(edge_labels=True) self.graph_img = encode_plot(P) self.graph_link = '<img src="%s" width="200" height="150"/>' % self.graph_img self.isogeny_matrix_str = latex(matrix(self.isogeny_matrix)) self.field = field_pretty(self.field_label) self.field_knowl = nf_display_knowl(self.field_label, lmfdb.base.getDBConnection(), self.field) def curve_url(c): return url_for(".show_ecnf", nf=c['field_label'], conductor_label=c['conductor_label'], class_label=c['iso_label'], number=c['number']) self.curves = [[ c['short_label'], curve_url(c), web_ainvs(self.field_label, c['ainvs']) ] for c in self.db_curves] self.urls = {} self.urls['class'] = url_for(".show_ecnf_isoclass", nf=self.field_label, conductor_label=self.conductor_label, class_label=self.iso_label) self.urls['conductor'] = url_for(".show_ecnf_conductor", nf=self.field_label, conductor_label=self.conductor_label) self.urls['field'] = url_for('.show_ecnf1', nf=self.field_label) sig = self.signature totally_real = sig[1] == 0 imag_quadratic = sig == [0, 1] if totally_real: self.hmf_label = "-".join( [self.field_label, self.conductor_label, self.iso_label]) self.urls['hmf'] = url_for('hmf.render_hmf_webpage', field_label=self.field_label, label=self.hmf_label) self.urls['Lfunction'] = url_for("l_functions.l_function_hmf_page", field=self.field_label, label=self.hmf_label, character='0', number='0') if imag_quadratic: self.bmf_label = "-".join( [self.field_label, self.conductor_label, self.iso_label]) self.friends = [] if totally_real: self.friends += [('Hilbert Modular Form ' + self.hmf_label, self.urls['hmf'])] self.friends += [('L-function', self.urls['Lfunction'])] if imag_quadratic: self.friends += [ ('Bianchi Modular Form %s not available' % self.bmf_label, '') ] self.properties = [('Base field', self.field), ('Label', self.class_label), (None, self.graph_link), ('Conductor', '%s' % self.conductor_label)] if self.rk != '?': self.properties += [('Rank', '%s' % self.rk)] else: if self.rk_bnds == 'not recorded': self.properties += [('Rank', '%s' % self.rk_bnds)] else: self.properties += [('Rank bounds', '%s' % self.rk_bnds)] self.bread = [('Elliptic Curves ', url_for(".index")), (self.field_label, self.urls['field']), (self.conductor_label, self.urls['conductor']), ('isogeny class %s' % self.short_label, self.urls['class'])]
def random_curve(): E = random_object_from_collection(db_ecnf()) return redirect(url_for(".show_ecnf", nf=E['field_label'], conductor_label=E['conductor_label'], class_label=E['iso_label'], number=E['number']), 301)
def render_hmf_webpage(**args): if 'data' in args: data = args['data'] label = data['label'] else: label = str(args['label']) data = get_hmf(label) if data is None: flash( Markup( "Error: <span style='color:black'>%s</span> is not a valid Hilbert modular form label. It must be of the form (number field label) - (level label) - (orbit label) separated by dashes, such as 2.2.5.1-31.1-a" % args['label']), "error") return search_input_error() info = {} try: info['count'] = args['count'] except KeyError: info['count'] = 10 hmf_field = get_hmf_field(data['field_label']) gen_name = findvar(hmf_field['ideals']) nf = WebNumberField(data['field_label'], gen_name=gen_name) info['hmf_field'] = hmf_field info['field'] = nf info['base_galois_group'] = nf.galois_string() info['field_degree'] = nf.degree() info['field_disc'] = str(nf.disc()) info['field_poly'] = teXify_pol(str(nf.poly())) info.update(data) info['downloads'] = [('Download to Magma', url_for(".render_hmf_webpage_download", field_label=info['field_label'], label=info['label'], download_type='magma')), ('Download to Sage', url_for(".render_hmf_webpage_download", field_label=info['field_label'], label=info['label'], download_type='sage'))] if hmf_field['narrow_class_no'] == 1 and nf.disc( )**2 * data['level_norm'] < 40000: info['friends'] = [('L-function', url_for("l_functions.l_function_hmf_page", field=info['field_label'], label=info['label'], character='0', number='0'))] else: info['friends'] = [('L-function not available', "")] if data['dimension'] == 1: # Try to attach associated elliptic curve lab = split_class_label(info['label']) ec_from_hmf = db_ecnf().find_one({"label": label + '1'}) if ec_from_hmf == None: info['friends'] += [('Elliptic curve not available', "")] else: info['friends'] += [('Isogeny class ' + info['label'], url_for("ecnf.show_ecnf_isoclass", nf=lab[0], conductor_label=lab[1], class_label=lab[2]))] bread = [('Hilbert Modular Forms', url_for(".hilbert_modular_form_render_webpage")), ('%s' % data['label'], ' ')] t = "Hilbert Cusp Form %s" % info['label'] forms_space = db_search().find( { 'field_label': data['field_label'], 'level_ideal': data['level_ideal'] }, {'dimension': True}) dim_space = 0 for v in forms_space: dim_space += v['dimension'] info['newspace_dimension'] = dim_space # Get hecke_polynomial, hecke_eigenvalues and AL_eigenvalues try: numeigs = request.args['numeigs'] numeigs = int(numeigs) except: numeigs = 20 info['numeigs'] = numeigs hecke_pol = data['hecke_polynomial'] eigs = data['hecke_eigenvalues'] eigs = eigs[:min(len(eigs), numeigs)] AL_eigs = data['AL_eigenvalues'] primes = hmf_field['primes'] n = min(len(eigs), len(primes)) info['eigs'] = [{ 'eigenvalue': teXify_pol(eigs[i]), 'prime_ideal': teXify_pol(primes[i]), 'prime_norm': primes[i][1:primes[i].index(',')] } for i in range(n)] try: display_eigs = request.args['display_eigs'] if display_eigs in ['True', 'true', '1', 'yes']: display_eigs = True else: display_eigs = False except KeyError: display_eigs = False if 'numeigs' in request.args: display_eigs = True info['hecke_polynomial'] = web_latex_split_on_pm(teXify_pol(hecke_pol)) if not AL_eigs: # empty list if data['level_norm'] == 1: # OK, no bad primes info['AL_eigs'] = 'none' else: # not OK, AL eigs are missing info['AL_eigs'] = 'missing' else: info['AL_eigs'] = [{ 'eigenvalue': teXify_pol(al[1]), 'prime_ideal': teXify_pol(al[0]), 'prime_norm': al[0][1:al[0].index(',')] } for al in data['AL_eigenvalues']] max_eig_len = max([len(eig['eigenvalue']) for eig in info['eigs']]) display_eigs = display_eigs or (max_eig_len <= 300) info['display_eigs'] = display_eigs if not display_eigs: for eig in info['eigs']: if len(eig['eigenvalue']) > 300: eig['eigenvalue'] = '...' info['level_ideal'] = teXify_pol(info['level_ideal']) if 'is_CM' in data: is_CM = data['is_CM'] else: is_CM = '?' info['is_CM'] = is_CM if 'is_base_change' in data: is_base_change = data['is_base_change'] else: is_base_change = '?' info['is_base_change'] = is_base_change if 'q_expansions' in data: info['q_expansions'] = data['q_expansions'] properties2 = [('Base field', '%s' % info['field'].field_pretty()), ('Weight', '%s' % data['weight']), ('Level norm', '%s' % data['level_norm']), ('Level', '$' + teXify_pol(data['level_ideal']) + '$'), ('Label', '%s' % data['label']), ('Dimension', '%s' % data['dimension']), ('CM', is_CM), ('Base change', is_base_change)] return render_template("hilbert_modular_form.html", downloads=info["downloads"], info=info, properties2=properties2, credit=hmf_credit, title=t, bread=bread, friends=info['friends'], learnmore=learnmore_list())
def elliptic_curve_search(**args): info = to_dict(args['data']) if 'download' in info and info['download'] != 0: return download_search(info) if not 'query' in info: info['query'] = {} bread = [('Elliptic Curves', url_for(".index")), ('Search Results', '.')] if 'jump' in info: label = info.get('label', '').replace(" ", "") # This label should be a full isogeny class label or a full # curve label (including the field_label component) try: nf, cond_label, iso_label, number = split_full_label(label.strip()) except ValueError: info['err'] = '' return search_input_error(info, bread) return show_ecnf(nf, cond_label, iso_label, number) query = {} try: parse_ints(info,query,'conductor_norm') parse_noop(info,query,'conductor_label') parse_nf_string(info,query,'field',name="base number field",qfield='field_label') parse_nf_elt(info,query,'jinv',name='j-invariant') parse_ints(info,query,'torsion',name='Torsion order',qfield='torsion_order') parse_bracketed_posints(info,query,'torsion_structure',maxlength=2) if 'torsion_structure' in query and not 'torsion_order' in query: query['torsion_order'] = reduce(mul,[int(n) for n in query['torsion_structure']],1) except ValueError: return search_input_error(info, bread) if 'include_isogenous' in info and info['include_isogenous'] == 'off': info['number'] = 1 query['number'] = 1 if 'include_base_change' in info and info['include_base_change'] == 'off': query['base_change'] = [] else: info['include_base_change'] = "on" if 'include_Q_curves' in info: if info['include_Q_curves'] == 'exclude': query['q_curve'] = False elif info['include_Q_curves'] == 'only': query['q_curve'] = True if 'include_cm' in info: if info['include_cm'] == 'exclude': query['cm'] = 0 elif info['include_cm'] == 'only': query['cm'] = {'$ne' : 0} info['query'] = query count = parse_count(info, 50) start = parse_start(info) # make the query and trim results according to start/count: cursor = db_ecnf().find(query) nres = cursor.count() if(start >= nres): start -= (1 + (start - nres) / count) * count if(start < 0): start = 0 res = cursor.sort([('field_label', ASC), ('conductor_norm', ASC), ('conductor_label', ASC), ('iso_nlabel', ASC), ('number', ASC)]).skip(start).limit(count) res = list(res) for e in res: e['numb'] = str(e['number']) e['field_knowl'] = nf_display_knowl(e['field_label'], getDBConnection(), field_pretty(e['field_label'])) info['curves'] = res # [ECNF(e) for e in res] info['number'] = nres info['start'] = start info['count'] = count info['more'] = int(start + count < nres) info['field_pretty'] = field_pretty info['web_ainvs'] = web_ainvs if nres == 1: info['report'] = 'unique match' else: if nres > count or start != 0: info['report'] = 'displaying matches %s-%s of %s' % (start + 1, min(nres, start + count), nres) else: info['report'] = 'displaying all %s matches' % nres t = 'Elliptic Curve search results' return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
def elliptic_curve_search(**args): info = to_dict(args['data']) if 'jump' in info: label = info.get('label', '').replace(" ", "") # This label should be a full isogeny class label or a full # curve label (including the field_label component) try: nf, cond_label, iso_label, number = split_full_label(label.strip()) except IndexError: if not 'query' in info: info['query'] = {} bread = [("Elliptic Curves", url_for(".index"))] info[ 'err'] = 'No elliptic curve in the database has label %s.' % label return search_input_error(info, bread) return show_ecnf(nf, cond_label, iso_label, number) query = {} bread = [('Elliptic Curves', url_for(".index")), ('Search Results', '.')] if 'conductor_norm' in info: Nnorm = clean_input(info['conductor_norm']) Nnorm = Nnorm.replace('..', '-').replace(' ', '') tmp = parse_range2(Nnorm, 'conductor_norm') if tmp[0] == '$or' and '$or' in query: newors = [] for y in tmp[1]: oldors = [dict.copy(x) for x in query['$or']] for x in oldors: x.update(y) newors.extend(oldors) tmp[1] = newors query[tmp[0]] = tmp[1] if 'conductor_label' in info: query['conductor_label'] = info['conductor_label'] if 'jinv' in info: query['jinv'] = info['jinv'] if info.get('torsion'): ran = info['torsion'] = clean_input(info['torsion']) ran = ran.replace('..', '-').replace(' ', '') if not LIST_RE.match(ran): info[ 'err'] = 'Error parsing input for the torsion order. It needs to be an integer (such as 5), a range of integers (such as 2-10 or 2..10), or a comma-separated list of these (such as 4,9,16 or 4-25, 81-121).' return search_input_error(info, bread) # Past input check tmp = parse_range2(ran, 'torsion_order') # work around syntax for $or # we have to foil out multiple or conditions if tmp[0] == '$or' and '$or' in query: newors = [] for y in tmp[1]: oldors = [dict.copy(x) for x in query['$or']] for x in oldors: x.update(y) newors.extend(oldors) tmp[1] = newors query[tmp[0]] = tmp[1] if 'torsion_structure' in info and info['torsion_structure']: res = parse_torsion_structure(info['torsion_structure'], 2) if 'Error' in res: info['err'] = res return search_input_error(info, bread) #update info for repeat searches info['torsion_structure'] = str(res).replace(' ', '') query['torsion_structure'] = [int(r) for r in res] if 'include_isogenous' in info and info['include_isogenous'] == 'off': query['number'] = 1 if 'include_base_change' in info and info['include_base_change'] == 'off': query['base_change'] = [] else: info['include_base_change'] = "on" if 'field' in info: query['field_label'] = parse_field_string(info['field']) info['query'] = query # process count and start if not default: count_default = 50 if info.get('count'): try: count = int(info['count']) except: count = count_default else: count = count_default start_default = 0 if info.get('start'): try: start = int(info['start']) if (start < 0): start += (1 - (start + 1) / count) * count except: start = start_default else: start = start_default # make the query and trim results according to start/count: cursor = db_ecnf().find(query) nres = cursor.count() if (start >= nres): start -= (1 + (start - nres) / count) * count if (start < 0): start = 0 res = cursor.sort([('field_label', ASC), ('conductor_norm', ASC), ('conductor_label', ASC), ('iso_nlabel', ASC), ('number', ASC)]).skip(start).limit(count) res = list(res) for e in res: e['numb'] = str(e['number']) e['field_knowl'] = nf_display_knowl(e['field_label'], getDBConnection(), e['field_label']) info['curves'] = res # [ECNF(e) for e in res] info['number'] = nres info['start'] = start info['count'] = count info['more'] = int(start + count < nres) info['field_pretty'] = field_pretty info['web_ainvs'] = web_ainvs if nres == 1: info['report'] = 'unique match' else: if nres > count or start != 0: info['report'] = 'displaying matches %s-%s of %s' % ( start + 1, min(nres, start + count), nres) else: info['report'] = 'displaying all %s matches' % nres t = 'Elliptic Curve search results' return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)
def render_hmf_webpage(**args): C = getDBConnection() if 'data' in args: data = args['data'] label = data['label'] else: label = str(args['label']) data = C.hmfs.forms.find_one({'label': label}) if data is None: return "No such form" info = {} try: info['count'] = args['count'] except KeyError: info['count'] = 10 try: numeigs = request.args['numeigs'] numeigs = int(numeigs) except: numeigs = 20 hmf_field = C.hmfs.fields.find_one({'label': data['field_label']}) gen_name = findvar(hmf_field['ideals']) nf = WebNumberField(data['field_label'], gen_name=gen_name) info['field'] = nf info['base_galois_group'] = nf.galois_string() info['field_degree'] = nf.degree() info['field_disc'] = str(nf.disc()) info['field_poly'] = teXify_pol(str(nf.poly())) info.update(data) info['downloads'] = [ ('Download to Magma', url_for(".render_hmf_webpage_download", field_label=info['field_label'], label=info['label'], download_type='magma')), ('Download to Sage', url_for(".render_hmf_webpage_download", field_label=info['field_label'], label=info['label'], download_type='sage')) ] if hmf_field['narrow_class_no'] == 1: info['friends'] = [('L-function', url_for("l_functions.l_function_hmf_page", field=info['field_label'], label=info['label'], character='0', number='0'))] else: info['friends'] = [('L-function not available', "")] if data['dimension'] == 1: # Try to attach associated elliptic curve lab = split_class_label(info['label']) ec_from_hmf = db_ecnf().find_one({"label": label + '1'}) if ec_from_hmf == None: info['friends'] += [('Elliptic curve not available', "")] else: info['friends'] += [('Isogeny class ' + info['label'], url_for("ecnf.show_ecnf_isoclass", nf=lab[0], conductor_label=lab[1], class_label=lab[2]))] bread = [('Hilbert Modular Forms', url_for(".hilbert_modular_form_render_webpage")), ('%s' % data[ 'label'], ' ')] t = "Hilbert Cusp Form %s" % info['label'] forms_space = C.hmfs.forms.find( {'field_label': data['field_label'], 'level_ideal': data['level_ideal']}) dim_space = 0 for v in forms_space: dim_space += v['dimension'] info['newspace_dimension'] = dim_space w = polygen(QQ, 'w') e = polygen(QQ, 'e') eigs = data['hecke_eigenvalues'] eigs = eigs[:min(len(eigs), numeigs)] primes = hmf_field['primes'] n = min(len(eigs), len(primes)) info['eigs'] = [{'eigenvalue': teXify_pol(eigs[i]), 'prime_ideal': teXify_pol(primes[i]), 'prime_norm': primes[i][1:primes[i].index(',')]} for i in range(n)] try: display_eigs = request.args['display_eigs'] if display_eigs in ['True', 'true', '1', 'yes']: display_eigs = True else: display_eigs = False except KeyError: display_eigs = False if 'numeigs' in request.args: display_eigs = True info['hecke_polynomial'] = teXify_pol(info['hecke_polynomial']) if 'AL_eigenvalues_fixed' in data: if data['AL_eigenvalues_fixed'] == 'done': info['AL_eigs'] = [{'eigenvalue': teXify_pol(al[1]), 'prime_ideal': teXify_pol(al[0]), 'prime_norm': al[0][1:al[0].index(',')]} for al in data['AL_eigenvalues']] else: info['AL_eigs'] = [{'eigenvalue': '?', 'prime_ideal': '?'}] else: info['AL_eigs'] = [{'eigenvalue': '?', 'prime_ideal': '?'}] info['AL_eigs_count'] = len(info['AL_eigs']) != 0 max_eig_len = max([len(eig['eigenvalue']) for eig in info['eigs']]) display_eigs = display_eigs or (max_eig_len<=300) if not display_eigs: for eig in info['eigs']: if len(eig['eigenvalue']) > 300: eig['eigenvalue'] = '...' for eig in info['AL_eigs']: if len(eig['eigenvalue']) > 300: eig['eigenvalue'] = '...' info['level_ideal'] = teXify_pol(info['level_ideal']) if 'is_CM' in data: is_CM = data['is_CM'] else: is_CM = '?' info['is_CM'] = is_CM if 'is_base_change' in data: is_base_change = data['is_base_change'] else: is_base_change = '?' info['is_base_change'] = is_base_change if 'q_expansions' in data: info['q_expansions'] = data['q_expansions'] properties2 = [('Base field', '%s' % info['field'].field_pretty()), ('Weight', '%s' % data['weight']), ('Level norm', '%s' % data['level_norm']), ('Level', '$' + teXify_pol(data['level_ideal']) + '$'), ('Label', '%s' % data['label_suffix']), ('Dimension', '%s' % data['dimension']), ('CM', is_CM), ('Base change', is_base_change) ] return render_template("hilbert_modular_form.html", downloads=info["downloads"], info=info, properties2=properties2, credit=hmf_credit, title=t, bread=bread, friends=info['friends'], learnmore=learnmore_list())
def elliptic_curve_search(**args): info = to_dict(args['data']) if 'download' in info and info['download'] != 0: return download_search(info) bread = [('Elliptic Curves', url_for(".index")), ('Search Results', '.')] if 'jump' in info: label = info.get('label', '').replace(" ", "") # This label should be a full isogeny class label or a full # curve label (including the field_label component) try: nf, cond_label, iso_label, number = split_full_label(label.strip()) except ValueError: if not 'query' in info: info['query'] = {} info['err'] = '' return search_input_error(info, bread) return show_ecnf(nf, cond_label, iso_label, number) query = {} try: parse_ints(info,query,'conductor_norm') parse_noop(info,query,'conductor_label') parse_nf_string(info,query,'field',name="base number field",qfield='field_label') parse_nf_elt(info,query,'jinv',name='j-invariant') parse_ints(info,query,'torsion',name='Torsion order',qfield='torsion_order') parse_bracketed_posints(info,query,'torsion_structure',maxlength=2) except ValueError: return search_input_error(info, bread) if 'include_isogenous' in info and info['include_isogenous'] == 'off': info['number'] = 1 query['number'] = 1 if 'include_base_change' in info and info['include_base_change'] == 'off': query['base_change'] = [] else: info['include_base_change'] = "on" info['query'] = query count = parse_count(info, 50) start = parse_start(info) # make the query and trim results according to start/count: cursor = db_ecnf().find(query) nres = cursor.count() if(start >= nres): start -= (1 + (start - nres) / count) * count if(start < 0): start = 0 res = cursor.sort([('field_label', ASC), ('conductor_norm', ASC), ('conductor_label', ASC), ('iso_nlabel', ASC), ('number', ASC)]).skip(start).limit(count) res = list(res) for e in res: e['numb'] = str(e['number']) e['field_knowl'] = nf_display_knowl(e['field_label'], getDBConnection(), field_pretty(e['field_label'])) info['curves'] = res # [ECNF(e) for e in res] info['number'] = nres info['start'] = start info['count'] = count info['more'] = int(start + count < nres) info['field_pretty'] = field_pretty info['web_ainvs'] = web_ainvs if nres == 1: info['report'] = 'unique match' else: if nres > count or start != 0: info['report'] = 'displaying matches %s-%s of %s' % (start + 1, min(nres, start + count), nres) else: info['report'] = 'displaying all %s matches' % nres t = 'Elliptic Curve search results' return render_template("ecnf-search-results.html", info=info, credit=ecnf_credit, bread=bread, title=t)