Skip to content

Commit 1da7752

Browse files
author
Release Manager
committed
Trac #34284: hardcode that curves have dimension 1
Example: {{{#!sage sage: proof.all(False) sage: R.<x> = GF((2^521-1,2))[] sage: C = HyperellipticCurve(R.random_element(degree=999)) sage: %time _ = C.jacobian() verbose 0 (3879: multi_polynomial_ideal.py, groebner_basis) Warning: falling back to very slow toy implementation. verbose 0 (1082: multi_polynomial_ideal.py, dimension) Warning: falling back to very slow toy implementation. CPU times: user 2.67 s, sys: 9.99 ms, total: 2.68 s Wall time: 2.72 s }}} All the time is spent on computing the dimension of the curve, and since the base field is not suitable for Singular this is done using Sage's own implementation. By definition, curves have dimension one, so this is totally redundant and can be avoided by adding an implementation of `.dimension()` to `Curve_generic` that simply returns `1`. This was pointed out here: https://github.com/jack4818/Castryck-Decru-SageMath#additional-monkey- patch-for-fixing-the-dimension With the patch, there is no more "toy implementation" warning and it's fast: {{{ CPU times: user 119 µs, sys: 2 µs, total: 121 µs Wall time: 124 µs }}} URL: https://trac.sagemath.org/34284 Reported by: lorenz Ticket author(s): Lorenz Panny Reviewer(s): Julien Grijalva
2 parents fe34675 + cbd8040 commit 1da7752

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/sage/schemes/curves/affine_curve.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -908,11 +908,7 @@ def projection(self, indices, AS=None):
908908
To: Affine Space of dimension 3 over Rational Field
909909
Defn: Defined on coordinates by sending (x, y, z, w) to
910910
(x, y, z),
911-
Closed subscheme of Affine Space of dimension 3 over Rational Field
912-
defined by:
913-
c - 1,
914-
b - 3,
915-
a - 2)
911+
Affine Curve over Rational Field defined by c - 1, b - 3, a - 2)
916912
917913
::
918914

src/sage/schemes/curves/curve.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
from sage.schemes.generic.divisor_group import DivisorGroup
3939
from sage.schemes.generic.divisor import Divisor_curve
4040

41+
from sage.rings.integer import Integer
42+
4143
class Curve_generic(AlgebraicScheme_subscheme):
4244
r"""
4345
Generic curve class.
@@ -113,6 +115,24 @@ def _latex_(self):
113115
polys = ', '.join(f'${latex(p)}$' for p in self.defining_polynomials())
114116
return fr"\text{{{ambient_type} curve over ${ring}$ defined by {polys}}}"
115117

118+
def dimension(self):
119+
r"""
120+
Return the dimension of the curve.
121+
122+
Curves have dimension one by definition.
123+
124+
EXAMPLES::
125+
126+
sage: x = polygen(QQ)
127+
sage: C = HyperellipticCurve(x^7 + x^4 + x)
128+
sage: C.dimension()
129+
1
130+
sage: from sage.schemes.projective.projective_subscheme import AlgebraicScheme_subscheme_projective
131+
sage: AlgebraicScheme_subscheme_projective.dimension(C)
132+
1
133+
"""
134+
return Integer(1)
135+
116136
def defining_polynomial(self):
117137
"""
118138
Return the defining polynomial of the curve.

0 commit comments

Comments
 (0)