# HG changeset patch
# User Alexandru Ghitza <aghitza@alum.mit.edu>
# Date 1232702207 -39600
# Node ID 03f5acb29102bd606136e82775dbc72037a6847f
# Parent f8fb0bf3e547d65a0f90f5b27d543c8cf4ca9da0
trac 4755: fixes in interfacing with Cremona database
diff -r f8fb0bf3e547 -r 03f5acb29102 sage/databases/cremona.py
a
|
b
|
|
5 | 5 | easy-to-use format. The unique instance of the class |
6 | 6 | CremonaDatabase() gives access to the database. |
7 | 7 | |
8 | | If the full CremonaDatabase isn't installed, a mini-version, which is |
9 | | included by default with SAGE, is included. It includes Weierstrass |
| 8 | If the full CremonaDatabase isn't installed, a mini-version is |
| 9 | included by default with SAGE. It contains Weierstrass |
10 | 10 | equations, rank, and torsion for curves up to conductor 10000. |
11 | 11 | |
12 | 12 | The large database includes all curves of conductor up to 120,000 (!). |
… |
… |
|
145 | 145 | |
146 | 146 | def old_cremona_letter_code(n): |
147 | 147 | r""" |
148 | | Returns \emph{old} the Cremona letter code corresponding to an |
| 148 | Returns the \emph{old} Cremona letter code corresponding to an |
149 | 149 | integer. |
150 | 150 | |
151 | 151 | For example, |
… |
… |
|
209 | 209 | |
210 | 210 | def parse_cremona_label(label): |
211 | 211 | """ |
212 | | Given a Cremona label corresponding that defines an elliptic |
| 212 | Given a Cremona label that defines an elliptic |
213 | 213 | curve, e.g., 11A1 or 37B3, parse the label and return the |
214 | 214 | conductor, isogeny class label, and number. |
215 | 215 | |
216 | | The isogeny number may be omitted, in which case it default to 1. |
| 216 | The isogeny number may be omitted, in which case it defaults to 1. |
217 | 217 | If the isogeny number and letter are both omitted, so label is |
218 | 218 | just a string representing a conductor, then the label defaults to |
219 | 219 | 'A' and the number to 1. |
… |
… |
|
548 | 548 | def isogeny_class(self, label): |
549 | 549 | """ |
550 | 550 | Returns the isogeny class of elliptic curves that are |
551 | | isogeneous to the curve with given Cremona label. |
| 551 | isogenous to the curve with given Cremona label. |
552 | 552 | INPUT: |
553 | 553 | label -- string |
554 | 554 | OUTPUT: |
555 | | list -- list of EllpticCurve objects. |
| 555 | list -- list of EllipticCurve objects. |
556 | 556 | """ |
557 | 557 | conductor, iso, num = parse_cremona_label(label) |
558 | 558 | A = self.allcurves(conductor) |
… |
… |
|
583 | 583 | INPUT: |
584 | 584 | conductors -- list or generator of ints |
585 | 585 | OUTPUT: |
586 | | generator that iterates over EllipticCurve objects. |
| 586 | list of EllipticCurve objects. |
587 | 587 | """ |
588 | 588 | return list(self.iter(conductors)) |
589 | 589 | |
590 | | def list(self, conductors): |
| 590 | def list_optimal(self, conductors): |
591 | 591 | """ |
592 | 592 | Returns a list of all optimal curves with conductor between Nmin and |
593 | 593 | Nmax-1, inclusive, in the database. |
… |
… |
|
677 | 677 | 4 |
678 | 678 | sage: c.number_of_curves(990) |
679 | 679 | 42 |
| 680 | sage: num = c.number_of_curves() |
680 | 681 | """ |
681 | 682 | if N == 0: |
682 | | return self['number_of_curves'] |
| 683 | try: |
| 684 | # if the optional database is installed, the number is |
| 685 | # easy to get |
| 686 | return self['number_of_curves'] |
| 687 | except KeyError: |
| 688 | # otherwise we need to do a bit of work |
| 689 | num = 0 |
| 690 | for N in range(self.smallest_conductor(), self.largest_conductor()+1): |
| 691 | L = self.allcurves(N) |
| 692 | num = num + len(L) |
| 693 | return num |
| 694 | |
683 | 695 | C = self.allcurves(N) |
684 | 696 | if i == 0: |
685 | 697 | return len(C) |
… |
… |
|
690 | 702 | def number_of_isogeny_classes(self, N=0): |
691 | 703 | """ |
692 | 704 | Returns the number of isogeny classes of curves in the database |
693 | | of conductor N. If N is 0, return the total number of curves |
694 | | in the database. |
| 705 | of conductor N. If N is 0, return the total number of isogeny |
| 706 | classes of curves in the database. |
695 | 707 | |
696 | 708 | INPUT: |
697 | 709 | N -- int |
… |
… |
|
703 | 715 | 1 |
704 | 716 | sage: c.number_of_isogeny_classes(37) |
705 | 717 | 2 |
| 718 | sage: num = c.number_of_isogeny_classes() |
706 | 719 | """ |
707 | 720 | if N == 0: |
708 | | return self['number_of_isogeny_classes'] |
| 721 | try: |
| 722 | # if the optional database is installed, the number is |
| 723 | # easy to get |
| 724 | return self['number_of_isogeny_classes'] |
| 725 | except KeyError: |
| 726 | # otherwise we need to do a bit of work |
| 727 | num = 0 |
| 728 | for N in range(self.smallest_conductor(), self.largest_conductor()+1): |
| 729 | L = self.curves(N) |
| 730 | num = num + len(L) |
| 731 | return num |
| 732 | |
709 | 733 | return len(self.curves(N)) |
710 | 734 | |
| 735 | |
711 | 736 | def random(self): |
712 | 737 | """ |
713 | 738 | Returns a random curve from the database. |