Skip to content

Commit

Permalink
sagemathgh-38598: Add reflection_index_set() and reflection() methods…
Browse files Browse the repository at this point in the history
… for permutations

    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

These methods are general optional methods for complex reflections
groups. We provide an implementation for two implementations of the
symmetric group.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#38598
Reported by: Travis Scrimshaw
Reviewer(s): Amritanshu Prasad
  • Loading branch information
Release Manager committed Sep 8, 2024
2 parents fb47750 + b8e8c19 commit a8d5783
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/sage/combinat/permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7722,6 +7722,52 @@ def simple_reflection(self, i):
g[i] = i
return self.element_class(self, g, check=False)

@cached_method
def reflection_index_set(self):
r"""
Return the index set of the reflections of ``self``.
.. SEEALSO::
- :meth:`reflection`
- :meth:`reflections`
EXAMPLES::
sage: P = Permutations(4)
sage: P.reflection_index_set()
((1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4))
"""
return tuple([tuple(c) for c in itertools.combinations(range(1, self.n+1), 2)])

def reflection(self, i):
r"""
Return the reflection indexed by ``i`` of ``self``.
This returns the permutation with cycle `i = (a, b)`.
.. SEEALSO::
- :meth:`reflections_index_set`
- :meth:`reflections`
EXAMPLES::
sage: P = Permutations(4)
sage: for i in P.reflection_index_set():
....: print('%s %s'%(i, P.reflection(i)))
(1, 2) [2, 1, 3, 4]
(1, 3) [3, 2, 1, 4]
(1, 4) [4, 2, 3, 1]
(2, 3) [1, 3, 2, 4]
(2, 4) [1, 4, 3, 2]
(3, 4) [1, 2, 4, 3]
"""
data = list(range(1, self.n+1))
data[i[0]-1] = i[1]
data[i[1]-1] = i[0]
return self.element_class(self, data, check=False)

class Element(Permutation):
def has_left_descent(self, i, mult=None):
r"""
Expand Down
44 changes: 44 additions & 0 deletions src/sage/groups/perm_gps/permgroup_named.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,50 @@ def simple_reflection(self, i):
"""
return self([(i, self._domain[self._domain.index(i)+1])], check=False)

@cached_method
def reflection_index_set(self):
r"""
Return the index set of the reflections of ``self``.
.. SEEALSO::
- :meth:`reflection`
- :meth:`reflections`
EXAMPLES::
sage: S5 = SymmetricGroup(5)
sage: S5.reflection_index_set()
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
"""
return tuple(range(len(self.reflections())))

def reflection(self, i):
r"""
Return the `i`-th reflection of ``self``.
For `i` in `1,\dots,N`, this gives the `i`-th reflection of
``self``.
.. SEEALSO::
- :meth:`reflections_index_set`
- :meth:`reflections`
EXAMPLES::
sage: S4 = SymmetricGroup(4)
sage: for i in S4.reflection_index_set():
....: print('%s %s'%(i, S4.reflection(i)))
0 (1,2)
1 (1,3)
2 (1,4)
3 (2,3)
4 (2,4)
5 (3,4)
"""
return self.reflections()[i]

def reflections(self):
"""
Return the list of all reflections in ``self``.
Expand Down

0 comments on commit a8d5783

Please sign in to comment.