# 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 self._gap_().Orbits(self._domain_gap()).sage()] @cached_method def orbit(self, point): def orbit(self, point, action = "OnPoints"): """ Return the orbit of the given point under the group action. Return the orbit of a point (or set, or tuple) under the group action. INPUT: - ``point`` -- can be a point or a tuple of points, depending on the action to be considered. - ``action`` (string) -- when ``point`` is a tuple of points, this variable defines whether the group is to be considered as acting on tuples (``action="ontuples"``) or acting on sets (``action="onsets"``). It is set to ``"onpoints"`` by default. See below for examples. EXAMPLES:: sage: G.orbit(3) [3, 4, 1] sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4,10)]]) sage: G.orbit(3) sage: G.orbit(3) [3, 4, 10, 1, 2] sage: G = PermutationGroup([ [('c','d')], [('a','c')] ]) sage: G.orbit('a') ['a', 'c', 'd'] """ point = self._domain_to_gap[point] return [self._domain_from_gap[x] for x in self._gap_().Orbit(point).sage()] Action of `S_3` on sets:: sage: S3 = groups.permutation.Symmetric(3) sage: S3.orbit((1,2), action = "OnSets") [[1, 2], [2, 3], [1, 3]] On tuples:: sage: S3.orbit((1,2), action = "OnTuples") [[1, 2], [2, 3], [2, 1], [3, 1], [1, 3], [3, 2]] """ if action == "OnPoints": try: point = self._domain_to_gap[point] except KeyError: raise ValueError("The point given as argument does not seem to "+ "exist. If you want to compute an action on sets "+ "of tuples you *must* define the 'action' "+ "argument explicitly.") return [self._domain_from_gap[x] for x in self._gap_().Orbit(point).sage()] elif action in ["OnTuples", "OnSets"]: points = [self._domain_to_gap[x] for x in point] orbits = self._gap_().Orbit(points, action).sage() return [[self._domain_from_gap[x] for x in o] for o in orbits] else: raise ValueError("'action' can only take values among 'OnPoints', 'OnTuples' or 'OnSets'.") def transversals(self, point): """ If G is a permutation group acting on the set `X = \{1, 2, ...., n\}` and H is the stabilizer subgroup of , a right (respectively left) transversal is a set containing exactly one element from each right (respectively left) coset of H. This method returns a right transversal of ``self`` by the stabilizer If G is a permutation group acting on the set `X = \{1, 2, ...., n\}` and H is the stabilizer subgroup of , a right (respectively left) transversal is a set containing exactly one element from each right (respectively left) coset of H. This method returns a right transversal of ``self`` by the stabilizer of ``self`` on position. EXAMPLES:: sage: G = PermutationGroup([ [(3,4)], [(1,3)] ]) sage: G = PermutationGroup([ [(3,4)], [(1,3)] ]) sage: G.transversals(1) [(), (1,3,4), (1,4,3)] sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4,10)]]) sage: G.transversals(1) sage: G.transversals(1) [(), (1,2)(3,4), (1,3,2,10,4), (1,4,2,10,3), (1,10,4,3,2)] sage: G = PermutationGroup([ [('c','d')], [('a','c')] ]) sage: G.transversals('a') [(), ('a','c','d'), ('a','d','c')] [(), ('a','c','d'), ('a','d','c')] """ G = self._gap_() return [self(G.RepresentativeAction(self._domain_to_gap[point], self._domain_to_gap[i])) sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4,10)]]) sage: G.stabilizer(10) Subgroup of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4,10)]) generated by [(2,3,4), (1,2)(3,4)] sage: G.stabilizer(1) sage: G.stabilizer(1) Subgroup of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4,10)]) generated by [(2,3)(4,10), (2,10,4)] sage: G = PermutationGroup([[(2,3,4)],[(6,7)]]) sage: G.stabilizer(1)