Exemplo n.º 1
0
    def create_object(self, version, key, **kwds):
        """
        Create an object from a ``UniqueFactory`` key.

        EXAMPLES::

            sage: E = EllipticCurve.create_object(0, (GF(3), (1, 2, 0, 1, 2)))
            sage: type(E)
            <class 'sage.schemes.elliptic_curves.ell_finite_field.EllipticCurve_finite_field_with_category'>

        .. NOTE::

            Keyword arguments are currently only passed to the
            constructor for elliptic curves over `\\QQ`; elliptic
            curves over other fields do not support them.

        """
        R, x = key

        if R is rings.QQ:
            from ell_rational_field import EllipticCurve_rational_field
            return EllipticCurve_rational_field(x, **kwds)
        elif is_NumberField(R):
            from ell_number_field import EllipticCurve_number_field
            return EllipticCurve_number_field(R, x)
        elif rings.is_pAdicField(R):
            from ell_padic_field import EllipticCurve_padic_field
            return EllipticCurve_padic_field(R, x)
        elif is_FiniteField(R) or (is_IntegerModRing(R)
                                   and R.characteristic().is_prime()):
            from ell_finite_field import EllipticCurve_finite_field
            return EllipticCurve_finite_field(R, x)
        elif R in _Fields:
            from ell_field import EllipticCurve_field
            return EllipticCurve_field(R, x)
        from ell_generic import EllipticCurve_generic
        return EllipticCurve_generic(R, x)
Exemplo n.º 2
0
    def rank(self, rank, tors=0, n=10, labels=False):
        r"""
        Return a list of at most `n` non-isogenous curves with given
        rank and torsion order.

        INPUT:

        - ``rank`` (int) -- the desired rank

        - ``tors`` (int, default 0) -- the desired torsion order (ignored if 0)

        - ``n`` (int, default 10) -- the maximum number of curves returned.

        - ``labels`` (bool, default False) -- if True, return Cremona
          labels instead of curves.

        OUTPUT:

        (list) A list at most `n` of elliptic curves of required rank.

        EXAMPLES::

            sage: elliptic_curves.rank(n=5, rank=3, tors=2, labels=True)
            ['59450i1', '59450i2', '61376c1', '61376c2', '65481c1']

        ::

            sage: elliptic_curves.rank(n=5, rank=0, tors=5, labels=True)
            ['11a1', '11a3', '38b1', '50b1', '50b2']

        ::

            sage: elliptic_curves.rank(n=5, rank=1, tors=7, labels=True)
            ['574i1', '4730k1', '6378c1']

        ::

            sage: e = elliptic_curves.rank(6)[0]; e.ainvs(), e.conductor()
            ((1, 1, 0, -2582, 48720), 5187563742)
            sage: e = elliptic_curves.rank(7)[0]; e.ainvs(), e.conductor()
            ((0, 0, 0, -10012, 346900), 382623908456)
            sage: e = elliptic_curves.rank(8)[0]; e.ainvs(), e.conductor()
            ((0, 0, 1, -23737, 960366), 457532830151317)

        """
        from sage.misc.misc import SAGE_SHARE
        db = os.path.join(SAGE_SHARE, 'ellcurves')
        data = os.path.join(db, 'rank%s' % rank)
        if not os.path.exists(data):
            return []
        v = []
        tors = int(tors)
        for w in open(data).readlines():
            N, iso, num, ainvs, r, t = w.split()
            if tors and tors != int(t):
                continue
            label = '%s%s%s' % (N, iso, num)
            if labels:
                v.append(label)
            else:
                E = EllipticCurve_rational_field(eval(ainvs))
                E._set_rank(r)
                E._set_torsion_order(t)
                E._set_conductor(N)
                E._set_cremona_label(label)
                v.append(E)
            if len(v) >= n:
                break
        return v
Exemplo n.º 3
0
    def rank(self, rank, tors=0, n=10, labels=False):
        r"""
        Return a list of at most `n` non-isogenous curves with given
        rank and torsion order.

        INPUT:

        - ``rank`` (int) -- the desired rank

        - ``tors`` (int, default 0) -- the desired torsion order (ignored if 0)

        - ``n`` (int, default 10) -- the maximum number of curves returned.

        - ``labels`` (bool, default False) -- if True, return Cremona
          labels instead of curves.

        OUTPUT:

        (list) A list at most `n` of elliptic curves of required rank.

        EXAMPLES::

            sage: elliptic_curves.rank(n=5, rank=3, tors=2, labels=True)
            ['59450i1', '59450i2', '61376c1', '61376c2', '65481c1']

        ::

            sage: elliptic_curves.rank(n=5, rank=0, tors=5, labels=True)
            ['11a1', '11a3', '38b1', '50b1', '50b2']

        ::

            sage: elliptic_curves.rank(n=5, rank=1, tors=7, labels=True)
            ['574i1', '4730k1', '6378c1']

        ::

            sage: e = elliptic_curves.rank(6)[0]; e.ainvs(), e.conductor()
            ((1, 1, 0, -2582, 48720), 5187563742)
            sage: e = elliptic_curves.rank(7)[0]; e.ainvs(), e.conductor()
            ((0, 0, 0, -10012, 346900), 382623908456)
            sage: e = elliptic_curves.rank(8)[0]; e.ainvs(), e.conductor()
            ((0, 0, 1, -23737, 960366), 457532830151317)

        """
        from sage.misc.misc import SAGE_SHARE
        db = os.path.join(SAGE_SHARE,'ellcurves')
        data = os.path.join(db,'rank%s'%rank)
        if not os.path.exists(data):
            return []
        v = []
        tors = int(tors)
        for w in open(data).readlines():
            N,iso,num,ainvs,r,t = w.split()
            if tors and tors != int(t):
                continue
            label = '%s%s%s'%(N,iso,num)
            if labels:
                v.append(label)
            else:
                E = EllipticCurve_rational_field(eval(ainvs))
                E._set_rank(r)
                E._set_torsion_order(t)
                E._set_conductor(N)
                E._set_cremona_label(label)
                v.append(E)
            if len(v) >= n:
                break
        return v