Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge branch 'public/combinat/fix_weak_order_permutations-27467' of g…
Browse files Browse the repository at this point in the history
…it://trac.sagemath.org/sage into public/combinat/fix_weak_order_permutations-27467
  • Loading branch information
Travis Scrimshaw committed May 24, 2019
2 parents 5ba5a5a + 2273223 commit c822b3f
Showing 1 changed file with 73 additions and 41 deletions.
114 changes: 73 additions & 41 deletions src/sage/combinat/permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3012,7 +3012,7 @@ def descents(self, final_descent=False, side='right', positive=False,
Check that the original error of :trac:`23891` is fixed::
sage: Permutations(4)([1,4,3,2]).weak_covers()
[[1, 4, 2, 3], [1, 3, 4, 2]]
[[1, 3, 4, 2], [1, 4, 2, 3]]
"""
if index_set is None:
index_set = range(1, len(self))
Expand Down Expand Up @@ -6200,11 +6200,11 @@ def __init__(self, n, category=None):
"""
TESTS:
We skip the reduced word method because it does not respect the
ordering for multiplication::
We skip the descent and reduced word methods because they do
not respect the ordering for multiplication::
sage: SP = Permutations(3)
sage: TestSuite(SP).run(skip='_test_reduced_word')
sage: TestSuite(SP).run(skip=['_test_reduced_word', '_test_has_descent'])
sage: SP.options.mult='r2l'
sage: TestSuite(SP).run()
Expand Down Expand Up @@ -6725,12 +6725,6 @@ def has_left_descent(self, i, mult=None):
descent of `\pi` is an index `i \in \{ 1, 2, \ldots, n-1 \}`
satisfying `\pi^{-1}(i) > \pi^{-1}(i+1)`.
The optional parameter ``mult`` can be set to ``'l2r'`` or
``'r2l'``; if so done, it is used instead of the ``mult``
variable in :meth:`Permutations.options`. Anyone using
this method in a non-interactive environment is encouraged to
do so in order to have code behave reliably.
.. WARNING::
The methods :meth:`descents` and :meth:`idescents` behave
Expand All @@ -6740,27 +6734,27 @@ def has_left_descent(self, i, mult=None):
.. WARNING::
The optional input ``mult`` might disappear once :trac:`14881`
is fixed.
This ignores the multiplication convention in order
to be consistent with other Coxeter operations in
permutations (e.g., computing :meth:`reduced_word`).
EXAMPLES::
sage: P = Permutations(4)
sage: x = P([3, 2, 4, 1])
sage: x.descents()
[1, 3]
sage: (~x).descents()
[1, 2]
sage: [i for i in P.index_set() if x.has_left_descent(i)]
[1, 3]
sage: [i for i in P.index_set() if x.has_left_descent(i, mult="l2r")]
[1, 3]
sage: [i for i in P.index_set() if x.has_left_descent(i, mult="r2l")]
[1, 2]
"""
if mult is None:
mult = self.parent().options.mult
if mult != 'l2r':
self = self.inverse()
return self[i-1] > self[i]
if mult is not None:
from sage.misc.superseded import deprecation
deprecation(27467, "The mult option is deprecated.")
for val in self._list:
if val == i:
return False
if val == i + 1:
return True

def has_right_descent(self, i, mult=None):
r"""
Expand All @@ -6783,12 +6777,6 @@ def has_right_descent(self, i, mult=None):
descent of `\pi` is an index `i \in \{ 1, 2, \ldots, n-1 \}`
satisfying `\pi(i) > \pi(i+1)`.
The optional parameter ``mult`` can be set to ``'l2r'`` or
``'r2l'``; if so done, it is used instead of the ``mult``
variable in :meth:`Permutations.options`. Anyone using
this method in a non-interactive environment is encouraged to
do so in order to have code behave reliably.
.. WARNING::
The methods :meth:`descents` and :meth:`idescents` behave
Expand All @@ -6798,26 +6786,22 @@ def has_right_descent(self, i, mult=None):
.. WARNING::
The optional input ``mult`` might disappear once :trac:`14881`
is fixed.
This ignores the multiplication convention in order
to be consistent with other Coxeter operations in
permutations (e.g., computing :meth:`reduced_word`).
EXAMPLES::
sage: P = Permutations(4)
sage: x = P([3, 2, 4, 1])
sage: (~x).descents()
[1, 2]
sage: x.descents()
[1, 3]
sage: [i for i in P.index_set() if x.has_right_descent(i)]
[1, 2]
sage: [i for i in P.index_set() if x.has_right_descent(i, mult="l2r")]
[1, 2]
sage: [i for i in P.index_set() if x.has_right_descent(i, mult="r2l")]
[1, 3]
"""
if mult is None:
mult = self.parent().options.mult
if mult != 'r2l':
self = self.inverse()
if mult is not None:
from sage.misc.superseded import deprecation
deprecation(27467, "The mult option is deprecated.")
return self[i-1] > self[i]

def __mul__(self, other):
Expand Down Expand Up @@ -6887,6 +6871,54 @@ def inverse(self):

__invert__ = inverse

def apply_simple_reflection_left(self, i):
r"""
Return ``self`` multiplied by the simple reflection ``s[i]``
on the left.
.. WARNING::
This ignores the multiplication convention in order
to be consistent with other Coxeter operations in
permutations (e.g., computing :meth:`reduced_word`).
EXAMPLES::
sage: W = Permutations(3)
sage: w = W([2,3,1])
sage: w.apply_simple_reflection_left(1)
[1, 3, 2]
sage: w.apply_simple_reflection_left(2)
[3, 2, 1]
"""
s = self.parent().simple_reflections()[i]
p = right_action_same_n(self._list, s._list)
return self.__class__(self.parent(), p)

def apply_simple_reflection_right(self, i):
r"""
Return ``self`` multiplied by the simple reflection ``s[i]``
on the right.
.. WARNING::
This ignores the multiplication convention in order
to be consistent with other Coxeter operations in
permutations (e.g., computing :meth:`reduced_word`).
EXAMPLES::
sage: W = Permutations(3)
sage: w = W([2,3,1])
sage: w.apply_simple_reflection_right(1)
[3, 2, 1]
sage: w.apply_simple_reflection_right(2)
[2, 1, 3]
"""
s = self.parent().simple_reflections()[i]
p = left_action_same_n(self._list, s._list)
return self.__class__(self.parent(), p)

#############################
# Constructing Permutations #
#############################
Expand Down

0 comments on commit c822b3f

Please sign in to comment.