Example #1
0
def show_ecnf(nf, conductor_label, class_label, number):
    try:
        nf_label = nf_string_to_label(nf)
    except ValueError:
        return search_input_error()
    label = "".join(["-".join([nf_label, conductor_label, class_label]), number])
    ec = ECNF.by_label(label)
    bread = [("Elliptic Curves", url_for(".index"))]
    if not ec:
        info = {'query':{}}
        info['err'] = 'No elliptic curve in the database has label %s.' % label
        return search_input_error(info, bread)

    title = "Elliptic Curve %s over Number Field %s" % (ec.short_label, ec.field.field_pretty())
    bread = [("Elliptic Curves", url_for(".index"))]
    bread.append((ec.field.field_pretty(), ec.urls['field']))
    bread.append((ec.conductor_label, ec.urls['conductor']))
    bread.append((ec.iso_label, ec.urls['class']))
    bread.append((ec.number, ec.urls['curve']))
    code = ec.code()
    code['show'] = {'magma':'','pari':'','sage':''} # use default show names
    info = {}
    return render_template("show-ecnf.html",
                           credit=ecnf_credit,
                           title=title,
                           bread=bread,
                           ec=ec,
                           code = code,
                           #        properties = ec.properties,
                           properties2=ec.properties,
                           friends=ec.friends,
                           info=info,
                           learnmore=learnmore_list())
Example #2
0
def show_ecnf(nf, conductor_label, class_label, number):
    nf_label = parse_field_string(nf)
    label = "".join(
        ["-".join([nf_label, conductor_label, class_label]), number])
    ec = ECNF.by_label(label)
    bread = [("Elliptic Curves", url_for(".index"))]
    if not ec:
        info = {}
        info['query'] = {}
        info['err'] = 'No elliptic curve in the database has label %s.' % label
        return search_input_error(info, bread)

    title = "Elliptic Curve %s over Number Field %s" % (
        ec.short_label, ec.field.field_pretty())
    bread = [("Elliptic Curves", url_for(".index"))]
    bread.append((ec.field.field_pretty(), ec.urls['field']))
    bread.append((ec.conductor_label, ec.urls['conductor']))
    bread.append((ec.iso_label, ec.urls['class']))
    bread.append((ec.number, ec.urls['curve']))
    info = {}

    return render_template(
        "show-ecnf.html",
        credit=ecnf_credit,
        title=title,
        bread=bread,
        ec=ec,
        #        properties = ec.properties,
        properties2=ec.properties,
        friends=ec.friends,
        info=info)
Example #3
0
def show_ecnf(nf, conductor_label, class_label, number):
    nf_label = parse_field_string(nf)
    label = "".join(["-".join([nf_label, conductor_label, class_label]), number])
    ec = ECNF.by_label(label)
    bread = [("Elliptic Curves", url_for(".index"))]
    if not ec:
        info = {}
        info['query'] = {}
        info['err'] = 'No elliptic curve in the database has label %s.' % label
        return search_input_error(info, bread)

    title = "Elliptic Curve %s over Number Field %s" % (ec.short_label, ec.field.field_pretty())
    bread = [("Elliptic Curves", url_for(".index"))]
    bread.append((ec.field.field_pretty(), ec.urls['field']))
    bread.append((ec.conductor_label, ec.urls['conductor']))
    bread.append((ec.iso_label, ec.urls['class']))
    bread.append((ec.number, ec.urls['curve']))
    info = {}

    return render_template("show-ecnf.html",
                           credit=ecnf_credit,
                           title=title,
                           bread=bread,
                           ec=ec,
                           #        properties = ec.properties,
                           properties2=ec.properties,
                           friends=ec.friends,
                           info=info)
Example #4
0
def show_ecnf(nf, conductor_label, class_label, number):
    try:
        nf_label = nf_string_to_label(nf)
    except ValueError:
        return search_input_error()
    label = "".join(["-".join([nf_label, conductor_label, class_label]), number])
    ec = ECNF.by_label(label)
    bread = [("Elliptic Curves", url_for(".index"))]
    if not ec:
        info = {"query": {}}
        info["err"] = "No elliptic curve in the database has label %s." % label
        return search_input_error(info, bread)

    title = "Elliptic Curve %s over Number Field %s" % (ec.short_label, ec.field.field_pretty())
    bread = [("Elliptic Curves", url_for(".index"))]
    bread.append((ec.field.field_pretty(), ec.urls["field"]))
    bread.append((ec.conductor_label, ec.urls["conductor"]))
    bread.append((ec.iso_label, ec.urls["class"]))
    bread.append((ec.number, ec.urls["curve"]))
    info = {}

    return render_template(
        "show-ecnf.html",
        credit=ecnf_credit,
        title=title,
        bread=bread,
        ec=ec,
        #        properties = ec.properties,
        properties2=ec.properties,
        friends=ec.friends,
        info=info,
        learnmore=learnmore_list(),
    )
Example #5
0
def ecnf_code(**args):
    label = "".join([
        "-".join([args['nf'], args['conductor_label'], args['class_label']]),
        args['number']
    ])
    if not LABEL_RE.fullmatch(label):
        return abort(404)
    try:
        E = ECNF.by_label(label)
    except ValueError:
        return abort(404)
    Ecode = E.code()
    lang = args['download_type']
    code = "{} {} code for working with elliptic curve {}\n\n".format(
        Comment[lang], Fullname[lang], label)
    code += "{} (Note that not all these functions may be available, and some may take a long time to execute.)\n".format(
        Comment[lang])
    if lang == 'gp':
        lang = 'pari'
    for k in sorted_code_names:
        if lang in Ecode[k]:
            code += "\n{} {}: \n".format(Comment[lang], code_names[k])
            code += Ecode[k][lang] + ('\n'
                                      if not '\n' in Ecode[k][lang] else '')
    return code
Example #6
0
def show_ecnf(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])
    ec = ECNF.by_label(label)
    bread = [("Elliptic Curves", url_for(".index"))]
    if not ec:
        info = {'query':{}}
        info['err'] = 'No elliptic curve in the database has label %s.' % label
        return search_input_error(info, bread)

    title = "Elliptic Curve %s over Number Field %s" % (ec.short_label, ec.field.field_pretty())
    bread = [("Elliptic Curves", url_for(".index"))]
    bread.append((ec.field.field_pretty(), ec.urls['field']))
    bread.append((ec.conductor_label, ec.urls['conductor']))
    bread.append((ec.iso_label, ec.urls['class']))
    bread.append((ec.number, ec.urls['curve']))
    code = ec.code()
    code['show'] = {'magma':'','pari':'','sage':''} # use default show names
    info = {}
    return render_template("ecnf-curve.html",
                           credit=ecnf_credit,
                           title=title,
                           bread=bread,
                           ec=ec,
                           code = code,
                           #        properties = ec.properties,
                           properties2=ec.properties,
                           friends=ec.friends,
                           info=info,
                           learnmore=learnmore_list())
Example #7
0
    def make_class(self):
        self.ECNF = ECNF.by_label(self.label)

        # Create a list of the curves in the class from the database
        self.db_curves = [ECNF(c) for c in db_ec().find(
            {'field_label' : self.field_label, 'conductor_label' :
             self.conductor_label, 'iso_label' : self.iso_label}).sort('number')]
        size = len(self.db_curves)

        # 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.curves = [[c.short_label, c.urls['curve'], c.latex_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.ECNF.field_label)
        self.field = self.ECNF.field
        if self.field.is_real_quadratic():
            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 self.field.is_imag_quadratic():
            self.bmf_label = "-".join([self.field.label,self.conductor_label,self.iso_label])


        self.friends = []
        if self.field.is_real_quadratic():
            self.friends += [('Hilbert Modular Form '+self.hmf_label, self.urls['hmf'])]
        if self.field.is_imag_quadratic():
            self.friends += [('Bianchi Modular Form %s not yet available' % self.bmf_label, '')]

        self.properties = [('Label', self.ECNF.label),
                           (None, self.graph_link),
                           ('Conductor', '%s' % self.ECNF.cond)
                           ]

        self.bread = [('Elliptic Curves ', url_for(".index")),
                      (self.ECNF.field_label, self.urls['field']),
                      (self.ECNF.conductor_label, self.urls['conductor']),
                      ('isogeny class %s' % self.ECNF.short_label, self.urls['class'])]
Example #8
0
def ecnf_code(**args):
    label = "".join(["-".join([args['nf'], args['conductor_label'], args['class_label']]), args['number']])
    E = ECNF.by_label(label)
    Ecode = E.code()
    lang = args['download_type']
    code = "{} {} code for working with elliptic curve {}\n\n".format(Comment[lang],Fullname[lang],label)
    code += "{} (Note that not all these functions may be available, and some may take a long time to execute.)\n".format(Comment[lang])
    if lang=='gp':
        lang = 'pari'
    for k in sorted_code_names:
        if lang in Ecode[k]:
            code += "\n{} {}: \n".format(Comment[lang],code_names[k])
            code += Ecode[k][lang] + ('\n' if not '\n' in Ecode[k][lang] else '')
    return code
Example #9
0
def show_ecnf(nf, conductor_label, class_label, number):
    if not FIELD_RE.fullmatch(nf):
        return abort(404)
    conductor_label = unquote(conductor_label)
    conductor_label = convert_IQF_label(nf, conductor_label)
    try:
        nf_label = nf_string_to_label(nf)
    except ValueError:
        flash_error("%s is not a valid number field label", nf_label)
        return redirect(url_for(".index"))
    label = "".join(
        ["-".join([nf_label, conductor_label, class_label]),
         str(number)])
    if not LABEL_RE.fullmatch(label):
        flash_error("%s is not a valid elliptic curve label", label)
        return redirect(url_for(".index"))
    ec = ECNF.by_label(label)
    if not isinstance(ec, ECNF):
        flash_error("There is no elliptic curve with label %s in the database",
                    label)
        return redirect(url_for(".index"))
    bread = [("Elliptic curves", url_for(".index"))]
    title = "Elliptic curve %s over number field %s" % (
        ec.short_label, ec.field.field_pretty())
    bread = [("Elliptic curves", url_for(".index"))]
    bread.append((ec.field.field_pretty(), ec.urls['field']))
    bread.append((ec.conductor_label, ec.urls['conductor']))
    bread.append((ec.iso_label, ec.urls['class']))
    bread.append((ec.number, ec.urls['curve']))
    code = ec.code()
    code['show'] = {
        'magma': '',
        'pari': '',
        'sage': ''
    }  # use default show names
    info = {}
    return render_template(
        "ecnf-curve.html",
        credit=ecnf_credit,
        title=title,
        bread=bread,
        ec=ec,
        code=code,
        #        properties = ec.properties,
        properties=ec.properties,
        friends=ec.friends,
        downloads=ec.downloads,
        info=info,
        KNOWL_ID="ec.%s" % label,
        learnmore=learnmore_list())
Example #10
0
def show_ecnf(nf, label):
    nf_label = parse_field_string(nf)
    label = "-".join([nf_label, label])
    ec = ECNF.by_label(label)
    title = "Elliptic Curve %s over Number Field %s" % (ec.short_label, ec.field.field_pretty())
    bread = [("Elliptic Curves", url_for(".index"))]
    bread.append((ec.field.field_pretty(),url_for(".show_ecnf1", nf=nf_label)))
    bread.append((ec.short_label, url_for(".show_ecnf", label = ec.short_label, nf = nf_label)))
    info = {}

    return render_template("show-ecnf.html",
        credit=ecnf_credit,
        title=title,
        bread=bread,
        ec=ec,
#        properties = ec.properties,
        properties2 = ec.properties,
        friends = ec.friends,
        info=info)
Example #11
0
def get_generators(field,
                   iso_class,
                   test_saturation=False,
                   verbose=False,
                   store=False):
    r""" Retrieves the curves in the isogeny class from the database, finds
    their ranks (or bounds) and generators, and optionally stores the
    result back in the database.  """
    res = nfcurves.find({'field_label': field, 'short_class_label': iso_class})
    if not res:
        raise ValueError(
            "No curves in the database ovver field %s in class %s" %
            (field, iso_class))
    Es = [ECNF(e).E for e in res]
    if verbose:
        print("Curves in class %s: %s" % (iso_class, [E.ainvs() for E in Es]))
    mwi = MWInfo_curves(Es,
                        HeightBound=2,
                        test_saturation=test_saturation,
                        verbose=verbose)
    if verbose:
        print("MW info: %s" % mwi)

    # res.rewind()

    # We find the curves again, since the cursor times out after 10
    # miniutes and finding the generators can take longer than that.

    res = nfcurves.find({'field_label': field, 'short_class_label': iso_class})
    for e, mw in zip(res, mwi):
        data = {}
        data['rank_bounds'] = [int(r) for r in mw[0]]
        if mw[0][0] == mw[0][1]:
            data['rank'] = int(mw[0][0])
        data['gens'] = encode_points(mw[1])
        if verbose:
            print("About to update %s using data %s" % (e['label'], data))
        if store:
            nfcurves.update(e, {'$set': data}, upsert=True)
        else:
            if verbose:
                print("(not done, dummy run)")
Example #12
0
def show_ecnf(nf, class_label, conductor_label, number):
    nf_label = parse_field_string(nf)
    label = "".join(["-".join([nf_label, conductor_label, class_label]), number])
    ec = ECNF.by_label(label)
    title = "Elliptic Curve %s over Number Field %s" % (ec.short_label, ec.field.field_pretty())
    bread = [("Elliptic Curves", url_for(".index"))]
    bread.append((ec.field.field_pretty(), ec.urls["field"]))
    bread.append((ec.conductor_label, ec.urls["conductor"]))
    bread.append((ec.iso_label, ec.urls["class"]))
    bread.append((ec.number, ec.urls["curve"]))
    info = {}

    return render_template(
        "show-ecnf.html",
        credit=ecnf_credit,
        title=title,
        bread=bread,
        ec=ec,
        #        properties = ec.properties,
        properties2=ec.properties,
        friends=ec.friends,
        info=info,
    )
Example #13
0
def ecnf_code(**args):
    label = "".join([
        "-".join([args['nf'], args['conductor_label'], args['class_label']]),
        args['number']
    ])
    E = ECNF.by_label(label)
    Ecode = E.code()
    lang = args['download_type']
    code = "{} {} code for working with elliptic curve {}\n\n".format(
        Comment[lang], Fullname[lang], label)
    code += "{} (Note that not all these functions may be available, and some may take a long time to execute.)\n".format(
        Comment[lang])
    if lang == 'gp':
        lang = 'pari'
    if lang == 'sage':
        code += "\nx = polygen(QQ)\n"
    elif lang == 'magma':
        code += "\nQx<x> := PolynomialRing(RationalField());\n"
    for k in sorted_code_names:
        if lang in Ecode[k]:
            code += "\n{} {}: \n".format(Comment[lang], code_names[k])
            code += Ecode[k][lang] + ('\n'
                                      if not '\n' in Ecode[k][lang] else '')
    return code
Example #14
0
    def make_class(self):
        self.ECNF = ECNF.by_label(self.label)

        # Create a list of the curves in the class from the database
        self.db_curves = [
            ECNF(c) for c in db_ec().find({
                'field_label': self.field_label,
                'conductor_label': self.conductor_label,
                'iso_label': self.iso_label
            }).sort('number')
        ]
        size = len(self.db_curves)

        # 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.curves = [[c.short_label, c.urls['curve'], c.latex_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.ECNF.field_label)
        self.field = self.ECNF.field
        if self.field.is_real_quadratic():
            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 self.field.is_imag_quadratic():
            self.bmf_label = "-".join(
                [self.field.label, self.conductor_label, self.iso_label])

        self.friends = []
        if self.field.is_real_quadratic():
            self.friends += [('Hilbert Modular Form ' + self.hmf_label,
                              self.urls['hmf'])]
        if self.field.is_imag_quadratic():
            self.friends += [
                ('Bianchi Modular Form %s not yet available' % self.bmf_label,
                 '')
            ]

        self.properties = [('Label', self.ECNF.label), (None, self.graph_link),
                           ('Conductor', '%s' % self.ECNF.cond)]

        self.bread = [('Elliptic Curves ', url_for(".index")),
                      (self.ECNF.field_label, self.urls['field']),
                      (self.ECNF.conductor_label, self.urls['conductor']),
                      ('isogeny class %s' % self.ECNF.short_label,
                       self.urls['class'])]