Ticket #14353: trac_14353_toric_morphism_composition.patch

File trac_14353_toric_morphism_composition.patch, 4.0 KB (added by vbraun, 9 years ago)

Initial patch

  • sage/schemes/toric/morphism.py

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1371694409 25200
    #      Wed Jun 19 19:13:29 2013 -0700
    # Node ID fc05ca1d7d6c9b1073a79fa0a263adccb87fe7e5
    # Parent  adaade0c9cc104e93bcfd035736cda27bed224aa
    Use the morphism framework for composition of toric morphisms
    
    diff --git a/sage/schemes/toric/morphism.py b/sage/schemes/toric/morphism.py
    a b  
    161161#                  http://www.gnu.org/licenses/
    162162#*****************************************************************************
    163163
     164# For now, the scheme morphism base class cannot derive from Morphism
     165# since this would clash with elliptic curves. So we derive only on
     166# the toric varieties level from Morphism. See
     167# https://groups.google.com/d/msg/sage-devel/qF4yU6Vdmao/wQlNrneSmWAJ
     168from sage.categories.morphism import Morphism
     169
    164170from sage.structure.sequence  import Sequence
    165171from sage.rings.all import ZZ
    166172
     
    174180
    175181############################################################################
    176182# A points on a toric variety determined by homogeneous coordinates.
    177 class SchemeMorphism_point_toric_field(SchemeMorphism_point):
     183class SchemeMorphism_point_toric_field(SchemeMorphism_point, Morphism):
    178184    """
    179185    A point of a toric variety determined by homogeneous coordinates
    180186    in a field.
     
    245251
    246252############################################################################
    247253# A morphism of toric varieties determined by homogeneous polynomials.
    248 class SchemeMorphism_polynomial_toric_variety(SchemeMorphism_polynomial):
     254class SchemeMorphism_polynomial_toric_variety(SchemeMorphism_polynomial, Morphism):
    249255    """
    250256    A morphism determined by homogeneous polynomials.
    251257
     
    341347       
    342348############################################################################
    343349# A morphism of toric varieties determined by a fan morphism
    344 class SchemeMorphism_fan_toric_variety(SchemeMorphism):
     350class SchemeMorphism_fan_toric_variety(SchemeMorphism, Morphism):
    345351    """
    346352    Construct a morphism determined by a fan morphism
    347353
     
    462468        else:
    463469            return cmp(type(self), type(right))
    464470
    465     def __imul__(self, right):
     471    def _composition_(self, right, homset):
    466472        """
    467473        Return the composition of ``self`` and ``right``.
    468474       
     
    480486            sage: P3 = toric_varieties.P(3)
    481487            sage: m = matrix([(2,0,0), (1,1,0)])
    482488            sage: phi = A2.hom(m, P3)
    483             sage: phi
     489            sage: phi1, phi2, phi3 = phi.factor()
     490            sage: phi1 * phi2
    484491            Scheme morphism:
    485492              From: 2-d affine toric variety
    486493              To:   3-d CPR-Fano toric variety covered by 4 affine patches
    487               Defn: Defined by sending Rational polyhedral fan in 2-d lattice N to
    488                     Rational polyhedral fan in 3-d lattice N.
    489             sage: prod(phi.factor()) # indirect test
    490             Scheme morphism:
    491               From: 2-d affine toric variety
    492               To:   3-d CPR-Fano toric variety covered by 4 affine patches
    493               Defn: Defined by sending Rational polyhedral fan in 2-d lattice N to
    494                     Rational polyhedral fan in 3-d lattice N.
     494              Defn: Defined by sending Rational polyhedral fan in Sublattice
     495                    <N(1, 0, 0), N(0, 1, 0)> to Rational polyhedral fan in 3-d lattice N.
     496            sage: phi1 * phi2 * phi3 == phi
     497            True
    495498        """
    496         if not isinstance(right, SchemeMorphism_fan_toric_variety):
    497             raise NotImplementedError("only composing toric morphisms based on "
    498                                 "fan morphisms is implemented at the moment")
    499499        f = self.fan_morphism() * right.fan_morphism()
    500         return right.domain().hom(f, self.codomain())
    501 
     500        return homset(f, self.codomain())
     501       
    502502    def _repr_defn(self):
    503503        """
    504504        Return a string representation of the definition of ``self``.