I'm working on LU factorization that involves pivoting rows and I'm still trying to work my head around how to obtain the permutation matrices with ease.
Say I want to interchange two rows. If I have something as simple as $A = \begin{bmatrix} a & b \\ c & d \end{bmatrix}$ then I can left multiply by $P = \begin{bmatrix} p_1 & p_2 \\ p_3 & p_4 \end{bmatrix}$, form a system under these matrices so that Gaussian elimination gives me $P = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}$, satisfying \begin{equation*} \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \begin{bmatrix} a & b \\ c & d \end{bmatrix} = \begin{bmatrix} c & d \\ a & b \end{bmatrix} \end{equation*}
But how do I do this for larger matrices between any arbitrary rows? Is there a fast algorithm that allows me to do this?