Column pivoting in LU factorisation

The LU algorithm fails if $A_{kk}^{(k-1)} = 0$. To avoid this and to improve numerical stability, we exchange rows so that the element of largest magnitude in column $k$ is at the pivotal position $(k,k)$. This pre-multiplies a permutation matrix.

We obtain a factorisation $$ \begin{align*} PA = LU \implies A = P^T LU \end{align*} $$ where $P$ is the product of all permutation matrices multiplied.

Example (column pivoting in LU factorisation)