# 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_ut_unb_var1( U, x, y ) print( 'y after =' ) print( y ) print( 'y - ( np.transpose( np.triu( U ) ) * x + yold ) = ' ) print( y - ( np.transpose( 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_ut_unb_var2( U, x, y ) print( 'y after =' ) print( y ) print( 'y - ( np.transpose( np.triu( U ) ) * x + yold ) = ' ) print( y - ( np.transpose( np.triu( U ) ) * x + yold ) )