Permutation matrices are a useful mathematical abstraction because they allow you to analyze using the normal rules of matrix algebra without having to introduce another type of operation.
In software, good implementations do not save the permutation matrix as a complete matrix, they store an array of permutations and directly apply it (without full matrix multiplication).
Depending on the size of the matrices and the operations and access patterns used, it may be cheaper not to apply the permutation to the data in memory in general, but simply use it as an additional indirectness. So, when you ask for (P * M)(i,j) , where P is the permutation matrix, and M is some other matrix that you rearrange, the data does not need to be reset at all, and the element access operation will look like a permutation string when accessing an item.
source share