21.3.2 Permutation Matrix Functions

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.