Calculates the LU decomposition of a matrix.