def __init__(self, X, coordinates, check=True): r""" See :class:`SchemeMorphism_toric_coordinates_field` for documentation. TESTS:: sage: fan = FaceFan(lattice_polytope.octahedron(2)) sage: P1xP1 = ToricVariety(fan) sage: P1xP1(1,2,3,4) [1 : 2 : 3 : 4] """ # Convert scheme to its set of points over the base ring if scheme.is_Scheme(X): X = X(X.base_ring()) super(SchemeMorphism_toric_coordinates_field, self).__init__(X) if check: # Verify that there are the right number of coords # Why is it not done in the parent? if is_SchemeMorphism(coordinates): coordinates = list(coordinates) if not isinstance(coordinates, (list, tuple)): raise TypeError("coordinates must be a scheme point, list, " "or tuple. Got %s" % coordinates) d = X.codomain().ambient_space().ngens() if len(coordinates) != d: raise ValueError("there must be %d coordinates! Got only %d: " "%s" % (d, len(coordinates), coordinates)) # Make sure the coordinates all lie in the appropriate ring coordinates = Sequence(coordinates, X.value_ring()) # Verify that the point satisfies the equations of X. X.codomain()._check_satisfies_equations(coordinates) self._coords = coordinates
def __init__(self, X, v, check=True): if scheme.is_Scheme(X): X = X(X.base_ring()) SchemeMorphism.__init__(self, X) if check: # Verify that there are the right number of coords d = X.codomain().ambient_space().ngens() if len(v) != d: raise TypeError, \ "Argument v (=%s) must have %s coordinates."%(v, d) if is_SchemeMorphism(v): v = list(v) 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.codomain()._check_satisfies_equations(v) self._coords = v
def __init__(self, X, v, check=True): if scheme.is_Scheme(X): X = X(X.base_ring()) SchemeMorphism.__init__(self, X) if check: from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_field # TODO: fix circular ref. 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) #v = Sequence(v, X.base_ring()) v = Sequence(v, X.value_ring()) if len(v) == d-1: # very common special case v.append(1) n = len(v) all_zero = True for i in range(n): if v[n-1-i]: all_zero = False c = v[n-1-i] if c == 1: break for j in range(n-i): v[j] /= c break if all_zero: raise ValueError, "%s does not define a valid point since all entries are 0"%repr(v) X.codomain()._check_satisfies_equations(v) self._coords = v