Ticket #14353: trac_14353_auxiliary_methods.patch

File trac_14353_auxiliary_methods.patch, 3.2 KB (added by novoselt, 9 years ago)

Made from Volker's patch

  • sage/schemes/toric/homset.py

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1364372448 -3600
    # Node ID 8bb4a76722f0f8ede78e8d6545ceb9f12ef7197e
    # Parent c12b42ee9273e065e45b60b05ade4bb10927ac22
    Factor a toric morphism into a surjective and generically injective morphism
    
    diff --git a/sage/schemes/toric/homset.py b/sage/schemes/toric/homset.py
    a b  
    231231        raise TypeError, "x must be a fan morphism or a list/tuple of polynomials"
    232232
    233233
     234    def _an_element_(self):
     235        """
     236        Construct a sample morphism.
     237
     238        OUTPUT:
     239
     240        An element of the homset.
     241
     242        EXAMPLES::
     243
     244            sage: P2 = toric_varieties.P2()
     245            sage: homset = P2.Hom(P2)
     246            sage: homset.an_element()   # indirect doctest
     247            Scheme endomorphism of 2-d CPR-Fano toric variety covered by 3 affine patches
     248              Defn: Defined by sending Rational polyhedral fan in 2-d lattice N to
     249                    Rational polyhedral fan in 2-d lattice N.
     250        """
     251        from sage.matrix.constructor import zero_matrix
     252        zero = zero_matrix(self.domain().dimension_relative(),
     253                           self.codomain().dimension_relative())
     254        return self(zero)
     255
    234256class SchemeHomset_points_toric_field(SchemeHomset_points):
    235257    """
    236258    Set of rational points of a toric variety.
  • sage/schemes/toric/morphism.py

    diff --git a/sage/schemes/toric/morphism.py b/sage/schemes/toric/morphism.py
    a b  
    515515                polys[i] *= x**d
    516516        return SchemeMorphism_polynomial_toric_variety(self.parent(), polys)
    517517
     518    def is_injective(self):
     519        r"""
     520        Check if ``self`` is injective.
     521       
     522        See
     523        :meth:`~sage.geometry.fan_morphism.FanMorphism.is_injective`
     524        for a description of the toric algorithm.
     525               
     526        OUTPUT:
     527       
     528        Boolean. Whether ``self`` is injective.
     529
     530        EXAMPLES::
     531       
     532            sage: X = toric_varieties.A(2)
     533            sage: m = identity_matrix(2)
     534            sage: f = X.hom(m, X)
     535            sage: f.is_injective()
     536            True
     537           
     538            sage: Y = ToricVariety(Fan([Cone([(1,0), (1,1)])]))
     539            sage: f = Y.hom(m, X)
     540            sage: f.is_injective()
     541            False
     542        """       
     543        return self.fan_morphism().is_injective()
     544       
     545    def is_surjective(self):
     546        r"""
     547        Check if ``self`` is surjective.
     548       
     549        See
     550        :meth:`~sage.geometry.fan_morphism.FanMorphism.is_surjective`
     551        for a description of the toric algorithm.
     552               
     553        OUTPUT:
     554       
     555        Boolean. Whether ``self`` is surjective.
     556
     557        EXAMPLES::
     558       
     559            sage: X = toric_varieties.A(2)
     560            sage: m = identity_matrix(2)
     561            sage: f = X.hom(m, X)
     562            sage: f.is_surjective()
     563            True
     564           
     565            sage: Y = ToricVariety(Fan([Cone([(1,0), (1,1)])]))
     566            sage: f = Y.hom(m, X)
     567            sage: f.is_surjective()
     568            False
     569        """       
     570        return self.fan_morphism().is_surjective()