Given an integer k
how would I create a permutation matrix with all possible permutations of the sequence 1
to k
? For example, let's consider k=2
. Then I would like to create the matrix:
1 2
2 1
and for k=3
:
1 1 2 2 3 3
2 3 1 3 1 2
3 2 3 1 2 1
I've tried using numpy.random.permutation
but this only produces a single permutation. So, I could continue using this function, appending unique permutations until the number of columns is equal to k!
but this seems incredibly inefficient.