Ticket #14291: 14291_reviewer.patch

File 14291_reviewer.patch, 5.6 KB (added by dimpase, 8 years ago)
  • sage/groups/perm_gps/permgroup.py

    # HG changeset patch
    # User Dmitrii Pasechnik <dimpase@gmail.com>
    # Date 1363712673 -28800
    # Node ID c88f77f5b975d7eb044a979c1feaaf8091821131
    # Parent  7bf0ce3fbbc7422dd5c98b3abc4067186469aac8
    reviewer patch, adding moar actions
    
    diff --git a/sage/groups/perm_gps/permgroup.py b/sage/groups/perm_gps/permgroup.py
    a b  
    9696
    9797- Javier Lopez Pena (2013): Added conjugacy classes.
    9898
     99- Nathann Cohen, Dmitrii Pasechnik (2013): Added non-default actions.
     100
    99101REFERENCES:
    100102
    101103- Cameron, P., Permutation Groups. New York: Cambridge University
     
    10391041    def orbits(self):
    10401042        """
    10411043        Returns the orbits of the elements of the domain under the
    1042         group action.
     1044        default group action.
    10431045       
    10441046        EXAMPLES::
    10451047       
     
    10661068        return [[self._domain_from_gap[x] for x in orbit] for orbit in
    10671069                self._gap_().Orbits(self._domain_gap()).sage()]
    10681070
     1071    supported_actions = ["OnPoints", "OnTuples", "OnSets", "OnPairs", "OnSetsSets",
     1072                "OnSetsDisjointSets", "OnSetsTuples", "OnTuplesSets", "OnTuplesTuples"]
     1073
    10691074    @cached_method
    10701075    def orbit(self, point, action = "OnPoints"):
    10711076        """
    1072         Return the orbit of a point (or set, or tuple) under the group action.
     1077        Return the orbit of a point under the group action in the list
     1078        `self.supported_actions`.
     1079        These are taken from `http://www.gap-system.org/Manuals/doc/ref/chap41.html`_.
    10731080
    10741081        INPUT:
    10751082
    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.
     1083        - ``point`` -- can be a point or any of the list above, depending on the
     1084          action to be considered. Note that sets should be "canonical", i.e. their
     1085          members must be sorted w.r.t. to the default order on them.
     1086
     1087        - ``action`` (string) -- if ``point`` is a tuple (of tuples) of points, this
     1088          variable describes how the group is acting. The list of possibilites is
     1089          is given by  `self.supported_actions`.
     1090          It is set to ``"OnPoints"`` by default. See below for examples.
    10841091
    10851092        EXAMPLES::
    10861093
     
    11041111
    11051112            sage: S3.orbit((1,2), action = "OnTuples")
    11061113            [[1, 2], [2, 3], [2, 1], [3, 1], [1, 3], [3, 2]]
     1114       
     1115        Action of `S_4` on sets of disjoint sets::
     1116
     1117            sage: S4 = groups.permutation.Symmetric(4)
     1118            sage: S4.orbit(((1,2),(3,4)), action = "OnSetsDisjointSets")
     1119            [[[1, 2], [3, 4]], [[1, 4], [2, 3]], [[1, 3], [2, 4]]]
     1120
    11071121        """
    11081122        if action == "OnPoints":
    11091123            try:
     
    11151129                                 "argument explicitly.")
    11161130            return [self._domain_from_gap[x] for x in self._gap_().Orbit(point).sage()]
    11171131
    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]
     1132        elif action in self.supported_actions:
     1133            if action in ['OnTuples', 'OnSets', 'OnPairs']:
     1134                points = [self._domain_to_gap[x] for x in point]
     1135                orbits = self._gap_().Orbit(points, action).sage()
     1136                return [[self._domain_from_gap[x] for x in o] for o in orbits]
     1137            else:
     1138                points = [[self._domain_to_gap[x] for x in p] for p in point]
     1139                orbits = self._gap_().Orbit(points, action).sage()
     1140                return [[[self._domain_from_gap[x] for x in p] for p in o]
     1141                        for o in orbits]
     1142
    11221143        else:
    1123             raise ValueError("'action' can only take values among 'OnPoints', 'OnTuples' or 'OnSets'.")
     1144            raise ValueError("'action' can only take values among "+
     1145                             self.supported_actions)
     1146
     1147    def action(self, domain, action = "OnPoints"):
     1148        """
     1149        Return the permutation group induced by self acting on domain.
     1150       
     1151        INPUT:
     1152
     1153        - ``domain`` -- the list of things for which GAP knows how to compute
     1154          the action of the permutation group. For instance it can be obtained by
     1155          calling :meth:`orbit`.
     1156
     1157        - ``action`` (string) -- the action on domain. Need not be limited to
     1158          `self.supported_actions`.
     1159          It is set to ``"OnPoints"`` by default. See below for examples.
     1160
     1161        EXAMPLES::
     1162
     1163            Action of `S_5` on 2-subsets::
     1164
     1165            sage: S5 = groups.permutation.Symmetric(5)
     1166            sage: o10 = S5.orbit((1,2), action = "OnSets")
     1167            sage: S5_10 = S5.action(o10, action = "OnSets"); S5_10
     1168            Permutation Group with generators [(2,4)(6,9)(7,10), (1,2,3,5,7)(4,6,8,9,10)]
     1169           
     1170            Non-faithful action of `S_4` on sets of disjoint sets::
     1171
     1172            sage: S4 = groups.permutation.Symmetric(4)
     1173            sage: o3 = S4.orbit(((1,2),(3,4)), action = "OnSetsDisjointSets")
     1174            sage: S3 = S4.action(o3,  "OnSetsDisjointSets"); S3
     1175            Permutation Group with generators [(2,3), (1,2)]
     1176            sage: S3.order()
     1177            6
     1178
     1179        """
     1180        return PermutationGroup(gap_group = self._gap_().Action(domain, action))
    11241181
    11251182    def transversals(self, point):
    11261183        """