Пример #1
0
    def identity(self):
        """
        The identity map of this homset.

        .. NOTE::

            Of course, this only exists for sets of endomorphisms.

        EXAMPLES::

            sage: H = Hom(QQ,QQ)
            sage: H.identity()
            Identity endomorphism of Rational Field
            sage: H = Hom(ZZ,QQ)
            sage: H.identity()
            Traceback (most recent call last):
            ...
            TypeError: Identity map only defined for endomorphisms. Try natural_map() instead.
            sage: H.natural_map()
            Ring Coercion morphism:
              From: Integer Ring
              To:   Rational Field

        """
        if self.is_endomorphism_set():
            return morphism.IdentityMorphism(self)
        else:
            raise TypeError, "Identity map only defined for endomorphisms. Try natural_map() instead."
Пример #2
0
 def identity(self):
     if self.is_endomorphism_set():
         return morphism.IdentityMorphism(self)
     else:
         raise TypeError, "Identity map only defined for endomorphisms. Try natural_map() instead."