Path: blob/master/src/sage/schemes/jacobians/abstract_jacobian.py
8821 views
"""1Base class for Jacobians of curves2"""34#*******************************************************************************5# Copyright (C) 2005 William Stein6# Distributed under the terms of the GNU General Public License (GPL)7# http://www.gnu.org/licenses/8#*******************************************************************************910from sage.categories.fields import Fields11_Fields = Fields()12from sage.schemes.generic.scheme import Scheme, is_Scheme1314def is_Jacobian(J):15"""16Return True if `J` is of type Jacobian_generic.1718EXAMPLES::1920sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian, is_Jacobian21sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)22sage: C = Curve(x^3 + y^3 + z^3)23sage: J = Jacobian(C)24sage: is_Jacobian(J)25True2627::2829sage: E = EllipticCurve('37a1')30sage: is_Jacobian(E)31False32"""33return isinstance(J, Jacobian_generic)3435def Jacobian(C):36"""37EXAMPLES::3839sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian40sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)41sage: C = Curve(x^3 + y^3 + z^3)42sage: Jacobian(C)43Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^344"""45try:46return C.jacobian()47except AttributeError:48return Jacobian_generic(C)4950class Jacobian_generic(Scheme):51"""52Base class for Jacobians of projective curves.5354The input must be a projective curve over a field.5556EXAMPLES::5758sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian59sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)60sage: C = Curve(x^3 + y^3 + z^3)61sage: J = Jacobian(C); J62Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^363"""64def __init__(self, C):65"""66TESTS::6768sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian_generic69sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)70sage: C = Curve(x^3 + y^3 + z^3)71sage: J = Jacobian_generic(C); J72Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^373sage: type(J)74<class 'sage.schemes.jacobians.abstract_jacobian.Jacobian_generic_with_category'>7576Note: this is an abstract parent, so we skip element tests::7778sage: TestSuite(J).run(skip =["_test_an_element",\79"_test_elements",\80"_test_elements_eq_reflexive",\81"_test_elements_eq_symmetric",\82"_test_elements_eq_transitive",\83"_test_elements_neq",\84"_test_some_elements"])8586::8788sage: Jacobian_generic(ZZ)89Traceback (most recent call last):90...91TypeError: Argument (=Integer Ring) must be a scheme.92sage: Jacobian_generic(P2)93Traceback (most recent call last):94...95ValueError: C (=Projective Space of dimension 2 over Rational Field) must have dimension 1.96sage: P2.<x, y, z> = ProjectiveSpace(Zmod(6), 2)97sage: C = Curve(x + y + z)98sage: Jacobian_generic(C)99Traceback (most recent call last):100...101TypeError: C (=Projective Curve over Ring of integers modulo 6 defined by x + y + z) must be defined over a field.102"""103if not is_Scheme(C):104raise TypeError, "Argument (=%s) must be a scheme."%C105if C.base_ring() not in _Fields:106raise TypeError, "C (=%s) must be defined over a field."%C107if C.dimension() != 1:108raise ValueError, "C (=%s) must have dimension 1."%C109self.__curve = C110Scheme.__init__(self, C.base_scheme())111112def __cmp__(self, J):113"""114Compare the Jacobian self to `J`. If `J` is a Jacobian, then115self and `J` are equal if and only if their curves are equal.116117EXAMPLES::118119sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian120sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)121sage: J1 = Jacobian(Curve(x^3 + y^3 + z^3))122sage: J1 == J1123True124sage: J1 == P2125False126sage: J1 != P2127True128sage: J2 = Jacobian(Curve(x + y + z))129sage: J1 == J2130False131sage: J1 != J2132True133"""134if not is_Jacobian(J):135return cmp(type(self), type(J))136return cmp(self.curve(), J.curve())137138def _repr_(self):139"""140Return a string representation of this Jacobian.141142EXAMPLES::143144sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian145sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)146sage: J = Jacobian(Curve(x^3 + y^3 + z^3)); J147Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^3148sage: J._repr_()149'Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^3'150"""151return "Jacobian of %s"%self.__curve152153def _point(self):154"""155Return the Hom-set from some affine scheme to ``self``.156157OUTPUT:158159This method always raises a ``NotImplementedError``; it is160only abstract.161162EXAMPLES::163164sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian165sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)166sage: J = Jacobian(Curve(x^3 + y^3 + z^3))167sage: J._point()168Traceback (most recent call last):169...170NotImplementedError171"""172raise NotImplementedError173174def curve(self):175"""176Return the curve of which self is the Jacobian.177178EXAMPLES::179180sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian181sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)182sage: J = Jacobian(Curve(x^3 + y^3 + z^3))183sage: J.curve()184Projective Curve over Rational Field defined by x^3 + y^3 + z^3185"""186return self.__curve187188def change_ring(self, R):189r"""190Return the Jacobian over the ring `R`.191192INPUT:193194- ``R`` -- a field. The new base ring.195196OUTPUT:197198The Jacobian over the ring `R`.199200EXAMPLES::201202sage: R.<x> = QQ['x']203sage: H = HyperellipticCurve(x^3-10*x+9)204sage: Jac = H.jacobian(); Jac205Jacobian of Hyperelliptic Curve over Rational206Field defined by y^2 = x^3 - 10*x + 9207sage: Jac.change_ring(RDF)208Jacobian of Hyperelliptic Curve over Real Double209Field defined by y^2 = x^3 - 10.0*x + 9.0210"""211return self.curve().change_ring(R).jacobian()212213def base_extend(self, R):214r"""215Return the natural extension of ``self`` over `R`216217INPUT:218219- ``R`` -- a field. The new base field.220221OUTPUT:222223The Jacobian over the ring `R`.224225EXAMPLES::226227sage: R.<x> = QQ['x']228sage: H = HyperellipticCurve(x^3-10*x+9)229sage: Jac = H.jacobian(); Jac230Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^3 - 10*x + 9231sage: F.<a> = QQ.extension(x^2+1)232sage: Jac.base_extend(F)233Jacobian of Hyperelliptic Curve over Number Field in a with defining234polynomial x^2 + 1 defined by y^2 = x^3 - 10*x + 9235"""236if R not in _Fields:237raise ValueError('Not a field: '+str(R))238if self.base_ring() is R:239return self240if not R.has_coerce_map_from(self.base_ring()):241raise ValueError('no natural map from the base ring (=%s) to R (=%s)!'242% (self.base_ring(), R))243return self.change_ring(R)244245246