1 | initial version |
The following yields the same result as your function perRandC
:
G = SymmetricGroup(5) # create the symmetric group on 5
perm = G((1,2)) # create the permutation (1, 2) in G, i.e. perm just swaps 1 and 2
M.permute_rows_and_columns(perm, perm)
show(M)
G
contains all possible permutations of {1,2,3,4,5}. Note that permute_rows_and_columns
works with 1-based indices, i.e. since we want to swap the 0th and 1st row we have to use (1,2)
. Alternatively, using the same method as in the documentation, we could also do:
G = PermutationGroup(['(1,2)'])
perm = G.gens()[0]
M.permute_rows_and_columns(perm, perm)
show(M)
All three yield the same result.