def lu(ctx, A):
        # get factorization
        A, p = ctx.LU_decomp(A)
        n = A.rows
        L = ctx.matrix(n)
        U = ctx.matrix(n)
        for i in xrange(n):
            for j in xrange(n):
                if i > j:
                    L[i,j] = A[i,j]
                elif i == j:
                    L[i,j] = 1
                    U[i,j] = A[i,j]
                else:
                    U[i,j] = A[i,j]
        # calculate permutation matrix
        P = ctx.eye(n)
        for k in xrange(len(p)):
            ctx.swap_row(P, k, p[k])
        return P, L, U
Disposes of the contents of an editor.
dataset/ETHPy150Open fredrik-johansson/mpmath/mpmath/matrices/linalg.py/LinearAlgebraMethods.lu--crossover with--dataset/ETHPy150Open enthought/traitsui/traitsui/wx/code_editor.py/SourceEditor.dispose