Example #1
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 #2
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'])]