I try to find a solution to found all the columns permutations of a matrix. So i wrote this code but it doesn't work.
SOLVED:
#! python
import numpy
def permutation(matrix):
if numpy.size(matrix,1) == 1:
return [matrix]
#empty list
m=[]
# Iterate the input(matrix) and calculate the permutation
for i in range(numpy.size(matrix,1)):
column = matrix[:,[i]]
# Extract column[i] or m from the matrix. remMatrix is the remaining matrix
remMatrix = numpy.concatenate((matrix[:,:i], matrix[:,i+1:]), axis=1)
# Generating all permutations where m is the first element
for p in permutation(remMatrix):
m.append(numpy.concatenate([column,p],axis=1))
return m
#driver to test the function
matrix=numpy.matrix('1 2 3; 0 0 0')
for p in permutation(matrix):
print(p)