# LU decomposition using Gaussian elimination with pivoting

From Algowiki

**Gaussian elimination with pivoting**: for a given square nonsingular matrix A, this method obtains the LU decomposition ([math]P_{1} A P_{2} = L U[/math]) of a permuted matrix [math]P_{1} A P_{2}[/math]. All the variants of the method are based on the idea of eliminating nonzero entries using elementary matrices.

There exist variants of the method with the choice of the pivot within the pivot column (column pivoting) ([math]P_{2}=E[/math]), within the pivot row (row pivoting) ([math]P_{1}=E[/math]), within the active submatrix (complete pivoting) ([math]P_{1} \ne P_{2}[/math]), and on the principal diagonal (diagonal pivoting) ([math]P_{1} = P_{2}[/math]). The first two variants are most popular and most common in program libraries.