Path: blob/master/sage/schemes/jacobians/abstract_jacobian.py
4128 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.rings.all import is_Field11from sage.schemes.generic.scheme import Scheme, is_Scheme1213def is_Jacobian(J):14"""15Return True if `J` is of type Jacobian_generic.1617EXAMPLES::1819sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian, is_Jacobian20sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)21sage: C = Curve(x^3 + y^3 + z^3)22sage: J = Jacobian(C)23sage: is_Jacobian(J)24True2526::2728sage: E = EllipticCurve('37a1')29sage: is_Jacobian(E)30False31"""32return isinstance(J, Jacobian_generic)3334def Jacobian(C):35"""36EXAMPLES::3738sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian39sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)40sage: C = Curve(x^3 + y^3 + z^3)41sage: Jacobian(C)42Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^343"""44try:45return C.jacobian()46except AttributeError:47return Jacobian_generic(C)4849class Jacobian_generic(Scheme):50"""51Base class for Jacobians of projective curves.5253The input must be a projective curve over a field.5455EXAMPLES::5657sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian58sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)59sage: C = Curve(x^3 + y^3 + z^3)60sage: J = Jacobian(C); J61Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^362"""63def __init__(self, C):64"""65TESTS::6667sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian_generic68sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)69sage: C = Curve(x^3 + y^3 + z^3)70sage: J = Jacobian_generic(C); J71Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^372sage: type(J)73<class 'sage.schemes.jacobians.abstract_jacobian.Jacobian_generic_with_category'>7475Note: this is an abstract parent, so we skip element tests::7677sage: TestSuite(J).run(skip =["_test_an_element", "_test_elements", "_test_elements_eq", "_test_some_elements"])7879::8081sage: Jacobian_generic(ZZ)82Traceback (most recent call last):83...84TypeError: Argument (=Integer Ring) must be a scheme.85sage: Jacobian_generic(P2)86Traceback (most recent call last):87...88ValueError: C (=Projective Space of dimension 2 over Rational Field) must have dimension 1.89sage: P2.<x, y, z> = ProjectiveSpace(Zmod(6), 2)90sage: C = Curve(x + y + z)91sage: Jacobian_generic(C)92Traceback (most recent call last):93...94TypeError: C (=Projective Curve over Ring of integers modulo 6 defined by x + y + z) must be defined over a field.95"""96if not is_Scheme(C):97raise TypeError, "Argument (=%s) must be a scheme."%C98if not is_Field(C.base_ring()):99raise TypeError, "C (=%s) must be defined over a field."%C100if C.dimension() != 1:101raise ValueError, "C (=%s) must have dimension 1."%C102self.__curve = C103Scheme.__init__(self, C.base_scheme())104105def __cmp__(self, J):106"""107Compare the Jacobian self to `J`. If `J` is a Jacobian, then108self and `J` are equal if and only if their curves are equal.109110EXAMPLES::111112sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian113sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)114sage: J1 = Jacobian(Curve(x^3 + y^3 + z^3))115sage: J1 == J1116True117sage: J1 == P2118False119sage: J1 != P2120True121sage: J2 = Jacobian(Curve(x + y + z))122sage: J1 == J2123False124sage: J1 != J2125True126"""127if not is_Jacobian(J):128return cmp(type(self), type(J))129return cmp(self.curve(), J.curve())130131def _repr_(self):132"""133Return a string representation of this Jacobian.134135EXAMPLES::136137sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian138sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)139sage: J = Jacobian(Curve(x^3 + y^3 + z^3)); J140Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^3141sage: J._repr_()142'Jacobian of Projective Curve over Rational Field defined by x^3 + y^3 + z^3'143"""144return "Jacobian of %s"%self.__curve145146def _point(self):147"""148Return the Hom-set from some affine scheme to ``self``.149150OUTPUT:151152This method always raises a ``NotImplementedError``; it is153only abstract.154155EXAMPLES::156157sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian158sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)159sage: J = Jacobian(Curve(x^3 + y^3 + z^3))160sage: J._point()161Traceback (most recent call last):162...163NotImplementedError164"""165raise NotImplementedError166167def curve(self):168"""169Return the curve of which self is the Jacobian.170171EXAMPLES::172173sage: from sage.schemes.jacobians.abstract_jacobian import Jacobian174sage: P2.<x, y, z> = ProjectiveSpace(QQ, 2)175sage: J = Jacobian(Curve(x^3 + y^3 + z^3))176sage: J.curve()177Projective Curve over Rational Field defined by x^3 + y^3 + z^3178"""179return self.__curve180181def change_ring(self, R):182r"""183Return the Jacobian over the ring `R`.184185INPUT:186187- ``R`` -- a field. The new base ring.188189OUTPUT:190191The Jacobian over the ring `R`.192193EXAMPLES::194195sage: R.<x> = QQ['x']196sage: H = HyperellipticCurve(x^3-10*x+9)197sage: Jac = H.jacobian(); Jac198Jacobian of Hyperelliptic Curve over Rational199Field defined by y^2 = x^3 - 10*x + 9200sage: Jac.change_ring(RDF)201Jacobian of Hyperelliptic Curve over Real Double202Field defined by y^2 = x^3 - 10.0*x + 9.0203"""204return self.curve().change_ring(R).jacobian()205206def base_extend(self, R):207r"""208Return the natural extension of ``self`` over `R`209210INPUT:211212- ``R`` -- a field. The new base field.213214OUTPUT:215216The Jacobian over the ring `R`.217218EXAMPLES::219220sage: R.<x> = QQ['x']221sage: H = HyperellipticCurve(x^3-10*x+9)222sage: Jac = H.jacobian(); Jac223Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^3 - 10*x + 9224sage: F.<a> = QQ.extension(x^2+1)225sage: Jac.base_extend(F)226Jacobian of Hyperelliptic Curve over Number Field in a with defining227polynomial x^2 + 1 defined by y^2 = x^3 - 10*x + 9228"""229if not is_Field(R):230raise ValueError('Not a field: '+str(R))231if self.base_ring() is R:232return self233if not R.has_coerce_map_from(self.base_ring()):234raise ValueError('no natural map from the base ring (=%s) to R (=%s)!'235% (self.base_ring(), R))236return self.change_ring(R)237238239