Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/schemes/jacobians/abstract_jacobian.py
4128 views
1
"""
2
Base class for Jacobians of curves
3
"""
4
5
#*******************************************************************************
6
# Copyright (C) 2005 William Stein
7
# Distributed under the terms of the GNU General Public License (GPL)
8
# http://www.gnu.org/licenses/
9
#*******************************************************************************
10
11
from sage.rings.all import is_Field
12
from sage.schemes.generic.scheme import Scheme, is_Scheme
13
14
def is_Jacobian(J):
15
"""
16
Return True if `J` is of type Jacobian_generic.
17
18
EXAMPLES::
19
20
sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian, is_Jacobian
21
sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)
22
sage: C = Curve(x^3 + y^3 + z^3)
23
sage: J = Jacobian(C)
24
sage: is_Jacobian(J)
25
True
26
27
::
28
29
sage: E = EllipticCurve('37a1')
30
sage: is_Jacobian(E)
31
False
32
"""
33
return isinstance(J, Jacobian_generic)
34
35
def Jacobian(C):
36
"""
37
EXAMPLES::
38
39
sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian
40
sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)
41
sage: C = Curve(x^3 + y^3 + z^3)
42
sage: Jacobian(C)
43
Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^3
44
"""
45
try:
46
return C.jacobian()
47
except AttributeError:
48
return Jacobian_generic(C)
49
50
class Jacobian_generic(Scheme):
51
"""
52
Base class for Jacobians of projective curves.
53
54
The input must be a projective curve over a field.
55
56
EXAMPLES::
57
58
sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian
59
sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)
60
sage: C = Curve(x^3 + y^3 + z^3)
61
sage: J = Jacobian(C); J
62
Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^3
63
"""
64
def __init__(self, C):
65
"""
66
TESTS::
67
68
sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian_generic
69
sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)
70
sage: C = Curve(x^3 + y^3 + z^3)
71
sage: J = Jacobian_generic(C); J
72
Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^3
73
sage: type(J)
74
<class 'sage.schemes.jacobians.abstract_jacobian.Jacobian_generic_with_category'>
75
76
Note: this is an abstract parent, so we skip element tests::
77
78
sage: TestSuite(J).run(skip =["_test_an_element", "_test_elements", "_test_elements_eq", "_test_some_elements"])
79
80
::
81
82
sage: Jacobian_generic(ZZ)
83
Traceback (most recent call last):
84
...
85
TypeError: Argument (=Integer Ring) must be a scheme.
86
sage: Jacobian_generic(P2)
87
Traceback (most recent call last):
88
...
89
ValueError: C (=Projective Space of dimension 2 over Rational Field) must have dimension 1.
90
sage: P2.<x, y, z> = ProjectiveSpace(Zmod(6), 2)
91
sage: C = Curve(x + y + z)
92
sage: Jacobian_generic(C)
93
Traceback (most recent call last):
94
...
95
TypeError: C (=Projective Curve over Ring of integers modulo 6 defined by x + y + z) must be defined over a field.
96
"""
97
if not is_Scheme(C):
98
raise TypeError, "Argument (=%s) must be a scheme."%C
99
if not is_Field(C.base_ring()):
100
raise TypeError, "C (=%s) must be defined over a field."%C
101
if C.dimension() != 1:
102
raise ValueError, "C (=%s) must have dimension 1."%C
103
self.__curve = C
104
Scheme.__init__(self, C.base_scheme())
105
106
def __cmp__(self, J):
107
"""
108
Compare the Jacobian self to `J`. If `J` is a Jacobian, then
109
self and `J` are equal if and only if their curves are equal.
110
111
EXAMPLES::
112
113
sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian
114
sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)
115
sage: J1 = Jacobian(Curve(x^3 + y^3 + z^3))
116
sage: J1 == J1
117
True
118
sage: J1 == P2
119
False
120
sage: J1 != P2
121
True
122
sage: J2 = Jacobian(Curve(x + y + z))
123
sage: J1 == J2
124
False
125
sage: J1 != J2
126
True
127
"""
128
if not is_Jacobian(J):
129
return cmp(type(self), type(J))
130
return cmp(self.curve(), J.curve())
131
132
def _repr_(self):
133
"""
134
Return a string representation of this Jacobian.
135
136
EXAMPLES::
137
138
sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian
139
sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)
140
sage: J = Jacobian(Curve(x^3 + y^3 + z^3)); J
141
Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^3
142
sage: J._repr_()
143
'Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^3'
144
"""
145
return "Jacobian of %s"%self.__curve
146
147
def _point(self):
148
"""
149
Return the Hom-set from some affine scheme to ``self``.
150
151
OUTPUT:
152
153
This method always raises a ``NotImplementedError``; it is
154
only abstract.
155
156
EXAMPLES::
157
158
sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian
159
sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)
160
sage: J = Jacobian(Curve(x^3 + y^3 + z^3))
161
sage: J._point()
162
Traceback (most recent call last):
163
...
164
NotImplementedError
165
"""
166
raise NotImplementedError
167
168
def curve(self):
169
"""
170
Return the curve of which self is the Jacobian.
171
172
EXAMPLES::
173
174
sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian
175
sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)
176
sage: J = Jacobian(Curve(x^3 + y^3 + z^3))
177
sage: J.curve()
178
Projective Curve over Rational Field defined by x^3 + y^3 + z^3
179
"""
180
return self.__curve
181
182
def change_ring(self, R):
183
r"""
184
Return the Jacobian over the ring `R`.
185
186
INPUT:
187
188
- ``R`` -- a field. The new base ring.
189
190
OUTPUT:
191
192
The Jacobian over the ring `R`.
193
194
EXAMPLES::
195
196
sage: R.<x> = QQ['x']
197
sage: H = HyperellipticCurve(x^3-10*x+9)
198
sage: Jac = H.jacobian(); Jac
199
Jacobian of Hyperelliptic Curve over Rational
200
Field defined by y^2 = x^3 - 10*x + 9
201
sage: Jac.change_ring(RDF)
202
Jacobian of Hyperelliptic Curve over Real Double
203
Field defined by y^2 = x^3 - 10.0*x + 9.0
204
"""
205
return self.curve().change_ring(R).jacobian()
206
207
def base_extend(self, R):
208
r"""
209
Return the natural extension of ``self`` over `R`
210
211
INPUT:
212
213
- ``R`` -- a field. The new base field.
214
215
OUTPUT:
216
217
The Jacobian over the ring `R`.
218
219
EXAMPLES::
220
221
sage: R.<x> = QQ['x']
222
sage: H = HyperellipticCurve(x^3-10*x+9)
223
sage: Jac = H.jacobian(); Jac
224
Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^3 - 10*x + 9
225
sage: F.<a> = QQ.extension(x^2+1)
226
sage: Jac.base_extend(F)
227
Jacobian of Hyperelliptic Curve over Number Field in a with defining
228
polynomial x^2 + 1 defined by y^2 = x^3 - 10*x + 9
229
"""
230
if not is_Field(R):
231
raise ValueError('Not a field: '+str(R))
232
if self.base_ring() is R:
233
return self
234
if not R.has_coerce_map_from(self.base_ring()):
235
raise ValueError('no natural map from the base ring (=%s) to R (=%s)!'
236
% (self.base_ring(), R))
237
return self.change_ring(R)
238
239