(ctx, L, b, p=None)
return b
Solve the lower part of a LU factorized matrix for y.
Solve the lower part of a LU factorized matrix for y.
Solve the lower part of a LU factorized matrix for y .
def L_solve(ctx, L, b, p=None):
        """
        Solve the lower part of a LU factorized matrix for y.
        """
        if L.rows != L.cols:
            raise RuntimeError("need n*n matrix")
        n = L.rows
        if len(b) != n:
            raise ValueError("Value should be equal to n")
        b = copy(b)
        if p: # swap b according to p
            for k in xrange(0, len(p)):
                ctx.swap_row(b, k, p[k])
        # solve
        for i in xrange(1, n):
            for j in xrange(i):
                b[i] -= L[i,j] * b[j]
        return b
def L_solve ( ctx , L , b , p = None ) : if L . rows != L . cols : raise RuntimeError ( "need n*n matrix" ) n = L . rows if len ( b ) != n : raise ValueError ( "Value should be equal to n" ) b = copy ( b ) if p : # swap b according to p for k in xrange ( 0 , len ( p ) ) : ctx . swap_row ( b , k , p [ k ] ) # solve for i in xrange ( 1 , n ) : for j in xrange ( i ) : b [ i ] -= L [ i , j ] * b [ j ] return b