示例#1
0
文件: morphism.py 项目: dagss/sage
    def __pow__(self, n, dummy=None):
        """
        Exponentiate an endomorphism.

        INPUT: 

        - ``n`` -- integer. The exponent.

        OUTPUT:

        A scheme morphism in the same endomorphism set as ``self``.

        EXAMPLES::

            sage: X = AffineSpace(QQ,2)
            sage: id = X.identity_morphism()
            sage: id^0
            Scheme endomorphism of Affine Space of dimension 2 over Rational Field
              Defn: Identity map
            sage: id^2
            Traceback (most recent call last):
            ...
            TypeError: unsupported operand type(s) for *: 
            'SchemeMorphism_id' and 'SchemeMorphism_id'
        """
        if not self.is_endomorphism():
            raise TypeError, "self must be an endomorphism."
        if n==0:
            return self.domain().identity_morphism()
        return generic_power(self, n)
示例#2
0
        def _pow_(self, n):
            """
            Return ``self`` to the `n^{th}` power.

            INPUT:

            - ``n`` -- a positive integer

            EXAMPLES::

                sage: S = Semigroups().example("leftzero")
                sage: x = S("x")
                sage: x^1, x^2, x^3, x^4, x^5
                ('x', 'x', 'x', 'x', 'x')
                sage: x^0
                Traceback (most recent call last):
                ...
                AssertionError

            TESTS::

                sage: x._pow_(17)
                'x'

            """
            assert n > 0
            return generic_power(self, n)
示例#3
0
文件: morphism.py 项目: Etn40ff/sage
    def __pow__(self, n, dummy=None):
        """
        Exponentiate an endomorphism.

        INPUT:

        - ``n`` -- integer. The exponent.

        OUTPUT:

        A composite map that belongs to the same endomorphism set as ``self``.

        EXAMPLES::

            sage: X = AffineSpace(QQ,2)
            sage: id = X.identity_morphism()
            sage: id^0
            Scheme endomorphism of Affine Space of dimension 2 over Rational Field
              Defn: Identity map
            sage: id^2
            Scheme endomorphism of Affine Space of dimension 2 over Rational Field
              Defn: Identity map
        """
        if not self.is_endomorphism():
            raise TypeError, "self must be an endomorphism."
        if n==0:
            return self.domain().identity_morphism()
        return generic_power(self, n)
    def __pow__(self, n):
        """
        returns self^n, where other is an integer.

        TESTS::

            sage: f = FreeGroupAutomorphism('a->ab,b->A')
            sage: f**-3
            Automorphism of the Free group over ['a', 'b']: a->bAB,b->baBAB
        """
        if n > 0:
            from sage.structure.element import generic_power
            return generic_power(self,n)
        elif n < 0:
            from sage.structure.element import generic_power
            return generic_power(self.inverse(), -n)
        else:
            return self.domain().identity_automorphism()
示例#5
0
        def __pow__(self, n):
            r"""
            INPUTS:
             - ``n``: a non negative integer

            Returns ``self`` to the `n^{th}` power.

            EXAMPLES::

                sage: S = Monoids().example()
                sage: x = S("aa")
                sage: x^0, x^1, x^2, x^3, x^4, x^5
                ('', 'aa', 'aaaa', 'aaaaaa', 'aaaaaaaa', 'aaaaaaaaaa')

            """
            if not n:  # FIXME: why do we need to do that?
                return self.parent().one()
            return generic_power(self, n, self.parent().one())
示例#6
0
        def __pow__(self, n):
            r"""
            INPUTS:
             - ``n``: a non negative integer

            Returns ``self`` to the `n^{th}` power.

            EXAMPLES::

                sage: S = Monoids().example()
                sage: x = S("aa")
                sage: x^0, x^1, x^2, x^3, x^4, x^5
                ('', 'aa', 'aaaa', 'aaaaaa', 'aaaaaaaa', 'aaaaaaaaaa')

            """
            if not n: # FIXME: why do we need to do that?
                return self.parent().one()
            return generic_power(self, n, self.parent().one())
示例#7
0
 def __pow__(self, n, dummy=None):
     if not self.is_endomorphism():
         raise TypeError, "self must be an endomorphism."
     # todo -- what about the case n=0 -- need to specify the identity map somehow.
     return generic_power(self, n)