(self, iszerofunc=_iszero)
return A, p
Returns A comprised of L, U (L's diag entries are 1) and
        p which is the list of the row swaps (in order).

        See Also
        ========

        LUdecomposition
        LUdecompositionFF
        LUsolve
Returns A comprised of L, U (L's diag entries are 1) and
        p which is the list of the row swaps (in order).
Returns A comprised of L U ( L s diag entries are 1 ) and p which is the list of the row swaps ( in order ) .
def LUdecomposition_Simple(self, iszerofunc=_iszero):
        """Returns A comprised of L, U (L's diag entries are 1) and
        p which is the list of the row swaps (in order).

        See Also
        ========

        LUdecomposition
        LUdecompositionFF
        LUsolve
        """
        if not self.is_square:
            raise NonSquareMatrixError("A Matrix must be square to apply LUdecomposition_Simple().")
        n = self.rows
        A = self.as_mutable()
        p = []
        # factorization
        for j in range(n):
            for i in range(j):
                for k in range(i):
                    A[i, j] = A[i, j] - A[i, k]*A[k, j]
            pivot = -1
            for i in range(j, n):
                for k in range(j):
                    A[i, j] = A[i, j] - A[i, k]*A[k, j]
                # find the first non-zero pivot, includes any expression
                if pivot == -1 and not iszerofunc(A[i, j]):
                    pivot = i
            if pivot < 0:
                # this result is based on iszerofunc's analysis of the possible pivots, so even though
                # the element may not be strictly zero, the supplied iszerofunc's evaluation gave True
                raise ValueError("No nonzero pivot found; inversion failed.")
            if pivot != j:  # row must be swapped
                A.row_swap(pivot, j)
                p.append([pivot, j])
            scale = 1 / A[j, j]
            for i in range(j + 1, n):
                A[i, j] = A[i, j]*scale
        return A, p
def LUdecomposition_Simple ( self , iszerofunc = _iszero ) : if not self . is_square : raise NonSquareMatrixError ( "A Matrix must be square to apply LUdecomposition_Simple()." ) n = self . rows A = self . as_mutable ( ) p = [ ] # factorization for j in range ( n ) : for i in range ( j ) : for k in range ( i ) : A [ i , j ] = A [ i , j ] - A [ i , k ] * A [ k , j ] pivot = - 1 for i in range ( j , n ) : for k in range ( j ) : A [ i , j ] = A [ i , j ] - A [ i , k ] * A [ k , j ] # find the first non-zero pivot, includes any expression if pivot == - 1 and not iszerofunc ( A [ i , j ] ) : pivot = i if pivot < 0 : # this result is based on iszerofunc's analysis of the possible pivots, so even though # the element may not be strictly zero, the supplied iszerofunc's evaluation gave True raise ValueError ( "No nonzero pivot found; inversion failed." ) if pivot != j : # row must be swapped A . row_swap ( pivot , j ) p . append ( [ pivot , j ] ) scale = 1 / A [ j , j ] for i in range ( j + 1 , n ) : A [ i , j ] = A [ i , j ] * scale return A , p