#Insert code here... from numpy import random from numpy import matrix U = matrix( random.rand( 4,4 ) ) x = matrix( random.rand( 4,1 ) ) y = matrix( random.rand( 4,1 ) ) yold = 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 ) print( 'y before =' ) print( y ) import numpy as np laff.copy( y, yold ) # save the original vector y Tmvmult_un_unb_var1( U, x, y ) print( 'y after =' ) print( y ) print( 'y - ( np.triu( U ) * x + yold ) = ' ) #np.triu makes the matrix upper triangular print( y - ( np.triu( U ) * x + yold ) ) #Insert code here... from numpy import random from numpy import matrix U = matrix( random.rand( 4,4 ) ) x = matrix( random.rand( 4,1 ) ) y = matrix( random.rand( 4,1 ) ) yold = 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 ) print( 'y before =' ) print( y ) laff.copy( y, yold ) # save the original vector y Tmvmult_un_unb_var2( U, x, y ) print( 'y after =' ) print( y ) print( 'y - ( np.triu( U ) * x + yold ) = ' ) #np.triu makes the matrix upper triangular print( y - ( np.triu( U ) * x + yold ) )