Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Make the cardinality in ell_finite_field more robust.
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Scrimshaw committed Jul 18, 2014
1 parent 185b49c commit f62a54a
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/sage/schemes/elliptic_curves/ell_finite_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,27 +764,26 @@ def cardinality(self, algorithm='heuristic', extension_degree=1):
INPUT:
- ``algorithm`` - string (default: 'heuristic'), used
- ``algorithm`` - string (default: ``'heuristic'``), used
only for point counting over prime fields
- ``'heuristic'`` - use a heuristic to choose between
``'pari'`` and ``'bsgs'``.
- ``'heuristic'`` - use a heuristic to choose between
``'pari'`` and ``'bsgs'``
- ``'pari'`` - use the baby step giant step or SEA methods
as implemented in PARI via the C-library function ellap.
- ``'pari'`` - use the baby step giant step or SEA methods
as implemented in PARI via the C-library function ellap
- ``'bsgs'`` - use the baby step giant step method as
implemented in Sage, with the Cremona-Sutherland version
of Mestre's trick.
- ``'bsgs'`` - use the baby step giant step method as
implemented in Sage, with the Cremona-Sutherland version
of Mestre's trick
- ``'all'`` - (over prime fields only) compute cardinality
with all of PARI and bsgs; return result if they agree
or raise a RuntimeError if they do not.
- ``'all'`` - (over prime fields only) compute cardinality
with all of PARI and bsgs; return result if they agree
or raise a ``RuntimeError`` if they do not
- ``extension_degree`` - int (default: 1); if the
base field is `k=GF(p^n)` and extension_degree=d, returns
the cardinality of `E(GF(p^{n d}))`.
the cardinality of `E(GF(p^{n d}))`
OUTPUT: an integer
Expand All @@ -796,7 +795,7 @@ def cardinality(self, algorithm='heuristic', extension_degree=1):
curve with the same j-invariant over the field GF(p)(j), then
lifted to the base_field, and finally account is taken of twists.
For j=0 and j=1728 special formulas are used instead.
For `j = 0` and `j = 1728` special formulas are used instead.
EXAMPLES::
Expand Down Expand Up @@ -847,6 +846,11 @@ def cardinality(self, algorithm='heuristic', extension_degree=1):
...
ValueError: Algorithm is not known
"""
if algorithm == 'sea':
algorithm = 'pari' # purely for backwards compatibility
if algorithm not in ['heuristic', 'pari', 'bsgs', 'all']:
raise ValueError("Algorithm is not known")

if extension_degree>1:
# A recursive call to cardinality() with
# extension_degree=1, which will cache the cardinality, is
Expand Down Expand Up @@ -888,8 +892,6 @@ def cardinality(self, algorithm='heuristic', extension_degree=1):
algorithm = 'pari'
if algorithm == 'pari':
N = self.cardinality_pari()
elif algorithm == 'sea':
N = self.cardinality_pari() # purely for backwards compatibility
elif algorithm == 'bsgs':
N = self.cardinality_bsgs()
elif algorithm == 'all':
Expand All @@ -899,8 +901,6 @@ def cardinality(self, algorithm='heuristic', extension_degree=1):
N = N1
else:
raise RuntimeError("BUG! Cardinality with pari=%s but with bsgs=%s"%(N1, N2))
else:
raise ValueError("Algorithm is not known")
self._order = Integer(N)
return self._order

Expand Down

0 comments on commit f62a54a

Please sign in to comment.