Changeset 7615:a1d368a08149


Ignore:
Timestamp:
12/12/07 07:50:58 (5 years ago)
Author:
William Stein <wstein@…>
Branch:
default
Message:

permutation conversion to tuples and hashing

Location:
sage/groups/perm_gps
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sage/groups/perm_gps/permgroup_element.pxd

    r7610 r7615  
    77    cdef __gap 
    88    cdef Element _gap_element 
     9    cdef __tuple 
    910    cdef PermutationGroupElement _new_c(self) 
    1011    cpdef list(self) 
  • sage/groups/perm_gps/permgroup_element.pyx

    r7611 r7615  
    498498        return [self.perm[i]+1 for i from 0 <= i < self.n] 
    499499 
     500    def __hash__(self): 
     501        """ 
     502        Return hash of this permutation. 
     503 
     504        EXAMPLES: 
     505            sage: G = SymmetricGroup(5) 
     506            sage: s = G([2,1,5,3,4]) 
     507            sage: s.tuple() 
     508            (2, 1, 5, 3, 4) 
     509            sage: hash(s) 
     510            1592966088 
     511            sage: hash(s.tuple()) 
     512            1592966088 
     513        """ 
     514        return hash(self.tuple()) 
     515 
     516    def tuple(self): 
     517        """ 
     518        Return tuple of images of integers under self. 
     519 
     520        EXAMPLES: 
     521            sage: G = SymmetricGroup(5) 
     522            sage: s = G([2,1,5,3,4]) 
     523            sage: s.tuple() 
     524            (2, 1, 5, 3, 4) 
     525        """ 
     526        if self.__tuple is None: 
     527            self.__tuple = tuple(self.list()) 
     528        return self.__tuple 
     529 
    500530    def dict(self): 
    501531        """ 
Note: See TracChangeset for help on using the changeset viewer.