The easiest way to construct a group is given first below. The other ways are given for completeness.
PermutationGroup.of
¶RepLAB becomes interesting when considering specific groups of permutations. For example, given two permutations, one would like to enumerate all permutations that can be generated by composition. There are several ways of constructing permutation groups in RepLAB. The easiest one is to call PermutationGroup.of.
h1 = [2 1 3 4];
h2 = [3 4 1 2];
H = replab.PermutationGroup.of(h1, h2)
H =
Permutation group acting on 4 elements of order 8
identity: [1, 2, 3, 4]
generator(1 or 'x1'): [2, 1, 3, 4]
generator(2 or 'x2'): [3, 4, 1, 2]
recognize.source: Dihedral group of order 8
This method allows us to name the generators as well (otherwise, they are given the default names x1
and x2
):
H = replab.PermutationGroup.of('h1', h1, 'h2', h2)
H =
Permutation group acting on 4 elements of order 8
identity: [1, 2, 3, 4]
generator(1 or 'h1'): [2, 1, 3, 4]
generator(2 or 'h2'): [3, 4, 1, 2]
recognize.source: Dihedral group of order 8
PermutationGroup
constructor¶Another option is to call the constructor directly.
H = replab.PermutationGroup(4, {h1, h2}, 'generatorNames', {'h1', 'h2'})
H =
Permutation group acting on 4 elements of order 8
identity: [1, 2, 3, 4]
generator(1 or 'h1'): [2, 1, 3, 4]
generator(2 or 'h2'): [3, 4, 1, 2]
recognize.source: Dihedral group of order 8
The generatorNames
keyword argument is optional: if omitted, the default names will be x1
and x2
as before.
Another interesting optional keyword argument here is order
. If the group order is known beforehand, the group can be constructed much faster. However, an incorrect value leads to undefined behavior (hanging, returning incorrect results). Use with caution.
H = replab.PermutationGroup(4, {h1, h2}, 'order', vpi(8));
This option is interesting mostly for big groups; thus we write the group order using the vpi library, which is included by default with RepLAB – using the default MATLAB/Octave number type would cause problems above \(2^{53}\), as it has finite precision.
One can equivalently construct \(H\) as a subgroup of the symmetric group \(S_4\) by calling the subgroup method.
S4 = replab.S(4);
H = S4.subgroup({h1, h2});
Like when using the PermutationGroup
constructor, group generators must be wrapped into a cell array here (the curly braces!), and generators can be named with the help of the dedicated keyword argument:
S4 = replab.S(4);
H = S4.subgroup({h1, h2}, 'generatorNames', {'h1', 'h2'})
H =
Permutation group acting on 4 elements of order 8
identity: [1, 2, 3, 4]
generator(1 or 'h1'): [2, 1, 3, 4]
generator(2 or 'h2'): [3, 4, 1, 2]
recognize.source: Dihedral group of order 8
The order
option is also available.
S4 = replab.S(4);
H = S4.subgroup({h1, h2}, 'order', vpi(8));
We already mentioned the symmetric group, here are two ways to construct this group:
S4 = replab.PermutationGroup.symmetric(4);
S4 = replab.S(4)
S4 =
Symmetric group acting on 4 elements
identity: [1, 2, 3, 4]
generator(1 or 'x1'): [2, 3, 4, 1]
generator(2 or 'x2'): [2, 1, 3, 4]
recognize.source: Symmetric group S(4)
The alternating group is available as well, which contains all permutations that can be expressed as a product of an even number of transpositions.
A4 = replab.PermutationGroup.alternating(4);
A4 = replab.A(4)
A4 =
Permutation group acting on 4 elements of order 12
identity: [1, 2, 3, 4]
generator(1 or 'x1'): [2, 1, 4, 3]
generator(2 or 'x2'): [2, 3, 1, 4]
recognize.source: Alternating group A(4) of degree 4
A dihedral group is the symmetry group of a regular polygon.
D4 = replab.PermutationGroup.dihedral(4);
D4 = replab.D(4)
D4 =
Permutation group acting on 4 elements of order 8
identity: [1, 2, 3, 4]
generator(1 or 'x1'): [4, 3, 2, 1]
generator(2 or 'x2'): [2, 3, 4, 1]
recognize.source: Dihedral group of order 8
The cyclic group \(C_n\) is isomorphic to the group of integers modulo \(n\).
C4 = replab.PermutationGroup.cyclic(4);
C4 = replab.C(4)
C4 =
Permutation group acting on 4 elements of order 4
identity: [1, 2, 3, 4]
generator(1 or 'x1'): [2, 3, 4, 1]
recognize.source: Cyclic group C(4) of order 4 < x | x^4 = 1 >