inv and pinv will invert a permutation matrix, preserving its specialness. det can be applied to a permutation matrix, efficiently calculating the sign of the permutation (which is equal to the determinant).
A permutation matrix can also be returned from the built-in functions lu and qr, if a pivoted factorization is requested.
The sparse function will convert a permutation matrix efficiently to a sparse matrix. The find function will also work efficiently with a permutation matrix, making it possible to conveniently obtain the permutation indices.
© 1996–2018 John W. Eaton
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://octave.org/doc/interpreter/Permutation-Matrix-Functions.html