Skip to content

Commit

Permalink
Trac #34373: Implement multimajor index for permutations
Browse files Browse the repository at this point in the history
We add an implementation for the multimajor index
of a permutation with respect to a combination of
the same size, as described in:

> Armin Jöllenbeck and Manfred Schocker. Cyclic
> characters of symmetric groups. J. Algebraic Combin.,
> 12 (2000), 155-161. [https://doi.org/10.1023/A:1026592027019
doi:10.1023/A:1026592027019]

URL: https://trac.sagemath.org/34373
Reported by: gh-25shriya
Ticket author(s): Amrutha P, Shriya M, Divya Aggarwal, Aritra
Bhattacharya
Reviewer(s): Amrutha P, Aritra Bhattacharya, Julian Rüth, Samuel
Lelièvre
  • Loading branch information
Release Manager committed Aug 29, 2022
2 parents 85b5ab9 + 9a93d1d commit 1749b85
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/doc/en/reference/references/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3330,6 +3330,11 @@ REFERENCES:
*Combinatorics of symmetric designs*.
Cambridge University Press, 2006.
.. [JS2000] \A. Joellenbeck, M. Schocker.
"Cyclic Characters of Symmetric Groups".
J. Algebraic Combin., **12** (2000), 155-161.
:doi:`10.1023/A:1026592027019`.
.. [JS2010] \B. Jones, A. Schilling.
"Affine structures and a tableau model for `E_6` crystals",
J. Algebra. **324** (2010). 2512-2542.
Expand Down
52 changes: 52 additions & 0 deletions src/sage/combinat/permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,18 @@
finite Weyl group to make it more uniform with :class:`SymmetricGroup`.
Added ability to compute the conjugacy classes.
- Amrutha P, Shriya M, Divya Aggarwal (2022-08-16): Added Multimajor Index.
Classes and methods
===================
"""

# ****************************************************************************
# Copyright (C) 2007 Mike Hansen <[email protected]>
# 2022 Amrutha P <[email protected]>
# 2022 Shriya M <[email protected]>
# 2022 Divya Aggarwal <[email protected]>
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -3365,6 +3371,52 @@ def major_index(self, final_descent=False) -> Integer:
descents = self.descents(final_descent)
return sum(descents)

def multi_major_index(self, composition):
r"""
Return the multimajor index of this permutation with respect to ``composition``.
INPUT:
- ``composition`` -- a composition of the :meth:`size` of this permutation
EXAMPLES::
sage: p = Permutation([5, 6, 2, 1, 3, 7, 4])
sage: p.multi_major_index([3, 2, 2])
[2, 0, 1]
sage: p.multi_major_index([7]) == [p.major_index()]
True
sage: p.multi_major_index([1]*7)
[0, 0, 0, 0, 0, 0, 0]
sage: Permutation([]).multi_major_index([])
[]
TESTS::
sage: p.multi_major_index([1, 3, 3, 7])
Traceback (most recent call last):
...
ValueError: size of the composition should be equal to size of the permutation
REFERENCES:
- [JS2000]_
"""
composition = Composition(composition)
if self.size() != composition.size():
raise ValueError("size of the composition should be equal to size of the permutation")
descents = self.descents()
partial_sum = [0] + composition.partial_sums()
multimajor_index = []
for j in range(1, len(partial_sum)):
a = partial_sum[j-1]
b = partial_sum[j]
from bisect import bisect_right, bisect_left
start = bisect_right(descents, a)
end = bisect_left(descents, b)
multimajor_index.append(sum(descents[start: end])-(end-start)*a)
return multimajor_index

def imajor_index(self, final_descent=False) -> Integer:
"""
Return the inverse major index of the permutation ``self``, which is
Expand Down

0 comments on commit 1749b85

Please sign in to comment.