#Insert code here... from numpy import random from numpy import matrix U = matrix( random.rand( 4,4 ) ) x = matrix( random.rand( 4,1 ) ) xold = matrix( random.rand( 4,1 ) ) # Notice that U is not upper triangular. We will only use the upper triangular part. print( 'U before =' ) print( U ) print( 'x before =' ) print( x ) import numpy as np laff.copy( x, xold ) # save the original vector x Trmv_un_unb_var1( U, x ) print( 'x after =' ) print( x ) print( np.triu( U ) * xold ) print( 'x - ( np.triu( U ) * xold ) = ' ) #np.triu makes the matrix upper triangular print( x - ( np.triu( U ) * xold ) ) #Insert code here... from numpy import random from numpy import matrix U = matrix( random.rand( 4,4 ) ) x = matrix( random.rand( 4,1 ) ) xold = matrix( random.rand( 4,1 ) ) # U is not upper triangular. We will only use the upper triangular part. print( 'U before =' ) print( U ) print( 'x before =' ) print( x ) laff.copy( x, xold ) # save the original vector y Trmv_un_unb_var2( U, x ) print( 'x after =' ) print( x ) print( 'x - ( np.triu( U ) * xold ) = ' ) #np.triu makes the matrix upper triangular print( x - ( np.triu( U ) * xold ) )