(ctx, U, y)
return x
Solve the upper part of a LU factorized matrix for x.
Solve the upper part of a LU factorized matrix for x.
Solve the upper part of a LU factorized matrix for x .
def U_solve(ctx, U, y):
        """
        Solve the upper part of a LU factorized matrix for x.
        """
        if U.rows != U.cols:
            raise RuntimeError("need n*n matrix")
        n = U.rows
        if len(y) != n:
            raise ValueError("Value should be equal to n")
        x = copy(y)
        for i in xrange(n - 1, -1, -1):
            for j in xrange(i + 1, n):
                x[i] -= U[i,j] * x[j]
            x[i] /= U[i,i]
        return x
def U_solve ( ctx , U , y ) : if U . rows != U . cols : raise RuntimeError ( "need n*n matrix" ) n = U . rows if len ( y ) != n : raise ValueError ( "Value should be equal to n" ) x = copy ( y ) for i in xrange ( n - 1 , - 1 , - 1 ) : for j in xrange ( i + 1 , n ) : x [ i ] -= U [ i , j ] * x [ j ] x [ i ] /= U [ i , i ] return x