def __init__(self, parent, polys, check=True): r""" The Python constructor. INPUT: - ``parent`` -- Homset - ``polys`` -- anything that defines a point in the class - ``check`` -- Boolean. Whether or not to perform input checks (Default: ``True``) EXAMPLES:: sage: P1.<x0,x1,x2> = ProjectiveSpace(QQ,2) sage: P2 = ProjectiveSpace(QQ,3,'y') sage: T = ProductProjectiveSpaces([P1,P2]) sage: Q1 = P1(1,1,1) sage: Q2 = P2(1,2,3,4) sage: T([Q1,Q2]) (1 : 1 : 1 , 1/4 : 1/2 : 3/4 : 1) :: sage: T = ProductProjectiveSpaces([2,2,2],GF(5),'x') sage: T.point([1,2,3,4,5,6,7,8,9]) (2 : 4 : 1 , 4 : 0 : 1 , 3 : 2 : 1) :: sage: T.<x,y,z,w> = ProductProjectiveSpaces([1,1],GF(5)) sage: X = T.subscheme([x-y,z-2*w]) sage: X([1,1,2,1]) (1 : 1 , 2 : 1) """ SchemeMorphism.__init__(self, parent) if all(isinstance(P, SchemeMorphism_point) for P in polys): if check: Q = [] self._points = [] for i in range(len(polys)): if polys[i].codomain() != parent.codomain().ambient_space( )[i]: raise ValueError( "Points must be in correct projective spaces") Q += list(polys[i]) self._points.append(polys[i]) parent.codomain()._check_satisfies_equations(Q) self._points = polys else: N = parent.codomain().ambient_space( ).dimension_relative_components() if check: parent.codomain()._check_satisfies_equations(polys) splitpolys = self.codomain().ambient_space()._factors(polys) self._points = [ parent.codomain().ambient_space()[i].point( splitpolys[i], check) for i in range(len(N)) ]
def __init__(self, X, v, check=True): """ The Python constructor. See :class:`SchemeMorphism_point_affine` for details. TESTS:: sage: from sage.schemes.affine.affine_point import SchemeMorphism_point_affine sage: A3.<x,y,z> = AffineSpace(QQ, 3) sage: SchemeMorphism_point_affine(A3(QQ), [1,2,3]) (1, 2, 3) """ SchemeMorphism.__init__(self, X) if is_SchemeMorphism(v): v = list(v) if check: # Verify that there are the right number of coords d = self.codomain().ambient_space().ngens() if len(v) != d: raise TypeError("Argument v (=%s) must have %s coordinates." % (v, d)) if not isinstance(v, (list, tuple)): raise TypeError( "Argument v (= %s) must be a scheme point, list, or tuple." % str(v)) # Make sure the coordinates all lie in the appropriate ring v = Sequence(v, X.value_ring()) # Verify that the point satisfies the equations of X. X.extended_codomain()._check_satisfies_equations(v) self._coords = tuple(v)
def __init__(self, parent, fan_morphism, check=True): r""" See :class:`SchemeMorphism_polynomial_toric_variety` for documentation. TESTS:: sage: P1xP1 = toric_varieties.P1xP1() sage: P1 = toric_varieties.P1() sage: hom_set = P1xP1.Hom(P1) sage: fan_morphism = FanMorphism( matrix(ZZ,[[1],[0]]), P1xP1.fan(), P1.fan() ) sage: from sage.schemes.toric.morphism import SchemeMorphism_fan_toric_variety sage: SchemeMorphism_fan_toric_variety(hom_set, fan_morphism) Scheme morphism: From: 2-d CPR-Fano toric variety covered by 4 affine patches To: 1-d CPR-Fano toric variety covered by 2 affine patches Defn: Defined by sending Rational polyhedral fan in 2-d lattice N to Rational polyhedral fan in 1-d lattice N. """ SchemeMorphism.__init__(self, parent) if check and self.domain().fan() != fan_morphism.domain_fan(): raise ValueError( 'The fan morphism domain must be the fan of the domain.') if check and self.codomain().fan() != fan_morphism.codomain_fan(): raise ValueError( 'The fan morphism codomain must be the fan of the codomain.') self._fan_morphism = fan_morphism
def __init__(self, X, v, check=True): """ The Python constructor. See :class:`SchemeMorphism_point_affine` for details. TESTS:: sage: from sage.schemes.affine.affine_point import SchemeMorphism_point_affine sage: A3.<x,y,z> = AffineSpace(QQ, 3) sage: SchemeMorphism_point_affine(A3(QQ), [1,2,3]) (1, 2, 3) """ SchemeMorphism.__init__(self, X) if is_SchemeMorphism(v): v = list(v) if check: # Verify that there are the right number of coords d = self.codomain().ambient_space().ngens() if len(v) != d: raise TypeError("Argument v (=%s) must have %s coordinates." % (v, d)) if not isinstance(v, (list, tuple)): raise TypeError("Argument v (= %s) must be a scheme point, list, or tuple." % str(v)) # Make sure the coordinates all lie in the appropriate ring v = Sequence(v, X.value_ring()) # Verify that the point satisfies the equations of X. X.extended_codomain()._check_satisfies_equations(v) self._coords = tuple(v)
def __init__(self, parent, polys, check=True): r""" The Python constructor. INPUT: - ``parent`` -- Hom-set. - ``polys`` -- anything that defines a point in the class. - ``check`` -- Boolean. Whether or not to perform input checks. (Default: ``True``) EXAMPLES:: sage: P1.<x0,x1,x2> = ProjectiveSpace(QQ, 2) sage: P2 = ProjectiveSpace(QQ, 3, 'y') sage: T = ProductProjectiveSpaces([P1, P2]) sage: Q1 = P1(1, 1, 1) sage: Q2 = P2(1, 2, 3, 4) sage: T([Q1, Q2]) (1 : 1 : 1 , 1/4 : 1/2 : 3/4 : 1) :: sage: T = ProductProjectiveSpaces([2, 2, 2], GF(5), 'x') sage: T.point([1, 2, 3, 4, 5, 6, 7, 8, 9]) (2 : 4 : 1 , 4 : 0 : 1 , 3 : 2 : 1) :: sage: T.<x,y,z,w> = ProductProjectiveSpaces([1, 1], GF(5)) sage: X = T.subscheme([x-y, z-2*w]) sage: X([1, 1, 2, 1]) (1 : 1 , 2 : 1) """ polys = copy(polys) SchemeMorphism.__init__(self, parent) if all(isinstance(P, SchemeMorphism_point) for P in polys): if check: Q = [] self._points = [] for i in range(len(polys)): if polys[i].codomain() != parent.codomain().ambient_space()[i]: raise ValueError("points must be in correct projective spaces") Q += list(polys[i]) self._points.append(polys[i]) parent.codomain()._check_satisfies_equations(Q) self._points = polys else: R = parent.codomain().ambient_space().base_ring() polys = Sequence(polys, R) N = parent.codomain().ambient_space().dimension_relative_components() if check: parent.codomain()._check_satisfies_equations(polys) splitpolys=self.codomain().ambient_space()._factors(polys) self._points = [parent.codomain().ambient_space()[i].point(splitpolys[i], check) for i in range(len(N))]
def __init__(self, parent, polys, check=True): r""" Create a new Jacobian element in Mumford representation. INPUT: parent: the parent Homset polys: Mumford's `u` and `v` polynomials check (default: True): if True, ensure that polynomials define a divisor on the appropriate curve and are reduced .. warning:: Not for external use! Use ``J(K)([u, v])`` instead. EXAMPLES:: sage: x = GF(37)['x'].gen() sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) sage: J = H.jacobian()(GF(37)); J Set of rational points of Jacobian of Hyperelliptic Curve over Finite Field of size 37 defined by y^2 = x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x :: sage: P1 = J(H.lift_x(2)); P1 # indirect doctest (x + 35, y + 26) sage: P1.parent() Set of rational points of Jacobian of Hyperelliptic Curve over Finite Field of size 37 defined by y^2 = x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x sage: type(P1) <class 'sage.schemes.hyperelliptic_curves.jacobian_morphism.JacobianMorphism_divisor_class_field'> """ SchemeMorphism.__init__(self, parent) if check: C = parent.curve() f, h = C.hyperelliptic_polynomials() a, b = polys if not (b**2 + h*b - f)%a == 0: raise ValueError, \ "Argument polys (= %s) must be divisor on curve %s."%( polys, C) genus = C.genus() if a.degree() > genus: polys = cantor_reduction(a, b, f, h, genus) self.__polys = polys
def __init__(self, parent, polys, check=True): r""" Create a new Jacobian element in Mumford representation. INPUT: parent: the parent Homset polys: Mumford's `u` and `v` polynomials check (default: True): if True, ensure that polynomials define a divisor on the appropriate curve and are reduced .. warning:: Not for external use! Use ``J(K)([u, v])`` instead. EXAMPLES:: sage: x = GF(37)['x'].gen() sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) sage: J = H.jacobian()(GF(37)); J Set of rational points of Jacobian of Hyperelliptic Curve over Finite Field of size 37 defined by y^2 = x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x :: sage: P1 = J(H.lift_x(2)); P1 # indirect doctest (x + 35, y + 26) sage: P1.parent() Set of rational points of Jacobian of Hyperelliptic Curve over Finite Field of size 37 defined by y^2 = x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x sage: type(P1) <class 'sage.schemes.hyperelliptic_curves.jacobian_morphism.JacobianMorphism_divisor_class_field'> """ SchemeMorphism.__init__(self, parent) if check: C = parent.curve() f, h = C.hyperelliptic_polynomials() a, b = polys if not (b**2 + h * b - f) % a == 0: raise ValueError( "Argument polys (= %s) must be divisor on curve %s." % (polys, C)) genus = C.genus() if a.degree() > genus: polys = cantor_reduction(a, b, f, h, genus) self.__polys = polys
def __init__(self, parent, fan_morphism, check=True): r""" See :class:`SchemeMorphism_polynomial_toric_variety` for documentation. TESTS:: sage: P1xP1 = toric_varieties.P1xP1() sage: P1 = toric_varieties.P1() sage: hom_set = P1xP1.Hom(P1) sage: fan_morphism = FanMorphism( matrix(ZZ,[[1],[0]]), P1xP1.fan(), P1.fan() ) sage: from sage.schemes.toric.morphism import SchemeMorphism_fan_toric_variety sage: SchemeMorphism_fan_toric_variety(hom_set, fan_morphism) Scheme morphism: From: 2-d CPR-Fano toric variety covered by 4 affine patches To: 1-d CPR-Fano toric variety covered by 2 affine patches Defn: Defined by sending Rational polyhedral fan in 2-d lattice N to Rational polyhedral fan in 1-d lattice N. """ SchemeMorphism.__init__(self, parent) if check and self.domain().fan()!=fan_morphism.domain_fan(): raise ValueError('The fan morphism domain must be the fan of the domain.') if check and self.codomain().fan()!=fan_morphism.codomain_fan(): raise ValueError('The fan morphism codomain must be the fan of the codomain.') self._fan_morphism = fan_morphism
def __init__(self, X, v, check=True): """ The Python constructor. See :class:`SchemeMorphism_point_projective_ring` for details. This function still normalizes points so that the rightmost non-zero coordinate is 1. This is to maintain functionality with current implementations of curves in projectives space (plane, conic, elliptic, etc). The :class:`SchemeMorphism_point_projective_ring` is for general use. EXAMPLES:: sage: P = ProjectiveSpace(2, QQ) sage: P(2, 3/5, 4) (1/2 : 3/20 : 1) :: sage: P = ProjectiveSpace(3, QQ) sage: P(0, 0, 0, 0) Traceback (most recent call last): ... ValueError: [0, 0, 0, 0] does not define a valid point since all entries are 0 :: sage: P.<x, y, z> = ProjectiveSpace(2, QQ) sage: X = P.subscheme([x^2-y*z]) sage: X([2, 2, 2]) (1 : 1 : 1) :: sage: P = ProjectiveSpace(1, GF(7)) sage: Q=P([2, 1]) sage: Q[0].parent() Finite Field of size 7 :: sage: P = ProjectiveSpace(QQ,1) sage: P.point(Infinity) (1 : 0) sage: P(infinity) (1 : 0) :: sage: P = ProjectiveSpace(QQ,2) sage: P(infinity) Traceback (most recent call last): ... ValueError: +Infinity not well defined in dimension > 1 sage: P.point(infinity) Traceback (most recent call last): ... ValueError: +Infinity not well defined in dimension > 1 """ SchemeMorphism.__init__(self, X) if check: from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_field from sage.rings.ring import CommutativeRing d = X.codomain().ambient_space().ngens() if is_SchemeMorphism(v) or isinstance(v, EllipticCurvePoint_field): v = list(v) else: try: if isinstance(v.parent(), CommutativeRing): v = [v] except AttributeError: pass if not isinstance(v, (list,tuple)): raise TypeError("argument v (= %s) must be a scheme point, list, or tuple"%str(v)) if len(v) != d and len(v) != d-1: raise TypeError("v (=%s) must have %s components"%(v, d)) R = X.value_ring() v = Sequence(v, R) if len(v) == d-1: # very common special case v.append(R(1)) n = len(v) all_zero = True for i in range(n): last = n-1-i if v[last]: all_zero = False c = v[last] if c == R.one(): break for j in range(last): v[j] /= c v[last] = R.one() break if all_zero: raise ValueError("%s does not define a valid point since all entries are 0"%repr(v)) X.extended_codomain()._check_satisfies_equations(v) self._coords = tuple(v)
def __init__(self, X, v, check=True): """ The Python constructor. EXAMPLES:: sage: P = ProjectiveSpace(2, QQ) sage: P(2, 3/5, 4) (1/2 : 3/20 : 1) :: sage: P = ProjectiveSpace(1, ZZ) sage: P([0, 1]) (0 : 1) :: sage: P = ProjectiveSpace(1, ZZ) sage: P([0, 0, 1]) Traceback (most recent call last): ... TypeError: v (=[0, 0, 1]) must have 2 components :: sage: P = ProjectiveSpace(3, QQ) sage: P(0,0,0,0) Traceback (most recent call last): ... ValueError: [0, 0, 0, 0] does not define a valid point since all entries are 0 It is possible to avoid the possibly time-consuming checks, but be careful!! :: sage: P = ProjectiveSpace(3, QQ) sage: P.point([0,0,0,0], check=False) (0 : 0 : 0 : 0) :: sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) sage: X = P.subscheme([x^2-y*z]) sage: X([2, 2, 2]) (2 : 2 : 2) :: sage: R.<t> = PolynomialRing(ZZ) sage: P = ProjectiveSpace(1, R.quo(t^2+1)) sage: P([2*t, 1]) (2*tbar : 1) :: sage: P = ProjectiveSpace(ZZ,1) sage: P.point(Infinity) (1 : 0) sage: P(infinity) (1 : 0) :: sage: P = ProjectiveSpace(ZZ,2) sage: P(Infinity) Traceback (most recent call last): ... ValueError: +Infinity not well defined in dimension > 1 sage: P.point(infinity) Traceback (most recent call last): ... ValueError: +Infinity not well defined in dimension > 1 """ SchemeMorphism.__init__(self, X) if check: from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_field from sage.rings.ring import CommutativeRing d = X.codomain().ambient_space().ngens() if is_SchemeMorphism(v) or isinstance(v, EllipticCurvePoint_field): v = list(v) else: try: if isinstance(v.parent(), CommutativeRing): v = [v] except AttributeError: pass if not isinstance(v, (list, tuple)): raise TypeError("argument v (= %s) must be a scheme point, list, or tuple"%str(v)) if len(v) != d and len(v) != d-1: raise TypeError("v (=%s) must have %s components"%(v, d)) R = X.value_ring() v = Sequence(v, R) if len(v) == d-1: # very common special case v.append(R(1)) n = len(v) all_zero = True for i in range(n): last = n-1-i if v[last]: all_zero = False break if all_zero: raise ValueError("%s does not define a valid point since all entries are 0"%repr(v)) X.extended_codomain()._check_satisfies_equations(v) self._coords = tuple(v)
def __init__(self, X, v, check=True): """ The Python constructor. EXAMPLES:: sage: P = ProjectiveSpace(2, QQ) sage: P(2, 3/5, 4) (1/2 : 3/20 : 1) :: sage: P = ProjectiveSpace(1, ZZ) sage: P([0, 1]) (0 : 1) :: sage: P = ProjectiveSpace(1, ZZ) sage: P([0, 0, 1]) Traceback (most recent call last): ... TypeError: v (=[0, 0, 1]) must have 2 components :: sage: P = ProjectiveSpace(3, QQ) sage: P(0,0,0,0) Traceback (most recent call last): ... ValueError: [0, 0, 0, 0] does not define a valid point since all entries are 0 :: It is possible to avoid the possibly time consuming checks, but be careful!! sage: P = ProjectiveSpace(3, QQ) sage: P.point([0,0,0,0],check=False) (0 : 0 : 0 : 0) :: sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) sage: X=P.subscheme([x^2-y*z]) sage: X([2,2,2]) (2 : 2 : 2) """ SchemeMorphism.__init__(self, X) if check: from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_field d = X.codomain().ambient_space().ngens() if is_SchemeMorphism(v) or isinstance(v, EllipticCurvePoint_field): v = list(v) elif v is infinity: v = [0] * (d) v[1] = 1 if not isinstance(v,(list,tuple)): raise TypeError("Argument v (= %s) must be a scheme point, list, or tuple."%str(v)) if len(v) != d and len(v) != d-1: raise TypeError("v (=%s) must have %s components"%(v, d)) R = X.value_ring() v = Sequence(v, R) if len(v) == d-1: # very common special case v.append(1) n = len(v) all_zero = True for i in range(n): last = n-1-i if v[last]: all_zero = False break if all_zero: raise ValueError("%s does not define a valid point since all entries are 0"%repr(v)) X.extended_codomain()._check_satisfies_equations(v) if isinstance(X.codomain().base_ring(), QuotientRing_generic): lift_coords = [P.lift() for P in v] else: lift_coords = v v = Sequence(lift_coords) self._coords = v
def __init__(self, X, v, check=True): """ The Python constructor. See :class:`SchemeMorphism_point_projective_ring` for details. This function still normalized points so that the rightmost non-zero coordinate is 1. The is to maintain current functionality with current implementations of curves in projectives space (plane, connic, elliptic, etc). The class:`SchemeMorphism_point_projective_ring` is for general use. EXAMPLES:: sage: P = ProjectiveSpace(2, QQ) sage: P(2, 3/5, 4) (1/2 : 3/20 : 1) :: sage: P = ProjectiveSpace(3, QQ) sage: P(0,0,0,0) Traceback (most recent call last): ... ValueError: [0, 0, 0, 0] does not define a valid point since all entries are 0 :: sage: P.<x, y, z> = ProjectiveSpace(2, QQ) sage: X=P.subscheme([x^2-y*z]) sage: X([2,2,2]) (1 : 1 : 1) """ SchemeMorphism.__init__(self, X) if check: from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_field d = X.codomain().ambient_space().ngens() if is_SchemeMorphism(v) or isinstance(v, EllipticCurvePoint_field): v = list(v) elif v is infinity: v = [0] * (d) v[1] = 1 if not isinstance(v,(list,tuple)): raise TypeError("Argument v (= %s) must be a scheme point, list, or tuple."%str(v)) if len(v) != d and len(v) != d-1: raise TypeError("v (=%s) must have %s components"%(v, d)) R = X.value_ring() v = Sequence(v, R) if len(v) == d-1: # very common special case v.append(1) n = len(v) all_zero = True for i in range(n): last = n-1-i if v[last]: all_zero = False c = v[last] if c == R.one(): break for j in range(last): v[j] /= c v[last] = R.one() break if all_zero: raise ValueError("%s does not define a valid point since all entries are 0"%repr(v)) X.extended_codomain()._check_satisfies_equations(v) self._coords = v