code for the matrix columnwise permutation generator