2.1 Permutations in RepLABΒΆ

In RepLAB, a permutation \(g\) is described using the row vector of permutation images \((g(1), g(2), \ldots, g(n))\). This corresponds to the behavior of the randperm and perms functions, and enables the use of such vectors of indices as matrix/vector subscripts.

Let us define two permutations. Note that in RepLAB permutations act on a set of given size: [1 2 3] and [1 2 3 4] are not equivalent, even though they both represent the identity of a permutation group.

g = [2 1 3];
h = [3 2 1];

To compute the action of a permutation on a point, we write:

g(2)
ans = 1

Let \(k = g h\) be the composition of \(g\) and \(h\). It is well defined if we ask that \(k(i) = g(h(i))\), then:

gh2 = g(h(2))
k = g(h)
k2 = k(2)
gh2 = 1
k =

   3   1   2

k2 = 1

But how can one compute the inverse of a permutation? Luckily, we can construct the group of all permutations of a given size in RepLAB, and call its methods to perform group operations. The function replab.S(n) creates the symmetric group acting on \(\{1,2,\ldots,n\}\). The returned object is of type replab.PermutationGroup and it proposes notably the identity, compose and inverse methods:

G = replab.S(3);
gh = G.compose(g, h)
gInv = G.inverse(g)
g_gInv = G.compose(g, gInv)
gh =

   3   1   2

gInv =

   2   1   3

g_gInv =

   1   2   3