Path: blob/master/sage/schemes/elliptic_curves/ec_database.py
4097 views
r"""1Tables of elliptic curves of given rank23The default database of curves contains the following data:45+------+------------------+--------------------+6| Rank | Number of curves | Maximal conductor |7+======+==================+====================+8| 0 | 30427 | 9999 |9+------+------------------+--------------------+10| 1 | 31871 | 9999 |11+------+------------------+--------------------+12| 2 | 2388 | 9999 |13+------+------------------+--------------------+14| 3 | 836 | 119888 |15+------+------------------+--------------------+16| 4 | 1 | 234446 |17+------+------------------+--------------------+18| 5 | 1 | 19047851 |19+------+------------------+--------------------+20| 6 | 1 | 5187563742 |21+------+------------------+--------------------+22| 7 | 1 | 382623908456 |23+------+------------------+--------------------+24| 8 | 1 | 457532830151317 |25+------+------------------+--------------------+2627AUTHOR:28- William Stein (2007-10-07): initial version2930See also the functions cremona_curves() and cremona_optimal_curves()31which enable easy looping through the Cremona elliptic curve database.3233"""3435import os3637from ell_rational_field import (EllipticCurve_rational_field)3839class EllipticCurves:40def rank(self, rank, tors=0, n=10, labels=False):41r"""42Return a list of at most `n` non-isogenous curves with given43rank and torsion order.4445INPUT:4647- ``rank`` (int) -- the desired rank4849- ``tors`` (int, default 0) -- the desired torsion order (ignored if 0)5051- ``n`` (int, default 10) -- the maximum number of curves returned.5253- ``labels`` (bool, default False) -- if True, return Cremona54labels instead of curves.5556OUTPUT:5758(list) A list at most `n` of elliptic curves of required rank.5960EXAMPLES::6162sage: elliptic_curves.rank(n=5, rank=3, tors=2, labels=True)63['59450i1', '59450i2', '61376c1', '61376c2', '65481c1']6465::6667sage: elliptic_curves.rank(n=5, rank=0, tors=5, labels=True)68['11a1', '11a3', '38b1', '50b1', '50b2']6970::7172sage: elliptic_curves.rank(n=5, rank=1, tors=7, labels=True)73['574i1', '4730k1', '6378c1']7475::7677sage: e = elliptic_curves.rank(6)[0]; e.ainvs(), e.conductor()78((1, 1, 0, -2582, 48720), 5187563742)79sage: e = elliptic_curves.rank(7)[0]; e.ainvs(), e.conductor()80((0, 0, 0, -10012, 346900), 382623908456)81sage: e = elliptic_curves.rank(8)[0]; e.ainvs(), e.conductor()82((0, 0, 1, -23737, 960366), 457532830151317)8384"""85db = "%s/ellcurves/"%os.environ['SAGE_DATA']86data = '%s/rank%s'%(db,rank)87if not os.path.exists(data):88return []89v = []90tors = int(tors)91for w in open(data).readlines():92N,iso,num,ainvs,r,t = w.split()93if tors and tors != int(t):94continue95label = '%s%s%s'%(N,iso,num)96if labels:97v.append(label)98else:99E = EllipticCurve_rational_field(eval(ainvs))100E._set_rank(r)101E._set_torsion_order(t)102E._set_conductor(N)103E._set_cremona_label(label)104v.append(E)105if len(v) >= n:106break107return v108109elliptic_curves = EllipticCurves()110111112113114