Ticket #14291: trac_14291.patch

File trac_14291.patch, 5.1 KB (added by ncohen, 8 years ago)
  • sage/groups/perm_gps/permgroup.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1363519490 -3600
    # Node ID 884c704285a3d36daabcf5a4bfb64b3270defe46
    # Parent  a706b13de29b1153214c78d11f94b2c30090c88d
    Orbits of tuples and sets
    
    diff --git a/sage/groups/perm_gps/permgroup.py b/sage/groups/perm_gps/permgroup.py
    a b  
    10671067                self._gap_().Orbits(self._domain_gap()).sage()]
    10681068
    10691069    @cached_method
    1070     def orbit(self, point):
     1070    def orbit(self, point, action = "OnPoints"):
    10711071        """
    1072         Return the orbit of the given point under the group action.
     1072        Return the orbit of a point (or set, or tuple) under the group action.
     1073
     1074        INPUT:
     1075
     1076        - ``point`` -- can be a point or a tuple of points, depending on the
     1077          action to be considered.
     1078
     1079        - ``action`` (string) -- when ``point`` is a tuple of points, this
     1080          variable defines whether the group is to be considered as acting on
     1081          tuples (``action="ontuples"``) or acting on sets
     1082          (``action="onsets"``). It is set to ``"onpoints"`` by default. See
     1083          below for examples.
    10731084
    10741085        EXAMPLES::
    10751086
     
    10771088            sage: G.orbit(3)
    10781089            [3, 4, 1]
    10791090            sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4,10)]])
    1080             sage: G.orbit(3)                                                 
     1091            sage: G.orbit(3)
    10811092            [3, 4, 10, 1, 2]
    1082 
    10831093            sage: G = PermutationGroup([ [('c','d')], [('a','c')] ])
    10841094            sage: G.orbit('a')
    10851095            ['a', 'c', 'd']
    1086         """
    1087         point = self._domain_to_gap[point]
    1088         return [self._domain_from_gap[x] for x in self._gap_().Orbit(point).sage()]
    1089    
     1096
     1097        Action of `S_3` on sets::
     1098
     1099            sage: S3 = groups.permutation.Symmetric(3)
     1100            sage: S3.orbit((1,2), action = "OnSets")
     1101            [[1, 2], [2, 3], [1, 3]]
     1102
     1103        On tuples::
     1104
     1105            sage: S3.orbit((1,2), action = "OnTuples")
     1106            [[1, 2], [2, 3], [2, 1], [3, 1], [1, 3], [3, 2]]
     1107        """
     1108        if action == "OnPoints":
     1109            try:
     1110                point = self._domain_to_gap[point]
     1111            except KeyError:
     1112                raise ValueError("The point given as argument does not seem to "+
     1113                                 "exist. If you want to compute an action on sets "+
     1114                                 "of tuples you *must* define the 'action' "+
     1115                                 "argument explicitly.")
     1116            return [self._domain_from_gap[x] for x in self._gap_().Orbit(point).sage()]
     1117
     1118        elif action in ["OnTuples", "OnSets"]:
     1119            points = [self._domain_to_gap[x] for x in point]
     1120            orbits = self._gap_().Orbit(points, action).sage()
     1121            return [[self._domain_from_gap[x] for x in o] for o in orbits]
     1122        else:
     1123            raise ValueError("'action' can only take values among 'OnPoints', 'OnTuples' or 'OnSets'.")
     1124
    10901125    def transversals(self, point):
    10911126        """
    1092         If G is a permutation group acting on the set `X = \{1, 2, ...., n\}` 
    1093         and H is the stabilizer subgroup of <integer>, a right 
    1094         (respectively left) transversal is a set containing exactly 
    1095         one element from each right (respectively left) coset of H. This 
    1096         method returns a right transversal of ``self`` by the stabilizer 
     1127        If G is a permutation group acting on the set `X = \{1, 2, ...., n\}`
     1128        and H is the stabilizer subgroup of <integer>, a right
     1129        (respectively left) transversal is a set containing exactly
     1130        one element from each right (respectively left) coset of H. This
     1131        method returns a right transversal of ``self`` by the stabilizer
    10971132        of ``self`` on <integer> position.
    10981133
    10991134        EXAMPLES::
    11001135
    1101             sage: G = PermutationGroup([ [(3,4)], [(1,3)] ])           
     1136            sage: G = PermutationGroup([ [(3,4)], [(1,3)] ])
    11021137            sage: G.transversals(1)
    11031138            [(), (1,3,4), (1,4,3)]
    11041139            sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4,10)]])
    1105             sage: G.transversals(1)                                   
     1140            sage: G.transversals(1)
    11061141            [(), (1,2)(3,4), (1,3,2,10,4), (1,4,2,10,3), (1,10,4,3,2)]
    11071142
    11081143            sage: G = PermutationGroup([ [('c','d')], [('a','c')] ])
    11091144            sage: G.transversals('a')
    1110             [(), ('a','c','d'), ('a','d','c')]           
     1145            [(), ('a','c','d'), ('a','d','c')]
    11111146        """
    11121147        G = self._gap_()
    11131148        return [self(G.RepresentativeAction(self._domain_to_gap[point], self._domain_to_gap[i]))
     
    11281163            sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4,10)]])
    11291164            sage: G.stabilizer(10)
    11301165            Subgroup of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4,10)]) generated by [(2,3,4), (1,2)(3,4)]
    1131             sage: G.stabilizer(1) 
     1166            sage: G.stabilizer(1)
    11321167            Subgroup of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4,10)]) generated by [(2,3)(4,10), (2,10,4)]
    11331168            sage: G = PermutationGroup([[(2,3,4)],[(6,7)]])
    11341169            sage: G.stabilizer(1)