def find_isomorphism(fan1, fan2, check=False): """ Find an isomorphism of the two fans. INPUT: - ``fan1``, ``fan2`` -- two fans. - ``check`` -- boolean (default: False). Passed to the fan morphism constructor, see :func:`~sage.geometry.fan_morphism.FanMorphism`. OUTPUT: A fan isomorphism. If the fans are not isomorphic, a :class:`FanNotIsomorphicError` is raised. EXAMPLE:: sage: rays = ((1, 1), (0, 1), (-1, -1), (3, 1)) sage: cones = [(0,1), (1,2), (2,3), (3,0)] sage: fan1 = Fan(cones, rays) sage: m = matrix([[-2,3],[1,-1]]) sage: m.det() == -1 True sage: fan2 = Fan(cones, [vector(r)*m for r in rays]) sage: from sage.geometry.fan_isomorphism import find_isomorphism sage: find_isomorphism(fan1, fan2, check=True) Fan morphism defined by the matrix [-2 3] [ 1 -1] Domain fan: Rational polyhedral fan in 2-d lattice N Codomain fan: Rational polyhedral fan in 2-d lattice N sage: find_isomorphism(fan1, toric_varieties.P2().fan()) Traceback (most recent call last): ... FanNotIsomorphicError sage: fan1 = Fan(cones=[[1,3,4,5],[0,1,2,3],[2,3,4],[0,1,5]], ... rays=[(-1,-1,0),(-1,-1,3),(-1,1,-1),(-1,3,-1),(0,2,-1),(1,-1,1)]) sage: fan2 = Fan(cones=[[0,2,3,5],[0,1,4,5],[0,1,2],[3,4,5]], ... rays=[(-1,-1,-1),(-1,-1,0),(-1,1,-1),(0,2,-1),(1,-1,1),(3,-1,-1)]) sage: fan1.is_isomorphic(fan2) True """ generator = fan_isomorphism_generator(fan1, fan2) try: m = next(generator) except StopIteration: raise FanNotIsomorphicError from sage.geometry.fan_morphism import FanMorphism return FanMorphism(m, domain_fan=fan1, codomain=fan2, check=check)
def _element_constructor_(self, x, check=True): """ Construct a scheme morphism. INPUT: - `x` -- anything that defines a morphism of toric varieties. A matrix, fan morphism, or a list or tuple of homogeneous polynomials that define a morphism. - ``check`` -- boolean (default: ``True``) passed onto functions called by this to be more careful about input argument type checking OUTPUT: The morphism of toric varieties determined by ``x``. EXAMPLES: First, construct from fan morphism:: sage: dP8.<t,x0,x1,x2> = toric_varieties.dP8() sage: P2.<y0,y1,y2> = toric_varieties.P2() sage: hom_set = dP8.Hom(P2) sage: fm = FanMorphism(identity_matrix(2), dP8.fan(), P2.fan()) sage: hom_set(fm) # calls hom_set._element_constructor_() Scheme morphism: From: 2-d CPR-Fano toric variety covered by 4 affine patches To: 2-d CPR-Fano toric variety covered by 3 affine patches Defn: Defined by sending Rational polyhedral fan in 2-d lattice N to Rational polyhedral fan in 2-d lattice N. A matrix will automatically be converted to a fan morphism:: sage: hom_set(identity_matrix(2)) Scheme morphism: From: 2-d CPR-Fano toric variety covered by 4 affine patches To: 2-d CPR-Fano toric variety covered by 3 affine patches Defn: Defined by sending Rational polyhedral fan in 2-d lattice N to Rational polyhedral fan in 2-d lattice N. Alternatively, one can use homogeneous polynomials to define morphisms:: sage: P2.inject_variables() Defining y0, y1, y2 sage: dP8.inject_variables() Defining t, x0, x1, x2 sage: hom_set([x0,x1,x2]) Scheme morphism: From: 2-d CPR-Fano toric variety covered by 4 affine patches To: 2-d CPR-Fano toric variety covered by 3 affine patches Defn: Defined on coordinates by sending [t : x0 : x1 : x2] to [x0 : x1 : x2] A morphism of the coordinate ring will also work:: sage: ring_hom = P2.coordinate_ring().hom([x0,x1,x2], dP8.coordinate_ring()) sage: ring_hom Ring morphism: From: Multivariate Polynomial Ring in y0, y1, y2 over Rational Field To: Multivariate Polynomial Ring in t, x0, x1, x2 over Rational Field Defn: y0 |--> x0 y1 |--> x1 y2 |--> x2 sage: hom_set(ring_hom) Scheme morphism: From: 2-d CPR-Fano toric variety covered by 4 affine patches To: 2-d CPR-Fano toric variety covered by 3 affine patches Defn: Defined on coordinates by sending [t : x0 : x1 : x2] to [x0 : x1 : x2] """ from sage.schemes.toric.morphism import SchemeMorphism_polynomial_toric_variety if isinstance(x, (list, tuple)): return SchemeMorphism_polynomial_toric_variety(self, x, check=check) from sage.categories.map import Map from sage.categories.all import Rings if isinstance(x, Map) and x.category_for().is_subcategory(Rings()): # x is a morphism of Rings assert x.domain() is self.codomain().coordinate_ring() assert x.codomain() is self.domain().coordinate_ring() return SchemeMorphism_polynomial_toric_variety(self, x.im_gens(), check=check) if is_Matrix(x): x = FanMorphism(x, self.domain().fan(), self.codomain().fan()) if isinstance(x, FanMorphism): if x.is_dominant(): from sage.schemes.toric.morphism import SchemeMorphism_fan_toric_variety_dominant return SchemeMorphism_fan_toric_variety_dominant(self, x, check=check) else: from sage.schemes.toric.morphism import SchemeMorphism_fan_toric_variety return SchemeMorphism_fan_toric_variety(self, x, check=check) raise TypeError( "x must be a fan morphism or a list/tuple of polynomials")
def _element_constructor_(self, x, check=True): """ Construct a scheme morphism. INPUT: - `x` -- anything that defines a morphism of toric varieties. A matrix, fan morphism, or a list or tuple of homogeneous polynomials that define a morphism. - ``check`` -- boolean (default: ``True``) passed onto functions called by this to be more careful about input argument type checking OUTPUT: The morphism of toric varieties determined by ``x``. EXAMPLES: First, construct from fan morphism:: sage: dP8.<t,x0,x1,x2> = toric_varieties.dP8() sage: P2.<y0,y1,y2> = toric_varieties.P2() sage: hom_set = dP8.Hom(P2) sage: fm = FanMorphism(identity_matrix(2), dP8.fan(), P2.fan()) sage: hom_set(fm) # calls hom_set._element_constructor_() Scheme morphism: From: 2-d CPR-Fano toric variety covered by 4 affine patches To: 2-d CPR-Fano toric variety covered by 3 affine patches Defn: Defined by sending Rational polyhedral fan in 2-d lattice N to Rational polyhedral fan in 2-d lattice N. A matrix will automatically be converted to a fan morphism:: sage: hom_set(identity_matrix(2)) Scheme morphism: From: 2-d CPR-Fano toric variety covered by 4 affine patches To: 2-d CPR-Fano toric variety covered by 3 affine patches Defn: Defined by sending Rational polyhedral fan in 2-d lattice N to Rational polyhedral fan in 2-d lattice N. Alternatively, one can use homogeneous polynomials to define morphisms:: sage: P2.inject_variables() Defining y0, y1, y2 sage: dP8.inject_variables() Defining t, x0, x1, x2 sage: hom_set([x0,x1,x2]) Scheme morphism: From: 2-d CPR-Fano toric variety covered by 4 affine patches To: 2-d CPR-Fano toric variety covered by 3 affine patches Defn: Defined on coordinates by sending [t : x0 : x1 : x2] to [x0 : x1 : x2] A morphism of the coordinate ring will also work:: sage: ring_hom = P2.coordinate_ring().hom([x0,x1,x2], dP8.coordinate_ring()) sage: ring_hom Ring morphism: From: Multivariate Polynomial Ring in y0, y1, y2 over Rational Field To: Multivariate Polynomial Ring in t, x0, x1, x2 over Rational Field Defn: y0 |--> x0 y1 |--> x1 y2 |--> x2 sage: hom_set(ring_hom) Scheme morphism: From: 2-d CPR-Fano toric variety covered by 4 affine patches To: 2-d CPR-Fano toric variety covered by 3 affine patches Defn: Defined on coordinates by sending [t : x0 : x1 : x2] to [x0 : x1 : x2] """ from sage.schemes.toric.morphism import SchemeMorphism_polynomial_toric_variety if isinstance(x, (list, tuple)): return SchemeMorphism_polynomial_toric_variety(self, x, check=check) if is_RingHomomorphism(x): assert x.domain() is self.codomain().coordinate_ring() assert x.codomain() is self.domain().coordinate_ring() return SchemeMorphism_polynomial_toric_variety(self, x.im_gens(), check=check) if is_Matrix(x): x = FanMorphism(x, self.domain().fan(), self.codomain().fan()) if isinstance(x, FanMorphism): if x.is_dominant(): from sage.schemes.toric.morphism import SchemeMorphism_fan_toric_variety_dominant return SchemeMorphism_fan_toric_variety_dominant(self, x, check=check) else: from sage.schemes.toric.morphism import SchemeMorphism_fan_toric_variety return SchemeMorphism_fan_toric_variety(self, x, check=check) raise TypeError("x must be a fan morphism or a list/tuple of polynomials")