Skip to content

Commit

Permalink
Trac #29808: fix left and right actions of permutations on matrices
Browse files Browse the repository at this point in the history
As observed in #29553, permutations incorrectly act on matrices via a
left action on the rows when multiplying on the right. This ticket fixes
the left action to act on the left, and also adds the missing right
action on the columns.

{{{
sage: S = SymmetricGroup(6)
sage: p, q = S('(1,2,3,4,5,6)'), S('(1,2)(3,4)(5,6)')
sage: M = matrix.diagonal([1..6])
sage: (M * p.matrix()) * q.matrix() == M * (p.matrix() * q.matrix())  #
correct
True
sage: (M * p) * q == M * (p * q)  # should be True
False
}}}

URL: https://trac.sagemath.org/29808
Reported by: gh-mwageringel
Ticket author(s): Markus Wageringel
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager committed Jul 8, 2020
2 parents 76f6767 + a9dd308 commit 8de8feb
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/sage/groups/perm_gps/permgroup_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1177,22 +1177,23 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):

cpdef _act_on_(self, x, bint self_on_left):
"""
Return the right action of self on left.
Return the result of the action of ``self`` on ``x``.
For example, if f=left is a polynomial, then this function returns
f(sigma\*x), which is image of f under the right action of sigma on
For example, if ``x=f(z)`` is a polynomial, then this function returns
f(sigma\*z), which is the image of f under the right action of sigma on
the indeterminates. This is a right action since the image of
f(sigma\*x) under tau is f(sigma\*tau\*x).
f(sigma\*z) under tau is f(sigma\*tau\*z).
Additionally, if ``left`` is a matrix, then sigma acts on the matrix
by permuting the rows.
Additionally, if ``x`` is a matrix, then sigma acts on the matrix
by permuting the columns when acting from the right and by permuting
the rows when acting from the left.
INPUT:
- ``x`` -- element of space on which permutations act
- ``left`` - element of space on which permutations
act from the right
- ``self_on_left`` -- if ``True``, this permutation acts on ``x`` from
the left, otherwise from the right
EXAMPLES::
Expand All @@ -1210,13 +1211,18 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):
2*x^2 - y^2 + z^2 + u^2
sage: M = matrix(ZZ,[[1,0,0,0,0],[0,2,0,0,0],[0,0,3,0,0],[0,0,0,4,0],[0,0,0,0,5]])
sage: M*sigma
sage: sigma * M
[0 2 0 0 0]
[0 0 3 0 0]
[1 0 0 0 0]
[0 0 0 0 5]
[0 0 0 4 0]
sage: (M * sigma) * tau == M * (sigma * tau)
True
sage: (M * sigma) * tau == (M * sigma.matrix()) * tau.matrix()
True
sage: (tau * sigma) * M == tau * (sigma * M)
True
"""
if not self_on_left:
left = x
Expand All @@ -1235,7 +1241,11 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):
left.parent()))
return left(tuple(sigma_x))
elif is_Matrix(left):
return left.with_permuted_rows(self)
return left.with_permuted_columns(~self)
else:
if is_Matrix(x):
return x.with_permuted_rows(self)


def __mul__(left, right):
r"""
Expand Down

0 comments on commit 8de8feb

Please sign in to comment.