-
-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #34373: Implement multimajor index for permutations
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
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|