def __init__(self, parent, polynomials, check=True): r""" See :class:`SchemeMorphism_polynomial_toric_variety` for documentation. TESTS:: sage: fan = FaceFan(lattice_polytope.octahedron(2)) sage: P1xP1 = ToricVariety(fan) sage: P1xP1.inject_variables() Defining z0, z1, z2, z3 sage: P1 = P1xP1.subscheme(z0-z2) sage: H = P1xP1.Hom(P1) sage: import sage.schemes.toric.morphism as MOR sage: MOR.SchemeMorphism_polynomial_toric_variety(H, [z0,z1,z0,z3]) Scheme morphism: From: 2-d toric variety covered by 4 affine patches To: Closed subscheme of 2-d toric variety covered by 4 affine patches defined by: z0 - z2 Defn: Defined on coordinates by sending [z0 : z1 : z2 : z3] to [z0 : z1 : z0 : z3] """ SchemeMorphism_polynomial.__init__(self, parent, polynomials, check) if check: # Check that defining polynomials are homogeneous (degrees can be # different if the target uses weighted coordinates) for p in self.defining_polynomials(): if not self.domain().ambient_space().is_homogeneous(p): raise ValueError("%s is not homogeneous!" % p)
def __init__(self, parent, polys, check=True): """ The Python constructor. See :class:`SchemeMorphism_polynomial` for details. EXAMPLES:: sage: P1.<x,y> = ProjectiveSpace(QQ,1) sage: H = P1.Hom(P1) sage: H([y,2*x]) Scheme endomorphism of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (y : 2*x) """ SchemeMorphism_polynomial.__init__(self, parent, polys, check) if check: # morphisms from projective space are always given by # homogeneous polynomials of the same degree try: d = polys[0].degree() except AttributeError: polys = [f.lift() for f in polys] if not all([f.is_homogeneous() for f in polys]): raise ValueError("polys (=%s) must be homogeneous"%polys) degs = [f.degree() for f in polys] if not all([d==degs[0] for d in degs[1:]]): raise ValueError("polys (=%s) must be of the same degree"%polys)
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: T.<x,y,z,w,u> = ProductProjectiveSpaces([2,1],QQ) sage: H = T.Hom(T) sage: H([x^2*u,y^2*w,z^2*u,w^2,u^2]) Scheme endomorphism of Product of projective spaces P^2 x P^1 over Rational Field Defn: Defined by sending (x : y : z , w : u) to (x^2*u : y^2*w : z^2*u , w^2 : u^2). :: sage: T.<x,y,z,w,u> = ProductProjectiveSpaces([2,1],QQ) sage: H = T.Hom(T) sage: H([x^2*u,y^2*w,z^2*u,w^2,u*z]) Traceback (most recent call last): ... TypeError: polys (=[x^2*u, y^2*w, z^2*u, w^2, z*u]) must be multi-homogeneous of the same degrees (by component) """ if check: #check multi-homogeneous #if self is a subscheme, we may need the lift of the polynomials try: polys[0].exponents() except AttributeError: polys = [f.lift() for f in polys] target = parent.codomain().ambient_space() from sage.schemes.product_projective.space import is_ProductProjectiveSpaces if is_ProductProjectiveSpaces(target): splitpolys = target._factors(polys) for m in range(len(splitpolys)): d = target._degree(splitpolys[m][0]) if not all(d == target._degree(f) for f in splitpolys[m]): raise TypeError( "polys (=%s) must be multi-homogeneous of the same degrees (by component)" % polys) else: #we are mapping into some other kind of space target._validate(polys) SchemeMorphism_polynomial.__init__(self, parent, polys, check)
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: T.<x,y,z,w,u> = ProductProjectiveSpaces([2,1],QQ) sage: H = T.Hom(T) sage: H([x^2*u,y^2*w,z^2*u,w^2,u^2]) Scheme endomorphism of Product of projective spaces P^2 x P^1 over Rational Field Defn: Defined by sending (x : y : z , w : u) to (x^2*u : y^2*w : z^2*u , w^2 : u^2). :: sage: T.<x,y,z,w,u> = ProductProjectiveSpaces([2,1],QQ) sage: H = T.Hom(T) sage: H([x^2*u,y^2*w,z^2*u,w^2,u*z]) Traceback (most recent call last): ... TypeError: polys (=[x^2*u, y^2*w, z^2*u, w^2, z*u]) must be multi-homogeneous of the same degrees (by component) """ if check: #check multi-homogeneous #if self is a subscheme, we may need the lift of the polynomials try: polys[0].exponents() except AttributeError: polys = [f.lift() for f in polys] target = parent.codomain().ambient_space() from sage.schemes.product_projective.space import is_ProductProjectiveSpaces if is_ProductProjectiveSpaces(target): splitpolys = target._factors(polys) for m in range(len(splitpolys)): d = target._degree(splitpolys[m][0]) if not all(d == target._degree(f) for f in splitpolys[m]): raise TypeError("polys (=%s) must be multi-homogeneous of the same degrees (by component)"%polys) else: #we are mapping into some other kind of space target._validate(polys) SchemeMorphism_polynomial.__init__(self, parent, polys, check)
def __init__(self, polys_or_rat_fncts, domain): r""" The Python constructor. EXAMPLES:: sage: from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem sage: P.<x,y> = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([x^2+y^2, y^2]) sage: isinstance(f, DynamicalSystem) True """ H = End(domain) # All consistency checks are done by the public class constructors, # so we can set check=False here. SchemeMorphism_polynomial.__init__(self, H, polys_or_rat_fncts, check=False)
def __init__(self, parent, polys, check=True): r""" The Python constructor. See :class:`SchemeMorphism_polynomial` for details. INPUT: - ``parent`` -- Hom. - ``polys`` -- list or tuple of polynomial or rational functions. - ``check`` -- Boolean. OUTPUT: - :class:`SchemeMorphism_polynomial_affine_space`. EXAMPLES:: sage: A.<x,y> = AffineSpace(ZZ, 2) sage: H = Hom(A, A) sage: H([3/5*x^2, y^2/(2*x^2)]) Traceback (most recent call last): ... TypeError: polys (=[3/5*x^2, y^2/(2*x^2)]) must be rational functions in Multivariate Polynomial Ring in x, y over Integer Ring :: sage: A.<x,y> = AffineSpace(ZZ, 2) sage: H = Hom(A, A) sage: H([3*x^2/(5*y), y^2/(2*x^2)]) Scheme endomorphism of Affine Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x, y) to (3*x^2/(5*y), y^2/(2*x^2)) :: sage: A.<x,y> = AffineSpace(QQ, 2) sage: H = Hom(A, A) sage: H([3/2*x^2, y^2]) Scheme endomorphism of Affine Space of dimension 2 over Rational Field Defn: Defined on coordinates by sending (x, y) to (3/2*x^2, y^2) :: sage: A.<x,y> = AffineSpace(QQ, 2) sage: X = A.subscheme([x-y^2]) sage: H = Hom(X, X) sage: H([9/4*x^2, 3/2*y]) Scheme endomorphism of Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -y^2 + x Defn: Defined on coordinates by sending (x, y) to (9/4*x^2, 3/2*y) sage: P.<x,y,z> = ProjectiveSpace(ZZ, 2) sage: H = Hom(P, P) sage: f = H([5*x^3 + 3*x*y^2-y^3, 3*z^3 + y*x^2, x^3-z^3]) sage: f.dehomogenize(2) Scheme endomorphism of Affine Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x0, x1) to ((5*x0^3 + 3*x0*x1^2 - x1^3)/(x0^3 - 1), (x0^2*x1 + 3)/(x0^3 - 1)) If you pass in quotient ring elements, they are reduced:: sage: A.<x,y,z> = AffineSpace(QQ, 3) sage: X = A.subscheme([x-y]) sage: H = Hom(X,X) sage: u,v,w = X.coordinate_ring().gens() sage: H([u, v, u+v]) Scheme endomorphism of Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: x - y Defn: Defined on coordinates by sending (x, y, z) to (y, y, 2*y) You must use the ambient space variables to create rational functions:: sage: A.<x,y,z> = AffineSpace(QQ, 3) sage: X = A.subscheme([x^2-y^2]) sage: H = Hom(X,X) sage: u,v,w = X.coordinate_ring().gens() sage: H([u, v, (u+1)/v]) Traceback (most recent call last): ... ArithmeticError: Division failed. The numerator is not a multiple of the denominator. sage: H([x, y, (x+1)/y]) Scheme endomorphism of Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: x^2 - y^2 Defn: Defined on coordinates by sending (x, y, z) to (x, y, (x + 1)/y) :: sage: R.<t> = PolynomialRing(QQ) sage: A.<x,y,z> = AffineSpace(R, 3) sage: X = A.subscheme(x^2-y^2) sage: H = End(X) sage: H([x^2/(t*y), t*y^2, x*z]) Scheme endomorphism of Closed subscheme of Affine Space of dimension 3 over Univariate Polynomial Ring in t over Rational Field defined by: x^2 - y^2 Defn: Defined on coordinates by sending (x, y, z) to (x^2/(t*y), t*y^2, x*z) """ if check: if not isinstance(polys, (list, tuple)): raise TypeError("polys (=%s) must be a list or tuple" % polys) source_ring = parent.domain().ambient_space().coordinate_ring() target = parent.codomain().ambient_space() if len(polys) != target.ngens(): raise ValueError("there must be %s polynomials" % target.ngens()) try: polys = [source_ring(poly) for poly in polys] except TypeError: #maybe given quotient ring elements try: polys = [source_ring(poly.lift()) for poly in polys] except (TypeError, AttributeError): #must be a rational function since we cannot have #rational functions for quotient rings try: if not all(p.base_ring() == source_ring.base_ring() for p in polys): raise TypeError( "polys (=%s) must be rational functions in %s" % (polys, source_ring)) polys = [ source_ring(poly.numerator()) / source_ring(poly.denominator()) for poly in polys ] except TypeError: #can't seem to coerce raise TypeError( "polys (=%s) must be rational functions in %s" % (polys, source_ring)) self._is_prime_finite_field = is_PrimeFiniteField( polys[0].base_ring()) # Needed for _fast_eval and _fastpolys SchemeMorphism_polynomial.__init__(self, parent, polys, False)
def __init__(self, parent, polys, check=True): r""" The Python constructor. See :class:`SchemeMorphism_polynomial` for details. INPUT: - ``parent`` -- Hom - ``polys`` -- list or tuple of polynomial or rational functions - ``check`` -- Boolean OUTPUT: - :class:`SchemeMorphism_polynomial_affine_space` EXAMPLES:: sage: A.<x,y>=AffineSpace(ZZ,2) sage: H=Hom(A,A) sage: H([3/5*x^2,y^2/(2*x^2)]) Traceback (most recent call last): ... TypeError: polys (=[3/5*x^2, y^2/(2*x^2)]) must be rational functions in Multivariate Polynomial Ring in x, y over Integer Ring :: sage: A.<x,y>=AffineSpace(ZZ,2) sage: H=Hom(A,A) sage: H([3*x^2/(5*y),y^2/(2*x^2)]) Scheme endomorphism of Affine Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x, y) to (3*x^2/(5*y), y^2/(2*x^2)) sage: A.<x,y>=AffineSpace(QQ,2) sage: H=Hom(A,A) sage: H([3/2*x^2,y^2]) Scheme endomorphism of Affine Space of dimension 2 over Rational Field Defn: Defined on coordinates by sending (x, y) to (3/2*x^2, y^2) sage: A.<x,y>=AffineSpace(QQ,2) sage: X=A.subscheme([x-y^2]) sage: H=Hom(X,X) sage: H([9/4*x^2,3/2*y]) Scheme endomorphism of Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -y^2 + x Defn: Defined on coordinates by sending (x, y) to (9/4*x^2, 3/2*y) sage: P.<x,y,z>=ProjectiveSpace(ZZ,2) sage: H=Hom(P,P) sage: f=H([5*x^3 + 3*x*y^2-y^3,3*z^3 + y*x^2, x^3-z^3]) sage: f.dehomogenize(2) Scheme endomorphism of Affine Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x0, x1) to ((5*x0^3 + 3*x0*x1^2 - x1^3)/(x0^3 - 1), (x0^2*x1 + 3)/(x0^3 - 1)) """ if check: if not isinstance(polys, (list, tuple)): raise TypeError("polys (=%s) must be a list or tuple" % polys) source_ring = parent.domain().ambient_space().coordinate_ring() target = parent.codomain().ambient_space() if len(polys) != target.ngens(): raise ValueError("there must be %s polynomials" % target.ngens()) try: polys = [source_ring(poly) for poly in polys] except TypeError: if all(p.base_ring() == source_ring.base_ring() for p in polys) == False: raise TypeError( "polys (=%s) must be rational functions in %s" % (polys, source_ring)) try: polys = [ source_ring(poly.numerator()) / source_ring(poly.denominator()) for poly in polys ] except TypeError: raise TypeError( "polys (=%s) must be rational functions in %s" % (polys, source_ring)) if isinstance(source_ring, QuotientRing_generic): polys = [f.lift() for f in polys] self._is_prime_finite_field = is_PrimeFiniteField( polys[0].base_ring()) # Needed for _fast_eval and _fastpolys SchemeMorphism_polynomial.__init__(self, parent, polys, False)
def __init__(self, parent, polys, check=True): r""" The Python constructor. See :class:`SchemeMorphism_polynomial` for details. INPUT: - ``parent`` -- Hom - ``polys`` -- list or tuple of polynomial or rational functions - ``check`` -- Boolean OUTPUT: - :class:`SchemeMorphism_polynomial_affine_space` EXAMPLES:: sage: A.<x,y>=AffineSpace(ZZ,2) sage: H=Hom(A,A) sage: H([3/5*x^2,y^2/(2*x^2)]) Traceback (most recent call last): ... TypeError: polys (=[3/5*x^2, y^2/(2*x^2)]) must be rational functions in Multivariate Polynomial Ring in x, y over Integer Ring :: sage: A.<x,y>=AffineSpace(ZZ,2) sage: H=Hom(A,A) sage: H([3*x^2/(5*y),y^2/(2*x^2)]) Scheme endomorphism of Affine Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x, y) to (3*x^2/(5*y), y^2/(2*x^2)) sage: A.<x,y>=AffineSpace(QQ,2) sage: H=Hom(A,A) sage: H([3/2*x^2,y^2]) Scheme endomorphism of Affine Space of dimension 2 over Rational Field Defn: Defined on coordinates by sending (x, y) to (3/2*x^2, y^2) sage: A.<x,y>=AffineSpace(QQ,2) sage: X=A.subscheme([x-y^2]) sage: H=Hom(X,X) sage: H([9/4*x^2,3/2*y]) Scheme endomorphism of Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -y^2 + x Defn: Defined on coordinates by sending (x, y) to (9/4*x^2, 3/2*y) sage: P.<x,y,z>=ProjectiveSpace(ZZ,2) sage: H=Hom(P,P) sage: f=H([5*x^3 + 3*x*y^2-y^3,3*z^3 + y*x^2, x^3-z^3]) sage: f.dehomogenize(2) Scheme endomorphism of Affine Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x0, x1) to ((5*x0^3 + 3*x0*x1^2 - x1^3)/(x0^3 - 1), (x0^2*x1 + 3)/(x0^3 - 1)) """ if check: if not isinstance(polys, (list, tuple)): raise TypeError("polys (=%s) must be a list or tuple"%polys) source_ring =parent.domain().ambient_space().coordinate_ring() target = parent.codomain().ambient_space() if len(polys) != target.ngens(): raise ValueError("there must be %s polynomials"%target.ngens()) try: polys = [source_ring(poly) for poly in polys] except TypeError: if all(p.base_ring()==source_ring.base_ring() for p in polys)==False: raise TypeError("polys (=%s) must be rational functions in %s"%(polys,source_ring)) try: polys = [source_ring(poly.numerator())/source_ring(poly.denominator()) for poly in polys] except TypeError: raise TypeError("polys (=%s) must be rational functions in %s"%(polys,source_ring)) if isinstance(source_ring, QuotientRing_generic): polys = [f.lift() for f in polys] SchemeMorphism_polynomial.__init__(self, parent,polys, False)
def __init__(self, parent, polys, check=True): r""" The Python constructor. See :class:`SchemeMorphism_polynomial` for details. INPUT: - ``parent`` -- Hom. - ``polys`` -- list or tuple of polynomial or rational functions. - ``check`` -- Boolean. OUTPUT: - :class:`SchemeMorphism_polynomial_affine_space`. EXAMPLES:: sage: A.<x,y> = AffineSpace(ZZ, 2) sage: H = Hom(A, A) sage: H([3/5*x^2, y^2/(2*x^2)]) Scheme endomorphism of Affine Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x, y) to (3*x^2/5, y^2/(2*x^2)) :: sage: A.<x,y> = AffineSpace(ZZ, 2) sage: H = Hom(A, A) sage: H([3*x^2/(5*y), y^2/(2*x^2)]) Scheme endomorphism of Affine Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x, y) to (3*x^2/(5*y), y^2/(2*x^2)) :: sage: A.<x,y> = AffineSpace(QQ, 2) sage: H = Hom(A, A) sage: H([3/2*x^2, y^2]) Scheme endomorphism of Affine Space of dimension 2 over Rational Field Defn: Defined on coordinates by sending (x, y) to (3/2*x^2, y^2) :: sage: A.<x,y> = AffineSpace(QQ, 2) sage: X = A.subscheme([x-y^2]) sage: H = Hom(X, X) sage: H([9/4*x^2, 3/2*y]) Scheme endomorphism of Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -y^2 + x Defn: Defined on coordinates by sending (x, y) to (9/4*x^2, 3/2*y) sage: P.<x,y,z> = ProjectiveSpace(ZZ, 2) sage: H = Hom(P, P) sage: f = H([5*x^3 + 3*x*y^2-y^3, 3*z^3 + y*x^2, x^3-z^3]) sage: f.dehomogenize(2) Scheme endomorphism of Affine Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x0, x1) to ((5*x0^3 + 3*x0*x1^2 - x1^3)/(x0^3 - 1), (x0^2*x1 + 3)/(x0^3 - 1)) If you pass in quotient ring elements, they are reduced:: sage: A.<x,y,z> = AffineSpace(QQ, 3) sage: X = A.subscheme([x-y]) sage: H = Hom(X,X) sage: u,v,w = X.coordinate_ring().gens() sage: H([u, v, u+v]) Scheme endomorphism of Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: x - y Defn: Defined on coordinates by sending (x, y, z) to (y, y, 2*y) You must use the ambient space variables to create rational functions:: sage: A.<x,y,z> = AffineSpace(QQ, 3) sage: X = A.subscheme([x^2-y^2]) sage: H = Hom(X,X) sage: u,v,w = X.coordinate_ring().gens() sage: H([u, v, (u+1)/v]) Traceback (most recent call last): ... ArithmeticError: Division failed. The numerator is not a multiple of the denominator. sage: H([x, y, (x+1)/y]) Scheme endomorphism of Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: x^2 - y^2 Defn: Defined on coordinates by sending (x, y, z) to (x, y, (x + 1)/y) :: sage: R.<t> = PolynomialRing(QQ) sage: A.<x,y,z> = AffineSpace(R, 3) sage: X = A.subscheme(x^2-y^2) sage: H = End(X) sage: H([x^2/(t*y), t*y^2, x*z]) Scheme endomorphism of Closed subscheme of Affine Space of dimension 3 over Univariate Polynomial Ring in t over Rational Field defined by: x^2 - y^2 Defn: Defined on coordinates by sending (x, y, z) to (x^2/(t*y), t*y^2, x*z) """ if check: if not isinstance(polys, (list, tuple)): raise TypeError("polys (=%s) must be a list or tuple"%polys) source_ring = parent.domain().ambient_space().coordinate_ring() target = parent.codomain().ambient_space() if len(polys) != target.ngens(): raise ValueError("there must be %s polynomials"%target.ngens()) try: polys = [source_ring(poly) for poly in polys] except TypeError: #maybe given quotient ring elements try: polys = [source_ring(poly.lift()) for poly in polys] except (TypeError, AttributeError): #must be a rational function since we cannot have #rational functions for quotient rings try: if not all(p.base_ring().fraction_field()==source_ring.base_ring().fraction_field() for p in polys): raise TypeError("polys (=%s) must be rational functions in %s"%(polys, source_ring)) K = FractionField(source_ring) polys = [K(p) for p in polys] #polys = [source_ring(poly.numerator())/source_ring(poly.denominator()) for poly in polys] except TypeError: #can't seem to coerce raise TypeError("polys (=%s) must be rational functions in %s"%(polys, source_ring)) self._is_prime_finite_field = is_PrimeFiniteField(polys[0].base_ring()) # Needed for _fast_eval and _fastpolys SchemeMorphism_polynomial.__init__(self, parent, polys, False)