update the matrix permutation