The LU-decomposition of a matrix is a factorization , where is a permutation matrix, is a unit lower triangular matrix (has 1’s on the diagonal), and is an upper triangular matrix.
Consider solving a linear system
where is invertible and has an LU-decomposition. The problem can be solved in operations using gaussian elimination and back substitution (let us exclude the faster algorithms). This is ok if the matrix is involved only once in such an equation. However, if is varied and stays constant, then the LU-decomposition can aid in solving the problems faster. After LU-decomposing in time, solutions to varying can be obtained in time. If is also positive definite, the linear system can be solved even faster, although only by a factor, by the Cholesky decomposition.
Because contains 1’s on the diagonal, one can pack and to the same packed matrix by throwing the diagonal of out:
This packing scheme saves memory. The packed matrix is what the decomposition object computes. This packed matrix can be used in solving linear equations by using the functions ‘solveUpperTriangular’ and ‘solveUnitLowerTriangular’. However, to make this even easier, Pastel provides an overload for ‘solveLinear’ which takes an LuDecomposition object instead of a matrix.