Permute - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

LinearAlgebra[Modular]

 Permute
 apply compact permutation to a mod m Matrix or Vector

 Calling Sequence Permute(m, pvec, A, rowflag, invflag)

Parameters

 m - modulus pvec - permutation vector A - mod m Matrix or Vector rowflag - boolean; indicate a row permutation (false for column) invflag - boolean; indicate whether inverse permutation is applied

Description

 • The Permute function applies the compact permutation stored in pvec to the mod m Matrix or Vector A in-place.
 • The pvec parameter must be a Vector of type integer[4]/integer[8], integer, or anything, and must have integer entries in the range $1..r$, where $r$ is the number of elements being permuted.
 • If rowflag is true, the permutation is applied to the rows of A.  If the number of elements in pvec is larger than the number of rows of A, then only the first $\mathrm{rows}\left(A\right)$ components of pvec are applied.
 If rowflag is false, the permutation is applied to the columns of A. If the number of elements in pvec is larger than the number of columns of A, then only the first $\mathrm{cols}\left(A\right)$ components of pvec are applied.
 • If the invflag parameter is true, it indicates that the inverse of the permutation is to be applied.  If invflag is false, it indicates that the permutation itself is to be applied.
 • As mentioned before, the permutation must be stored in a compact form in pvec. This vector can be interpreted as an ordered list of instructions on how to apply a permutation, where the first entry describes the row exchange required for the first row, the second describes the row exchange required for the second row, etcetera.
 For example, if, for a $4x4$ Matrix, the permutation Vector is given by [1, 4, 4], then this corresponds to the following exchanges in the given order: $1<=>1$, $2<=>4$, $3<=>4$.
 Unlike a permutation Matrix, this format does not result in a unique representation for a permutation. For example, for a $4x4$ Matrix, the identity permutation is given by [], [1], [2,1], [1,2,3], [3,2,1], [2,1,3], etcetera. Use of this format makes application of the permutation (or its inverse) to a Matrix or Vector quite simple. If the permutation Matrix is required, it can be obtained through application of the Permute function on an identity Matrix.
 • This function is most often used in combination with LUDecomposition and RowEchelonTransform, and is used in LUApply.
 • This command is part of the LinearAlgebra[Modular] package, so it can be used in the form Permute(..) only after executing the command with(LinearAlgebra[Modular]).  However, it can always be used in the form LinearAlgebra[Modular][Permute](..).

Examples

An application of a row permutation and inverse to a Matrix.

 > $\mathrm{with}\left({\mathrm{LinearAlgebra}}_{\mathrm{Modular}}\right):$
 > $p≔97$
 ${p}{≔}{97}$ (1)
 > $A≔\mathrm{Mod}\left(p,\mathrm{Matrix}\left(5,5,\left(i,j\right)→\mathrm{rand}\left(\right)\right),{\mathrm{integer}}_{[]}\right)$
 ${A}{≔}\left[\begin{array}{ccccc}{77}& {96}& {10}& {86}& {58}\\ {36}& {80}& {22}& {44}& {39}\\ {60}& {39}& {43}& {12}& {55}\\ {2}& {24}& {71}& {45}& {29}\\ {21}& {48}& {7}& {33}& {57}\end{array}\right]$ (2)
 > $\mathrm{A2}≔\mathrm{Copy}\left(p,A\right):$
 > $P≔{\mathrm{Vector}}_{\mathrm{row}}\left(\left[5,4,3,5\right]\right)$
 ${P}{≔}\left[\begin{array}{cccc}{5}& {4}& {3}& {5}\end{array}\right]$ (3)
 > $\mathrm{Permute}\left(p,P,\mathrm{A2},\mathrm{true},\mathrm{false}\right):$
 > $\mathrm{A2}$
 $\left[\begin{array}{ccccc}{21}& {48}& {7}& {33}& {57}\\ {2}& {24}& {71}& {45}& {29}\\ {60}& {39}& {43}& {12}& {55}\\ {77}& {96}& {10}& {86}& {58}\\ {36}& {80}& {22}& {44}& {39}\end{array}\right]$ (4)
 > $\mathrm{Permute}\left(p,P,\mathrm{A2},\mathrm{true},\mathrm{true}\right):$
 > $\mathrm{A2},A$
 $\left[\begin{array}{ccccc}{77}& {96}& {10}& {86}& {58}\\ {36}& {80}& {22}& {44}& {39}\\ {60}& {39}& {43}& {12}& {55}\\ {2}& {24}& {71}& {45}& {29}\\ {21}& {48}& {7}& {33}& {57}\end{array}\right]{,}\left[\begin{array}{ccccc}{77}& {96}& {10}& {86}& {58}\\ {36}& {80}& {22}& {44}& {39}\\ {60}& {39}& {43}& {12}& {55}\\ {2}& {24}& {71}& {45}& {29}\\ {21}& {48}& {7}& {33}& {57}\end{array}\right]$ (5)

An application of column permutation to a row vector.

 > $B≔\mathrm{Mod}\left(p,{\mathrm{Vector}}_{\mathrm{row}}\left(5,i→\mathrm{rand}\left(\right)\right),{\mathrm{float}}_{8}\right)$
 ${B}{≔}\left[\begin{array}{ccccc}{65.}& {16.}& {93.}& {96.}& {71.}\end{array}\right]$ (6)
 > $\mathrm{Permute}\left(p,P,B,\mathrm{false},\mathrm{false}\right):$
 > $B$
 $\left[\begin{array}{ccccc}{71.}& {96.}& {93.}& {65.}& {16.}\end{array}\right]$ (7)
 > $\mathrm{Permute}\left(p,P,B,\mathrm{false},\mathrm{true}\right):$
 > $B$
 $\left[\begin{array}{ccccc}{65.}& {16.}& {93.}& {96.}& {71.}\end{array}\right]$ (8)