Changeset 6221:125ab3b64c6a


Ignore:
Timestamp:
09/06/07 17:59:51 (6 years ago)
Author:
Tom Boothby <boothby@…>
Branch:
default
Message:

Further work on #503.

Location:
sage
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sage/categories/morphism.pyx

    r5480 r6221  
    2929include "../ext/stdsage.pxi" 
    3030from sage.structure.element cimport Element 
     31from sage.structure.element import generic_power 
    3132 
    3233def make_morphism(_class, parent, _dict, _slots): 
     
    144145            raise TypeError, "self must be an endomorphism." 
    145146        # todo -- what about the case n=0 -- need to specify the identity map somehow. 
    146         import sage.rings.arith as arith 
    147         return arith.generic_power(self, n) 
     147        return generic_power(self, n) 
    148148 
    149149cdef class FormalCoercionMorphism(Morphism): 
  • sage/rings/power_series_mpoly.pyx

    r5862 r6221  
    161161        return PowerSeries_mpoly(self._parent, self.__f._lmul_c(c), self._prec, check=False) 
    162162 
    163     def __pow__(self_t, r, dummy):  # TODO -- too much code duplication with power_series_poly.pyx? 
    164         cdef PowerSeries_mpoly self = self_t 
    165         cdef int right = r 
    166         if right != r: 
    167             raise ValueError, "exponent must be an integer" 
    168         if right < 0: 
    169             return (~self)**(-right) 
    170         if right == 0: 
    171             return self._parent(1) 
    172         if self.__is_gen: 
    173             return PowerSeries_mpoly(self._parent, self.__f**right, check=False) 
    174         if self.is_zero(): 
    175             return self 
    176         return arith.generic_power(self, right, self._parent(1)) 
    177163 
    178164def make_powerseries_mpoly_v0(parent,  f, prec, is_gen): 
  • sage/rings/power_series_poly.pyx

    r5590 r6221  
    1919            sage: loads(q.dumps()) == q 
    2020            True 
     21 
     22            sage: R.<t> = QQ[[]] 
     23            sage: f = 3 - t^3 + O(t^5) 
     24            sage: a = f^3; a 
     25            27 - 27*t^3 + O(t^5) 
     26            sage: b = f^-3; b 
     27            1/27 + 1/27*t^3 + O(t^5) 
     28            sage: a*b 
     29            1 + O(t^5) 
    2130        """ 
    2231        R = parent._poly_ring() 
     
    4958        return (<Element>left)._richcmp(right, op) 
    5059 
    51     def __pow__(self_t, r, dummy): 
    52         cdef PowerSeries_poly self = self_t 
    53         cdef int right = r 
    54         if right != r: 
    55             raise ValueError, "exponent must be an integer" 
    56         if right < 0: 
    57             return (~self)**(-right) 
    58         if right == 0: 
    59             return self._parent(1) 
    60         if self.__is_gen: 
    61             return PowerSeries_poly(self._parent, self.__f**right, check=False) 
    62         if self.is_zero(): 
    63             return self 
    64         return arith.generic_power(self, right, self._parent(1)) 
    65      
    6660    def polynomial(self): 
    6761        """ 
  • sage/schemes/generic/morphism.py

    r5498 r6221  
    1414#***************************************************************************** 
    1515 
    16 from sage.structure.element   import AdditiveGroupElement, RingElement, Element 
     16from sage.structure.element   import AdditiveGroupElement, RingElement, Element, generic_power 
    1717from sage.structure.sequence  import Sequence 
    1818 
     
    7575        return FormalCompositeMorphism(homset, right, self) 
    7676 
    77     def __pow__(self, n, dummy): 
     77    def __pow__(self, n, dummy=None): 
    7878        if not self.is_endomorphism(): 
    7979            raise TypeError, "self must be an endomorphism." 
    8080        # todo -- what about the case n=0 -- need to specify the identity map somehow. 
    81         import sage.rings.arith as arith 
    82         return arith.generic_power(self, n) 
     81        return generic_power(self, n) 
    8382 
    8483 
Note: See TracChangeset for help on using the changeset viewer.