MAT C=PERM(A,P) / If P is a column vector (m*1) consisting of numbers 1,2,...,m in any order, the rows of A will be permuted according to P. If P is a row vector, the columns of A are permuted. In fact P may contain any distinct numbers. The rows (or columns) of A are permuted according to the magnitudes of these numbers. There is another form of this operation MAT C=PERM2(A,P) which does the same job but the permutation defined by P is interpreted in a different way. Let A=[1,2,3,4,5,6,7,8] and P=[5,8,1,3,7,6,4,2]. Then MAT C=PERM(A,P) gives C=[3,8,4,7,1,6,5,2], i.e. C(P(i))=A(i), but MAT C=PERM2(A,P) gives C=[5,8,1,3,7,6,4,2], i.e. C(i)=A(P(i)). MAT C=PERM0(A,P) works as PERM2 but assumes that P really consists of integers 1,2,... in some order. PERM0 is faster than PERM2. M = More information on MAT operations