Ticket #10911: trac_10911-inverses-permutation-group-v2.patch

File trac_10911-inverses-permutation-group-v2.patch, 1.5 KB (added by rbeezer, 10 years ago)
  • sage/groups/perm_gps/permgroup_element.pyx

    # HG changeset patch
    # User Rob Beezer <beezer@ups.edu>
    # Date 1299784522 28800
    # Node ID 25aa3b3919010583fa0ce820b86d8a3f9495d046
    # Parent  8438b7c20d79c02a2ece3e1c3f7224a772ff8f07
    10911: inverse method for permutation group elements
    
    diff -r 8438b7c20d79 -r 25aa3b391901 sage/groups/perm_gps/permgroup_element.pyx
    a b  
    744744                    order = Integer(order_c)
    745745        sage_free(seen)
    746746        return int(order_c) if order is None else order
     747
     748    def inverse(self):
     749        r"""
     750        Returns the inverse permutation.
     751
     752        OUTPUT:
     753
     754        For an element of a permutation group, this method returns the inverse
     755        element, which is both the inverse function and the inverse as an
     756        element of a group.
     757
     758        EXAMPLES::
     759
     760            sage: s = PermutationGroupElement("(1,2,3)(4,5)")
     761            sage: s.inverse()
     762            (1,3,2)(4,5)
     763
     764            sage: A = AlternatingGroup(4)
     765            sage: t = A("(1,2,3)")
     766            sage: t.inverse()
     767            (1,3,2)
     768
     769        There are several ways (syntactically) to get an inverse
     770        of a permutation group element.  ::
     771
     772            sage: s = PermutationGroupElement("(1,2,3,4)(6,7,8)")
     773            sage: s.inverse() == s^-1
     774            True
     775            sage: s.inverse() == ~s
     776            True
     777        """
     778        return ~self
    747779       
    748780    def sign(self):
    749781        """