commit d4dce71599d16ef1423cb99aa1b81bf2e1381325
Author: Julien Lengrand-Lambert
Date: Wed May 2 09:13:08 2018 +0200
Create repo
diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..f8255c5
Binary files /dev/null and b/.DS_Store differ
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/1521Instructions.pdf b/1521Instructions.pdf
new file mode 100755
index 0000000..9711c29
Binary files /dev/null and b/1521Instructions.pdf differ
diff --git a/Answers/.DS_Store b/Answers/.DS_Store
new file mode 100644
index 0000000..d0e3bcf
Binary files /dev/null and b/Answers/.DS_Store differ
diff --git a/Answers/Week01/Dot_unb.m b/Answers/Week01/Dot_unb.m
new file mode 100755
index 0000000..93683a5
--- /dev/null
+++ b/Answers/Week01/Dot_unb.m
@@ -0,0 +1,60 @@
+
+% Copyright 2015 The University of Texas at Austin
+%
+% For licensing information see
+% http://www.cs.utexas.edu/users/flame/license.html
+%
+% Programmed by: Name of author
+% Email of author
+
+function [ alpha_out ] = Dot_unb( alpha, x, y )
+
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+
+ [ yT, ...
+ yB ] = FLA_Part_2x1( y, ...
+ 0, 'FLA_TOP' );
+
+ alpha = 0;
+
+ while ( size( xT, 1 ) < size( x, 1 ) )
+
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+
+ [ y0, ...
+ psi1, ...
+ y2 ] = FLA_Repart_2x1_to_3x1( yT, ...
+ yB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ alpha = chi1 * psi1 + alpha;
+
+ %------------------------------------------------------------%
+
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+
+ [ yT, ...
+ yB ] = FLA_Cont_with_3x1_to_2x1( y0, ...
+ psi1, ...
+ y2, ...
+ 'FLA_TOP' );
+
+ end
+
+ alpha_out = alpha;
+
+
+return
+
diff --git a/Answers/Week01/GenerateProblem.m b/Answers/Week01/GenerateProblem.m
new file mode 100755
index 0000000..cf1fcc2
--- /dev/null
+++ b/Answers/Week01/GenerateProblem.m
@@ -0,0 +1,40 @@
+disp( 'To end practice, enter Control-C' )
+
+for i=1:10
+ size_A = randi( [1,3], 2,1 );
+
+ A = randi( [-2,2], size_A(1), size_A(2) );
+ x = randi( [-2,2], size_A(2), 1 );
+
+ m_A = size( A, 1 );
+ for i=1:5
+ disp( 'evaluate' )
+ PrintMVProblem( A, x );
+
+ answ = A * x;
+ correct = 1;
+ for j=1:m_A
+ y( j,1 ) = input('');
+ if y( j, 1 ) ~= answ( j )
+ correct = 0;
+ end
+ end
+
+ if correct
+ disp('Correct!')
+ disp(' ')
+ break
+ else
+ disp('try again!' )
+ disp(' ')
+ end
+
+ if i == 5
+ disp( 'the answer is' )
+ PrintMVProblem( A, x );
+ disp( A * x )
+ end
+ end
+end
+
+
diff --git a/Answers/Week01/PrintMVProblem.m b/Answers/Week01/PrintMVProblem.m
new file mode 100755
index 0000000..5ec4ac1
--- /dev/null
+++ b/Answers/Week01/PrintMVProblem.m
@@ -0,0 +1,73 @@
+function [ error ] = PrintMVProblem( A, x )
+
+output_string = '';
+col = 1;
+
+[ m_A, n_A ] = size( A );
+[ m_x, n_x ] = size( x );
+
+for i=1:max( m_A, m_x )
+ if m_A == 1 & i== 1
+ outstring = '< ';
+ elseif i == 1
+ outstring = '/ ';
+ elseif i==m_A
+ outstring = '\ ';
+ elseif i ' ];
+ elseif i == 1
+ outstring = [ outstring '\ '];
+ elseif i==m_A
+ outstring = [ outstring '/ '];
+ elseif i' ];
+ elseif i == 1
+ outstring = [ outstring '\ ' ];
+ elseif i==m_x
+ outstring = [ outstring '/ '];
+ elseif i row axpy
+disp( 'row -> row axpy' )
+if ( isequal( laff_axpy( alpha, x', y' ), alpha * x' + y' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test column - column axpy (wrong size)
+disp( 'column - column axpy (wrong size)' )
+if ( isequal( laff_axpy( alpha, x, z ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test column - row axpy (wrong size)
+disp( 'column - row axpy (wrong size)' )
+if ( isequal( laff_axpy( alpha, x, z' ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test row -> column (wrong size)
+disp( 'row -> column (wrong size)' )
+if ( isequal( laff_axpy( alpha, x', z ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test row -> row axpy (wrong size)
+disp( 'row -> row axpy (wrong size)' )
+if ( isequal( laff_axpy( alpha, x', z' ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
\ No newline at end of file
diff --git a/Answers/Week01/test_copy.m b/Answers/Week01/test_copy.m
new file mode 100755
index 0000000..ea07702
--- /dev/null
+++ b/Answers/Week01/test_copy.m
@@ -0,0 +1,95 @@
+% Create some vectors
+x = [
+1
+2
+3
+]
+y = [
+0
+-1
+-2
+]
+z = [
+4
+3
+2
+1
+]
+
+% test column -> column copy
+disp( 'column -> column copy' )
+if ( isequal( laff_copy( x, y ), x ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test column -> row copy
+disp( 'column -> row copy' )
+if ( isequal( laff_copy( x, y' ), x' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test row -> column copy
+disp( 'row -> column copy' )
+if ( isequal( laff_copy( x', y ), x ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test row -> row copy
+disp( 'row -> row copy' )
+if ( isequal( laff_copy( x', y' ), x' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test column -> column copy (wrong size)
+disp( 'column -> column copy (wrong size)' )
+if ( isequal( laff_copy( x, z ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test column -> row copy (wrong size)
+disp( 'column -> row copy (wrong size)' )
+if ( isequal( laff_copy( x, z' ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test row -> column copy (wrong size)
+disp( 'row -> column copy (wrong size)' )
+if ( isequal( laff_copy( x', z ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test row -> row copy (wrong size)
+disp( 'row -> row copy (wrong size)' )
+if ( isequal( laff_copy( x', z' ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
\ No newline at end of file
diff --git a/Answers/Week01/test_dot.m b/Answers/Week01/test_dot.m
new file mode 100755
index 0000000..0f37a9e
--- /dev/null
+++ b/Answers/Week01/test_dot.m
@@ -0,0 +1,95 @@
+% Create some vectors
+x = [
+1
+2
+3
+]
+y = [
+0
+-1
+-2
+]
+z = [
+4
+3
+2
+1
+]
+
+% test dot product of column vector with column vector
+disp( 'dot product of column vector with column vector' )
+if ( isequal( laff_dot( x, y ), x' * y ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test dot product of column vector with row vector
+disp( 'dot product of column vector with row vector' )
+if ( isequal( laff_dot( x, y' ), x' * y ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test dot product of row vector with column vector
+disp( 'dot product of row vector with column vector' )
+if ( isequal( laff_dot( x', y ), x' * y ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test dot product of row vector with row vector
+disp( 'dot product of row vector with row vector' )
+if ( isequal( laff_dot( x', y' ), x' * y ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test dot product of column vector with column vector (wrong size)
+disp( 'dot product of column vector with column vector (wrong size)' )
+if ( isequal( laff_dot( x, z ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test dot product of column vector with row vector (wrong size)
+disp( 'dot product of column vector with row vector (wrong size)' )
+if ( isequal( laff_dot( x, z' ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test dot product of row vector with column vector (wrong size)
+disp( 'dot product of row vector with column vector (wrong size)' )
+if ( isequal( laff_dot( x', z ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test dot product of row vector with row vector (wrong size)
+disp( 'dot product of row vector with row vector (wrong size)' )
+if ( isequal( laff_dot( x', z' ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
\ No newline at end of file
diff --git a/Answers/Week01/test_norm2.m b/Answers/Week01/test_norm2.m
new file mode 100755
index 0000000..f114c67
--- /dev/null
+++ b/Answers/Week01/test_norm2.m
@@ -0,0 +1,47 @@
+% Create a vector
+x = [
+1
+2
+3
+]
+
+% test with x column vector, comparing against matlab's norm function
+disp( 'compute length of column vector' )
+if ( isequal( laff_norm2( x ), norm( x ) ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED. But could this be due to roundoff? Lets check:' )
+ disp( 'laff_norm2( x ):' )
+ disp( laff_norm2( x ) )
+ disp( 'norm( x, 2 ):' )
+ disp( norm( x, 2 ) )
+end
+
+disp( ' ' )
+
+% test with x row vector, comparing against matlab's norm function
+disp( 'compute length of row vector' )
+if ( isequal( laff_norm2( x' ), norm( x ) ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED But could this be due to roundoff? Lets check:' )
+ disp( 'laff_norm2( trans(x) ):' )
+ disp( laff_norm2( x' ) )
+ disp( 'norm( x, 2 ):' )
+ disp( norm( x, 2 ) )
+end
+
+disp( ' ' )
+
+% test with illegal x
+x = [
+ 2 3
+ -1 -2
+ ];
+
+disp( 'illegal x' )
+if ( isequal( laff_norm2( x ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
diff --git a/Answers/Week01/test_scal.m b/Answers/Week01/test_scal.m
new file mode 100755
index 0000000..42fcd69
--- /dev/null
+++ b/Answers/Week01/test_scal.m
@@ -0,0 +1,54 @@
+% Create a vector and a scalar
+x = [
+1
+2
+3
+]
+alpha = -2
+
+% test with x column vector
+disp( 'scale column vector' )
+if ( isequal( laff_scal( alpha, x ), alpha * x ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test with x row vector
+disp( 'scale row vector' )
+if ( isequal( laff_scal( alpha, x' ), alpha * x' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test with illegal alpha
+alpha = [
+ 1 2
+ 3 4
+ ];
+disp( 'illegal alpha' )
+if ( isequal( laff_scal( alpha, x ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
+
+disp( ' ' )
+
+% test with illegal x
+x = [
+ 2 3
+ -1 -2
+ ];
+alpha = 2;
+disp( 'illegal x' )
+if ( isequal( laff_scal( alpha, x ), 'FAILED' ) )
+ disp( 'TEST PASSED' )
+else
+ disp( 'TEST FAILED' )
+end
diff --git a/Answers/Week03/AllAlgorithms.pdf b/Answers/Week03/AllAlgorithms.pdf
new file mode 100755
index 0000000..7a84914
Binary files /dev/null and b/Answers/Week03/AllAlgorithms.pdf differ
diff --git a/Answers/Week03/Set_to_diagonal_matrix_unb.m b/Answers/Week03/Set_to_diagonal_matrix_unb.m
new file mode 100755
index 0000000..f96f58d
--- /dev/null
+++ b/Answers/Week03/Set_to_diagonal_matrix_unb.m
@@ -0,0 +1,50 @@
+function [ A_out ] = Set_to_diagonal_matrix_unb( A, x )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ a01 = laff_zerov( a01 );
+ alpha11 = laff_copy( chi1, alpha11 );
+ a21 = laff_zerov( a21 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
\ No newline at end of file
diff --git a/Answers/Week03/Set_to_diagonal_matrix_unb_var1.m b/Answers/Week03/Set_to_diagonal_matrix_unb_var1.m
new file mode 100755
index 0000000..20735f1
--- /dev/null
+++ b/Answers/Week03/Set_to_diagonal_matrix_unb_var1.m
@@ -0,0 +1,50 @@
+function [ A_out ] = Set_to_diagonal_matrix_unb_var1( A, x )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ a01 = laff_zerov( a01 );
+ alpha11 = laff_copy( chi1, alpha11 );
+ a21 = laff_zerov( a21 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Set_to_diagonal_matrix_unb_var2.m b/Answers/Week03/Set_to_diagonal_matrix_unb_var2.m
new file mode 100755
index 0000000..fcbac93
--- /dev/null
+++ b/Answers/Week03/Set_to_diagonal_matrix_unb_var2.m
@@ -0,0 +1,50 @@
+function [ A_out ] = Set_to_diagonal_matrix_unb_var2( A, x )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ a10t = laff_zerov( a10t );
+ alpha11 = laff_copy( chi1, alpha11 );
+ a12t = laff_zerov( a12t );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Set_to_diagonal_matrix_unb_var3.m b/Answers/Week03/Set_to_diagonal_matrix_unb_var3.m
new file mode 100755
index 0000000..79eae56
--- /dev/null
+++ b/Answers/Week03/Set_to_diagonal_matrix_unb_var3.m
@@ -0,0 +1,50 @@
+function [ A_out ] = Set_to_diagonal_matrix_unb_var3( A, x )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ a01 = laff_zerov( a01 );
+ alpha11 = laff_copy( chi1, alpha11 );
+ a10t = laff_zerov( a10t );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Set_to_diagonal_matrix_unb_var4.m b/Answers/Week03/Set_to_diagonal_matrix_unb_var4.m
new file mode 100755
index 0000000..033d456
--- /dev/null
+++ b/Answers/Week03/Set_to_diagonal_matrix_unb_var4.m
@@ -0,0 +1,50 @@
+function [ A_out ] = Set_to_diagonal_matrix_unb_var4( A, x )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ a12t = laff_zerov( a12t );
+ alpha11 = laff_copy( chi1, alpha11 );
+ a21 = laff_zerov( a21 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Set_to_identity_unb.m b/Answers/Week03/Set_to_identity_unb.m
new file mode 100755
index 0000000..b6a1522
--- /dev/null
+++ b/Answers/Week03/Set_to_identity_unb.m
@@ -0,0 +1,34 @@
+function [ A_out ] = Set_to_identity_unb( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a01 = laff_zerov( a01 );
+ alpha11 = 1;
+ a21 = laff_zerov( a21 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
\ No newline at end of file
diff --git a/Answers/Week03/Set_to_identity_unb_var1.m b/Answers/Week03/Set_to_identity_unb_var1.m
new file mode 100755
index 0000000..36c8d0e
--- /dev/null
+++ b/Answers/Week03/Set_to_identity_unb_var1.m
@@ -0,0 +1,34 @@
+function [ A_out ] = Set_to_identity_unb_var1( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a01 = laff_zerov( a01 );
+ alpha11 = laff_onev( alpha11 );
+ a21 = laff_zerov( a21 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Set_to_identity_unb_var2.m b/Answers/Week03/Set_to_identity_unb_var2.m
new file mode 100755
index 0000000..da18d05
--- /dev/null
+++ b/Answers/Week03/Set_to_identity_unb_var2.m
@@ -0,0 +1,34 @@
+function [ A_out ] = Set_to_identity_unb_var2( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a10t = laff_zerov( a10t );
+ alpha11 = laff_onev( alpha11 );
+ a12t = laff_zerov( a12t );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Set_to_identity_unb_var3.m b/Answers/Week03/Set_to_identity_unb_var3.m
new file mode 100755
index 0000000..9a6ba42
--- /dev/null
+++ b/Answers/Week03/Set_to_identity_unb_var3.m
@@ -0,0 +1,34 @@
+function [ A_out ] = Set_to_identity_unb_var3( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a01 = laff_zerov( a01 );
+ alpha11 = laff_onev( alpha11 );
+ a01t = laff_zerov( a01t );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Set_to_identity_unb_var4.m b/Answers/Week03/Set_to_identity_unb_var4.m
new file mode 100755
index 0000000..4f2890a
--- /dev/null
+++ b/Answers/Week03/Set_to_identity_unb_var4.m
@@ -0,0 +1,34 @@
+function [ A_out ] = Set_to_identity_unb_var4( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a12t = laff_zerov( a12t );
+ alpha11 = laff_onev( alpha11 );
+ a21 = laff_zerov( a21 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Set_to_lower_triangular_matrix_unb_var1.m b/Answers/Week03/Set_to_lower_triangular_matrix_unb_var1.m
new file mode 100755
index 0000000..73dea59
--- /dev/null
+++ b/Answers/Week03/Set_to_lower_triangular_matrix_unb_var1.m
@@ -0,0 +1,32 @@
+function [ A_out ] = Set_to_lower_triangular_matrix_unb_var1( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a01 := laff_zerov( a01 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Set_to_lower_triangular_matrix_unb_var2.m b/Answers/Week03/Set_to_lower_triangular_matrix_unb_var2.m
new file mode 100755
index 0000000..9a178e1
--- /dev/null
+++ b/Answers/Week03/Set_to_lower_triangular_matrix_unb_var2.m
@@ -0,0 +1,32 @@
+function [ A_out ] = Set_to_lower_triangular_matrix_unb_var2( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a12t := laff_zerov( a12t );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Set_to_unit_lower_triangular_matrix_unb_var1.m b/Answers/Week03/Set_to_unit_lower_triangular_matrix_unb_var1.m
new file mode 100755
index 0000000..109e4ed
--- /dev/null
+++ b/Answers/Week03/Set_to_unit_lower_triangular_matrix_unb_var1.m
@@ -0,0 +1,33 @@
+function [ A_out ] = Set_to_unit_lower_triangular_matrix_unb_var1( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a01 := laff_zerov( a01 );
+ alpha11 := laff_onev( alpha11 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Set_to_unit_lower_triangular_matrix_unb_var2.m b/Answers/Week03/Set_to_unit_lower_triangular_matrix_unb_var2.m
new file mode 100755
index 0000000..3f45a29
--- /dev/null
+++ b/Answers/Week03/Set_to_unit_lower_triangular_matrix_unb_var2.m
@@ -0,0 +1,33 @@
+function [ A_out ] = Set_to_unit_lower_triangular_matrix_unb_var2( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a12t := laff_zerov( a12t );
+ alpha11 := laff_onev( alpha11 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Set_to_zero_unb_var1.m b/Answers/Week03/Set_to_zero_unb_var1.m
new file mode 100755
index 0000000..19a081d
--- /dev/null
+++ b/Answers/Week03/Set_to_zero_unb_var1.m
@@ -0,0 +1,24 @@
+function [ A_out ] = Set_to_zero_unb_var1( A )
+
+ [ AL, AR ] = FLA_Part_1x2( A, ...
+ 0, 'FLA_LEFT' );
+
+ while ( size( AL, 2 ) < size( A, 2 ) )
+
+ [ A0, a1, A2 ]= FLA_Repart_1x2_to_1x3( AL, AR, ...
+ 1, 'FLA_RIGHT' );
+
+ %------------------------------------------------------------%
+
+ a1 = laff_zerov( a1 );
+
+ %------------------------------------------------------------%
+
+ [ AL, AR ] = FLA_Cont_with_1x3_to_1x2( A0, a1, A2, ...
+ 'FLA_LEFT' );
+
+ end
+
+ A_out = [ AL, AR ];
+
+return
diff --git a/Answers/Week03/Set_to_zero_unb_var2.m b/Answers/Week03/Set_to_zero_unb_var2.m
new file mode 100755
index 0000000..0131340
--- /dev/null
+++ b/Answers/Week03/Set_to_zero_unb_var2.m
@@ -0,0 +1,32 @@
+function [ A_out ] = Set_to_zero_unb_var2( A )
+
+ [ AT, ...
+ AB ] = FLA_Part_2x1( A, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( AT, 1 ) < size( A, 1 ) )
+
+ [ A0, ...
+ a1t, ...
+ A2 ] = FLA_Repart_2x1_to_3x1( AT, ...
+ AB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ a1t = laff_zerov( a1t );
+
+ %------------------------------------------------------------%
+
+ [ AT, ...
+ AB ] = FLA_Cont_with_3x1_to_2x1( A0, ...
+ a1t, ...
+ A2, ...
+ 'FLA_TOP' );
+
+ end
+
+ A_out = [ AT
+ AB ];
+
+return
diff --git a/Answers/Week03/Symmetrize_from_lower_triangle_unb_var1.m b/Answers/Week03/Symmetrize_from_lower_triangle_unb_var1.m
new file mode 100755
index 0000000..b73d93c
--- /dev/null
+++ b/Answers/Week03/Symmetrize_from_lower_triangle_unb_var1.m
@@ -0,0 +1,32 @@
+function [ A_out ] = Symmetrize_from_lower_triangle_unb_var1( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a01 = laff_copy( a10t, a01 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Symmetrize_from_lower_triangle_unb_var2.m b/Answers/Week03/Symmetrize_from_lower_triangle_unb_var2.m
new file mode 100755
index 0000000..6b2caee
--- /dev/null
+++ b/Answers/Week03/Symmetrize_from_lower_triangle_unb_var2.m
@@ -0,0 +1,32 @@
+function [ A_out ] = Symmetrize_from_lower_triangle_unb_var2( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a12t = laff_copy( a21, a12t );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Symmetrize_from_upper_triangle_unb_var1.m b/Answers/Week03/Symmetrize_from_upper_triangle_unb_var1.m
new file mode 100755
index 0000000..f0ff39e
--- /dev/null
+++ b/Answers/Week03/Symmetrize_from_upper_triangle_unb_var1.m
@@ -0,0 +1,32 @@
+function [ A_out ] = Symmetrize_from_upper_triangle_unb_var1( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a10t = laff_copy( a01, a10t );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Symmetrize_from_upper_triangle_unb_var2.m b/Answers/Week03/Symmetrize_from_upper_triangle_unb_var2.m
new file mode 100755
index 0000000..19b00eb
--- /dev/null
+++ b/Answers/Week03/Symmetrize_from_upper_triangle_unb_var2.m
@@ -0,0 +1,32 @@
+function [ A_out ] = Symmetrize_from_upper_triangle_unb_var2( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a21 = laff_copy( a12t, a21 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week03/Transpose_unb_var1.m b/Answers/Week03/Transpose_unb_var1.m
new file mode 100755
index 0000000..98cbdef
--- /dev/null
+++ b/Answers/Week03/Transpose_unb_var1.m
@@ -0,0 +1,42 @@
+function [ B_out ] = Transpose_unb_var1( A, B )
+
+ [ AL, AR ] = FLA_Part_1x2( A, ...
+ 0, 'FLA_LEFT' );
+
+ [ BT, ...
+ BB ] = FLA_Part_2x1( B, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( AL, 2 ) < size( A, 2 ) )
+
+ [ A0, a1, A2 ]= FLA_Repart_1x2_to_1x3( AL, AR, ...
+ 1, 'FLA_RIGHT' );
+
+ [ B0, ...
+ b1t, ...
+ B2 ] = FLA_Repart_2x1_to_3x1( BT, ...
+ BB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ b1t = laff_copy( a1, b1t );
+
+ %------------------------------------------------------------%
+
+ [ AL, AR ] = FLA_Cont_with_1x3_to_1x2( A0, a1, A2, ...
+ 'FLA_LEFT' );
+
+ [ BT, ...
+ BB ] = FLA_Cont_with_3x1_to_2x1( B0, ...
+ b1t, ...
+ B2, ...
+ 'FLA_TOP' );
+
+ end
+
+ B_out = [ BT
+ BB ];
+
+return
+
diff --git a/Answers/Week03/Transpose_unb_var2.m b/Answers/Week03/Transpose_unb_var2.m
new file mode 100755
index 0000000..c06b77a
--- /dev/null
+++ b/Answers/Week03/Transpose_unb_var2.m
@@ -0,0 +1,40 @@
+function [ B_out ] = Transpose_unb_var2( A, B )
+
+ [ AT, ...
+ AB ] = FLA_Part_2x1( A, ...
+ 0, 'FLA_TOP' );
+
+ [ BL, BR ] = FLA_Part_1x2( B, ...
+ 0, 'FLA_LEFT' );
+
+ while ( size( AT, 1 ) < size( A, 1 ) )
+
+ [ A0, ...
+ a1t, ...
+ A2 ] = FLA_Repart_2x1_to_3x1( AT, ...
+ AB, ...
+ 1, 'FLA_BOTTOM' );
+
+ [ B0, b1, B2 ]= FLA_Repart_1x2_to_1x3( BL, BR, ...
+ 1, 'FLA_RIGHT' );
+
+ %------------------------------------------------------------%
+
+ b1 = laff_copy( a1t, b1 );
+
+ %------------------------------------------------------------%
+
+ [ AT, ...
+ AB ] = FLA_Cont_with_3x1_to_2x1( A0, ...
+ a1t, ...
+ A2, ...
+ 'FLA_TOP' );
+
+ [ BL, BR ] = FLA_Cont_with_1x3_to_1x2( B0, b1, B2, ...
+ 'FLA_LEFT' );
+
+ end
+
+ B_out = [ BL, BR ];
+
+return
diff --git a/Answers/Week03/ZeroMatrix_unb.m b/Answers/Week03/ZeroMatrix_unb.m
new file mode 100755
index 0000000..4989e1c
--- /dev/null
+++ b/Answers/Week03/ZeroMatrix_unb.m
@@ -0,0 +1,25 @@
+function [ A_out ] = ZeroMatrix_unb( A )
+
+ [ AL, AR ] = FLA_Part_1x2( A, ...
+ 0, 'FLA_LEFT' );
+
+ while ( size( AL, 2 ) < size( A, 2 ) )
+
+ [ A0, a1, A2 ]= FLA_Repart_1x2_to_1x3( AL, AR, ...
+ 1, 'FLA_RIGHT' );
+
+ %------------------------------------------------------------%
+
+ a1 = laff_zerov( a1 );
+
+ %------------------------------------------------------------%
+
+ [ AL, AR ] = FLA_Cont_with_1x3_to_1x2( A0, a1, A2, ...
+ 'FLA_LEFT' );
+
+ end
+
+ A_out = [ AL, AR ];
+
+return
+
diff --git a/Answers/Week03/mvmult_n_unb_var1.m b/Answers/Week03/mvmult_n_unb_var1.m
new file mode 100755
index 0000000..44adbec
--- /dev/null
+++ b/Answers/Week03/mvmult_n_unb_var1.m
@@ -0,0 +1,48 @@
+function [ y_out ] = mvmult_n_unb_var1( A, x, y )
+
+ [ AT, ...
+ AB ] = FLA_Part_2x1( A, ...
+ 0, 'FLA_TOP' );
+
+ [ yT, ...
+ yB ] = FLA_Part_2x1( y, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( AT, 1 ) < size( A, 1 ) )
+
+ [ A0, ...
+ a1t, ...
+ A2 ] = FLA_Repart_2x1_to_3x1( AT, ...
+ AB, ...
+ 1, 'FLA_BOTTOM' );
+
+ [ y0, ...
+ psi1, ...
+ y2 ] = FLA_Repart_2x1_to_3x1( yT, ...
+ yB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ psi1 = laff_dots( a1t, x, psi1 );
+
+ %------------------------------------------------------------%
+
+ [ AT, ...
+ AB ] = FLA_Cont_with_3x1_to_2x1( A0, ...
+ a1t, ...
+ A2, ...
+ 'FLA_TOP' );
+
+ [ yT, ...
+ yB ] = FLA_Cont_with_3x1_to_2x1( y0, ...
+ psi1, ...
+ y2, ...
+ 'FLA_TOP' );
+
+ end
+
+ y_out = [ yT
+ yB ];
+
+return
diff --git a/Answers/Week03/mvmult_n_unb_var2.m b/Answers/Week03/mvmult_n_unb_var2.m
new file mode 100755
index 0000000..8058cf8
--- /dev/null
+++ b/Answers/Week03/mvmult_n_unb_var2.m
@@ -0,0 +1,40 @@
+function [ y_out ] = mvmult_n_unb_var2( A, x, y )
+
+ [ AL, AR ] = FLA_Part_1x2( A, ...
+ 0, 'FLA_LEFT' );
+
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( AL, 2 ) < size( A, 2 ) )
+
+ [ A0, a1, A2 ]= FLA_Repart_1x2_to_1x3( AL, AR, ...
+ 1, 'FLA_RIGHT' );
+
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ y = laff_axpy( chi1, a1, y );
+
+ %------------------------------------------------------------%
+
+ [ AL, AR ] = FLA_Cont_with_1x3_to_1x2( A0, a1, A2, ...
+ 'FLA_LEFT' );
+
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+
+ end
+
+ y_out = y;
+
+return
diff --git a/Answers/Week03/mvmult_unb_var1.m b/Answers/Week03/mvmult_unb_var1.m
new file mode 100755
index 0000000..decbaa0
--- /dev/null
+++ b/Answers/Week03/mvmult_unb_var1.m
@@ -0,0 +1,48 @@
+function [ y_out ] = Mvmult_n_unb_var1( A, x, y )
+
+ [ AT, ...
+ AB ] = FLA_Part_2x1( A, ...
+ 0, 'FLA_TOP' );
+
+ [ yT, ...
+ yB ] = FLA_Part_2x1( y, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( AT, 1 ) < size( A, 1 ) )
+
+ [ A0, ...
+ a1t, ...
+ A2 ] = FLA_Repart_2x1_to_3x1( AT, ...
+ AB, ...
+ 1, 'FLA_BOTTOM' );
+
+ [ y0, ...
+ psi1, ...
+ y2 ] = FLA_Repart_2x1_to_3x1( yT, ...
+ yB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ psi1 = laff_dots( a1t, x, psi1 );
+
+ %------------------------------------------------------------%
+
+ [ AT, ...
+ AB ] = FLA_Cont_with_3x1_to_2x1( A0, ...
+ a1t, ...
+ A2, ...
+ 'FLA_TOP' );
+
+ [ yT, ...
+ yB ] = FLA_Cont_with_3x1_to_2x1( y0, ...
+ psi1, ...
+ y2, ...
+ 'FLA_TOP' );
+
+ end
+
+ y_out = [ yT
+ yB ];
+
+return
diff --git a/Answers/Week03/mvmult_unb_var2.m b/Answers/Week03/mvmult_unb_var2.m
new file mode 100755
index 0000000..1ed907b
--- /dev/null
+++ b/Answers/Week03/mvmult_unb_var2.m
@@ -0,0 +1,42 @@
+\begin{verbatim}
+function [ y_out ] = Mvmult_n_unb_var2( A, x, y )
+
+ [ AL, AR ] = FLA_Part_1x2( A, ...
+ 0, 'FLA_LEFT' );
+
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( AL, 2 ) < size( A, 2 ) )
+
+ [ A0, a1, A2 ]= FLA_Repart_1x2_to_1x3( AL, AR, ...
+ 1, 'FLA_RIGHT' );
+
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ y = laff_axpy( chi1, a1, y );
+
+ %------------------------------------------------------------%
+
+ [ AL, AR ] = FLA_Cont_with_1x3_to_1x2( A0, a1, A2, ...
+ 'FLA_LEFT' );
+
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+
+ end
+
+ y_out = y;
+
+return
+\end{verbatim}
\ No newline at end of file
diff --git a/Answers/Week04/Mvmult_t_unb_var1.m b/Answers/Week04/Mvmult_t_unb_var1.m
new file mode 100755
index 0000000..d946742
--- /dev/null
+++ b/Answers/Week04/Mvmult_t_unb_var1.m
@@ -0,0 +1,41 @@
+function [ y_out ] = Mvmult_t_unb_var1( A, x, y )
+
+ [ AL, AR ] = FLA_Part_1x2( A, ...
+ 0, 'FLA_LEFT' );
+
+ [ yT, ...
+ yB ] = FLA_Part_2x1( y, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( AL, 2 ) < size( A, 2 ) )
+
+ [ A0, a1, A2 ]= FLA_Repart_1x2_to_1x3( AL, AR, ...
+ 1, 'FLA_RIGHT' );
+
+ [ y0, ...
+ psi1, ...
+ y2 ] = FLA_Repart_2x1_to_3x1( yT, ...
+ yB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ psi1 = laff_dots( a1, x, psi1 );
+
+ %------------------------------------------------------------%
+
+ [ AL, AR ] = FLA_Cont_with_1x3_to_1x2( A0, a1, A2, ...
+ 'FLA_LEFT' );
+
+ [ yT, ...
+ yB ] = FLA_Cont_with_3x1_to_2x1( y0, ...
+ psi1, ...
+ y2, ...
+ 'FLA_TOP' );
+
+ end
+
+ y_out = [ yT
+ yB ];
+
+return
\ No newline at end of file
diff --git a/Answers/Week04/Mvmult_t_unb_var2.m b/Answers/Week04/Mvmult_t_unb_var2.m
new file mode 100755
index 0000000..81d6204
--- /dev/null
+++ b/Answers/Week04/Mvmult_t_unb_var2.m
@@ -0,0 +1,48 @@
+function [ y_out ] = Mvmult_t_unb_var2( A, x, y )
+
+ [ AT, ...
+ AB ] = FLA_Part_2x1( A, ...
+ 0, 'FLA_TOP' );
+
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( AT, 1 ) < size( A, 1 ) )
+
+ [ A0, ...
+ a1t, ...
+ A2 ] = FLA_Repart_2x1_to_3x1( AT, ...
+ AB, ...
+ 1, 'FLA_BOTTOM' );
+
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ y = laff_axpy( chi1, a1t, y );
+
+ %------------------------------------------------------------%
+
+ [ AT, ...
+ AB ] = FLA_Cont_with_3x1_to_2x1( A0, ...
+ a1t, ...
+ A2, ...
+ 'FLA_TOP' );
+
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+
+ end
+
+ y_out = y;
+
+
+return
diff --git a/Answers/Week04/Mvmult_unb_var1B.m b/Answers/Week04/Mvmult_unb_var1B.m
new file mode 100755
index 0000000..cafc5b1
--- /dev/null
+++ b/Answers/Week04/Mvmult_unb_var1B.m
@@ -0,0 +1,55 @@
+function [ y_out ] = Mvmult_n_unb_var1B( A, x, y )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Part_2x1( y, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+ [ y0, ...
+ psi1, ...
+ y2 ] = FLA_Repart_2x1_to_3x1( yT, ...
+ yB, ...
+ 1, 'FLA_BOTTOM' );
+ %------------------------------------------------------------%
+
+ psi1 = laff_dots( a10t, x0, psi1 );
+ psi1 = laff_dots( alpha11, chi1, psi1 );
+ psi1 = laff_dots( a12t, x2, psi1 );
+ %------------------------------------------------------------%
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Cont_with_3x1_to_2x1( y0, ...
+ psi1, ...
+ y2, ...
+ 'FLA_TOP' );
+ end
+
+ y_out = [ yT
+ yB ];
+return
diff --git a/Answers/Week04/Mvmult_unb_var2B.m b/Answers/Week04/Mvmult_unb_var2B.m
new file mode 100755
index 0000000..80b9e9a
--- /dev/null
+++ b/Answers/Week04/Mvmult_unb_var2B.m
@@ -0,0 +1,56 @@
+function [ y_out ] = Mvmult_n_unb_var2B( A, x, y )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Part_2x1( y, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+ [ y0, ...
+ psi1, ...
+ y2 ] = FLA_Repart_2x1_to_3x1( yT, ...
+ yB, ...
+ 1, 'FLA_BOTTOM' );
+ %------------------------------------------------------------%
+
+ y0 = laff_axpy( chi1, a01, y0 );
+ psi1 = laff_axpy( chi1, alpha11, psi1 );
+ y2 = laff_axpy( chi1, a21, y2 );
+
+ %------------------------------------------------------------%
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Cont_with_3x1_to_2x1( y0, ...
+ psi1, ...
+ y2, ...
+ 'FLA_TOP' );
+ end
+
+ y_out = [ yT
+ yB ];
+return
diff --git a/Answers/Week04/Symv_l_unb_var1.m b/Answers/Week04/Symv_l_unb_var1.m
new file mode 100755
index 0000000..c831022
--- /dev/null
+++ b/Answers/Week04/Symv_l_unb_var1.m
@@ -0,0 +1,59 @@
+function [ y_out ] = Symv_l_unb_var1( A, x, y )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Part_2x1( y, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+ [ y0, ...
+ psi1, ...
+ y2 ] = FLA_Repart_2x1_to_3x1( yT, ...
+ yB, ...
+ 1, 'FLA_BOTTOM' );
+ %------------------------------------------------------------%
+
+ psi1 = laff_dots( a10t, x0, psi1 );
+ psi1 = laff_dots( alpha11, chi1, psi1 );
+ psi1 = laff_dots( a21, x2, psi1 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Cont_with_3x1_to_2x1( y0, ...
+ psi1, ...
+ y2, ...
+ 'FLA_TOP' );
+ end
+
+ y_out = [ yT
+ yB ];
+
+return
+
diff --git a/Answers/Week04/Symv_l_unb_var2.m b/Answers/Week04/Symv_l_unb_var2.m
new file mode 100755
index 0000000..e04ce24
--- /dev/null
+++ b/Answers/Week04/Symv_l_unb_var2.m
@@ -0,0 +1,58 @@
+function [ y_out ] = Symv_l_unb_var2( A, x, y )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Part_2x1( y, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+ [ y0, ...
+ psi1, ...
+ y2 ] = FLA_Repart_2x1_to_3x1( yT, ...
+ yB, ...
+ 1, 'FLA_BOTTOM' );
+ %------------------------------------------------------------%
+
+ y0 = laff_axpy( chi1, a10t, y0 );
+ psi1 = laff_axpy( chi1, alpha11, psi1 );
+ y2 = laff_axpy( chi1, a21, y2 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Cont_with_3x1_to_2x1( y0, ...
+ psi1, ...
+ y2, ...
+ 'FLA_TOP' );
+ end
+
+ y_out = [ yT
+ yB ];
+
+return
diff --git a/Answers/Week04/Symv_u_unb_var1.m b/Answers/Week04/Symv_u_unb_var1.m
new file mode 100755
index 0000000..ef1a1a2
--- /dev/null
+++ b/Answers/Week04/Symv_u_unb_var1.m
@@ -0,0 +1,58 @@
+function [ y_out ] = Symv_u_unb_var1( A, x, y )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Part_2x1( y, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+ [ y0, ...
+ psi1, ...
+ y2 ] = FLA_Repart_2x1_to_3x1( yT, ...
+ yB, ...
+ 1, 'FLA_BOTTOM' );
+ %------------------------------------------------------------%
+
+ psi1 = laff_dots( a01, x0, psi1 );
+ psi1 = laff_dots( alpha11, chi1, psi1 );
+ psi1 = laff_dots( a12t, x2, psi1 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Cont_with_3x1_to_2x1( y0, ...
+ psi1, ...
+ y2, ...
+ 'FLA_TOP' );
+ end
+
+ y_out = [ yT
+ yB ];
+
+return
diff --git a/Answers/Week04/Symv_u_unb_var2.m b/Answers/Week04/Symv_u_unb_var2.m
new file mode 100755
index 0000000..6f7b98b
--- /dev/null
+++ b/Answers/Week04/Symv_u_unb_var2.m
@@ -0,0 +1,58 @@
+function [ y_out ] = Symv_u_unb_var2( A, x, y )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Part_2x1( y, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+ [ y0, ...
+ psi1, ...
+ y2 ] = FLA_Repart_2x1_to_3x1( yT, ...
+ yB, ...
+ 1, 'FLA_BOTTOM' );
+ %------------------------------------------------------------%
+
+ y0 = laff_axpy( chi1, a01, y0 );
+ psi1 = laff_axpy( chi1, alpha11, psi1 );
+ y2 = laff_axpy( chi1, a12t, y2 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Cont_with_3x1_to_2x1( y0, ...
+ psi1, ...
+ y2, ...
+ 'FLA_TOP' );
+ end
+
+ y_out = [ yT
+ yB ];
+
+return
diff --git a/Answers/Week04/Symv_u_unb_var3.m b/Answers/Week04/Symv_u_unb_var3.m
new file mode 100755
index 0000000..e31d19d
--- /dev/null
+++ b/Answers/Week04/Symv_u_unb_var3.m
@@ -0,0 +1,58 @@
+function [ y_out ] = Symv_u_unb_var3( A, x, y )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Part_2x1( y, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+ [ y0, ...
+ psi1, ...
+ y2 ] = FLA_Repart_2x1_to_3x1( yT, ...
+ yB, ...
+ 1, 'FLA_BOTTOM' );
+ %------------------------------------------------------------%
+
+ y0 = laff_axpy( chi1, a01, y0 );
+ psi1 = laff_axpy( chi1, alpha11, psi1 );
+ psi1 = laff_dots( a01, x0, psi1 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Cont_with_3x1_to_2x1( y0, ...
+ psi1, ...
+ y2, ...
+ 'FLA_TOP' );
+ end
+
+ y_out = [ yT
+ yB ];
+
+return
diff --git a/Answers/Week04/Trmv_ln_unb_var1.m b/Answers/Week04/Trmv_ln_unb_var1.m
new file mode 100755
index 0000000..268c518
--- /dev/null
+++ b/Answers/Week04/Trmv_ln_unb_var1.m
@@ -0,0 +1,50 @@
+function [ x_out ] = Trmv_ln_unb_var1( L, x )
+
+ [ LTL, LTR, ...
+ LBL, LBR ] = FLA_Part_2x2( L, ...
+ 0, 0, 'FLA_BR' );
+
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_BOTTOM' );
+
+ while ( size( LBR, 1 ) < size( L, 1 ) )
+
+ [ L00, l01, L02, ...
+ l10t, lambda11, l12t, ...
+ L20, l21, L22 ] = FLA_Repart_2x2_to_3x3( LTL, LTR, ...
+ LBL, LBR, ...
+ 1, 1, 'FLA_TL' );
+
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_TOP' );
+
+ %------------------------------------------------------------%
+
+ chi1 = lambda11 * chi1;
+ chi1 = l10t * x0 + chi1;
+
+ %------------------------------------------------------------%
+
+ [ LTL, LTR, ...
+ LBL, LBR ] = FLA_Cont_with_3x3_to_2x2( L00, l01, L02, ...
+ l10t, lambda11, l12t, ...
+ L20, l21, L22, ...
+ 'FLA_BR' );
+
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_BOTTOM' );
+
+ end
+
+ x_out = [ xT
+ xB ];
+
+return
+
diff --git a/Answers/Week04/Trmv_ln_unb_var2.m b/Answers/Week04/Trmv_ln_unb_var2.m
new file mode 100755
index 0000000..696d559
--- /dev/null
+++ b/Answers/Week04/Trmv_ln_unb_var2.m
@@ -0,0 +1,50 @@
+function [ x_out ] = Trmv_ln_unb_var2( L, x )
+
+ [ LTL, LTR, ...
+ LBL, LBR ] = FLA_Part_2x2( L, ...
+ 0, 0, 'FLA_BR' );
+
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_BOTTOM' );
+
+ while ( size( LBR, 1 ) < size( L, 1 ) )
+
+ [ L00, l01, L02, ...
+ l10t, lambda11, l12t, ...
+ L20, l21, L22 ] = FLA_Repart_2x2_to_3x3( LTL, LTR, ...
+ LBL, LBR, ...
+ 1, 1, 'FLA_TL' );
+
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_TOP' );
+
+ %------------------------------------------------------------%
+
+ x2 = chi1 * l21 + x2;
+ chi1 = lambda11 * chi1;
+
+ %------------------------------------------------------------%
+
+ [ LTL, LTR, ...
+ LBL, LBR ] = FLA_Cont_with_3x3_to_2x2( L00, l01, L02, ...
+ l10t, lambda11, l12t, ...
+ L20, l21, L22, ...
+ 'FLA_BR' );
+
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_BOTTOM' );
+
+ end
+
+ x_out = [ xT
+ xB ];
+
+return
+
diff --git a/Answers/Week04/Trmv_un_unb_var1.m b/Answers/Week04/Trmv_un_unb_var1.m
new file mode 100755
index 0000000..4cf3b72
--- /dev/null
+++ b/Answers/Week04/Trmv_un_unb_var1.m
@@ -0,0 +1,43 @@
+function [ x_out ] = Trmv_un_unb_var1( U, x )
+
+ [ UTL, UTR, ...
+ UBL, UBR ] = FLA_Part_2x2( U, ...
+ 0, 0, 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( UTL, 1 ) < size( U, 1 ) )
+
+ [ U00, u01, U02, ...
+ u10t, upsilon11, u12t, ...
+ U20, u21, U22 ] = FLA_Repart_2x2_to_3x3( UTL, UTR, ...
+ UBL, UBR, ...
+ 1, 1, 'FLA_BR' );
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+ %------------------------------------------------------------%
+
+ chi1 = laff_dot( upsilon11, chi1 );
+ chi1 = laff_dots( u12t, x2, chi1 );
+
+ %------------------------------------------------------------%
+ [ UTL, UTR, ...
+ UBL, UBR ] = FLA_Cont_with_3x3_to_2x2( U00, u01, U02, ...
+ u10t, upsilon11, u12t, ...
+ U20, u21, U22, ...
+ 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+ end
+
+ x_out = [ xT
+ xB ];
+
+return
\ No newline at end of file
diff --git a/Answers/Week04/Trmv_un_unb_var2.m b/Answers/Week04/Trmv_un_unb_var2.m
new file mode 100755
index 0000000..66de68b
--- /dev/null
+++ b/Answers/Week04/Trmv_un_unb_var2.m
@@ -0,0 +1,43 @@
+function [ x_out ] = Trmv_un_unb_var2( U, x )
+
+ [ UTL, UTR, ...
+ UBL, UBR ] = FLA_Part_2x2( U, ...
+ 0, 0, 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( UTL, 1 ) < size( U, 1 ) )
+
+ [ U00, u01, U02, ...
+ u10t, upsilon11, u12t, ...
+ U20, u21, U22 ] = FLA_Repart_2x2_to_3x3( UTL, UTR, ...
+ UBL, UBR, ...
+ 1, 1, 'FLA_BR' );
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+ %------------------------------------------------------------%
+
+ x0 = laff_axpy( chi1, u01, x0 );
+ chi1 = laff_dot( upsilon11, chi1 );
+
+ %------------------------------------------------------------%
+ [ UTL, UTR, ...
+ UBL, UBR ] = FLA_Cont_with_3x3_to_2x2( U00, u01, U02, ...
+ u10t, upsilon11, u12t, ...
+ U20, u21, U22, ...
+ 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+ end
+
+ x_out = [ xT
+ xB ];
+
+return
\ No newline at end of file
diff --git a/Answers/Week04/Trmvp_ln_unb_var1.m b/Answers/Week04/Trmvp_ln_unb_var1.m
new file mode 100755
index 0000000..140fde9
--- /dev/null
+++ b/Answers/Week04/Trmvp_ln_unb_var1.m
@@ -0,0 +1,62 @@
+function [ y_out ] = Trmvp_ln_unb_var1( L, x, y )
+
+ [ LTL, LTR, ...
+ LBL, LBR ] = FLA_Part_2x2( L, ...
+ 0, 0, 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Part_2x1( y, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( LTL, 1 ) < size( L, 1 ) )
+
+ [ L00, l01, L02, ...
+ l10t, lambda11, l12t, ...
+ L20, l21, L22 ] = FLA_Repart_2x2_to_3x3( LTL, LTR, ...
+ LBL, LBR, ...
+ 1, 1, 'FLA_BR' );
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+ [ y0, ...
+ psi1, ...
+ y2 ] = FLA_Repart_2x1_to_3x1( yT, ...
+ yB, ...
+ 1, 'FLA_BOTTOM' );
+ %------------------------------------------------------------%
+
+ psi1 = laff_dots( l10t, x0, psi1 );
+ psi1 = laff_dots( lambda11, chi1, psi1 );
+
+ %------------------------------------------------------------%
+
+ [ LTL, LTR, ...
+ LBL, LBR ] = FLA_Cont_with_3x3_to_2x2( L00, l01, L02, ...
+ l10t, lambda11, l12t, ...
+ L20, l21, L22, ...
+ 'FLA_TL' );
+
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+
+ [ yT, ...
+ yB ] = FLA_Cont_with_3x1_to_2x1( y0, ...
+ psi1, ...
+ y2, ...
+ 'FLA_TOP' );
+
+ end
+
+ y_out = [ yT
+ yB ];
+
+return
+
+
diff --git a/Answers/Week04/Trmvp_un_unb_var1.m b/Answers/Week04/Trmvp_un_unb_var1.m
new file mode 100755
index 0000000..de208b7
--- /dev/null
+++ b/Answers/Week04/Trmvp_un_unb_var1.m
@@ -0,0 +1,56 @@
+function [ y_out ] = Trmvp_un_unb_var1( U, x, y )
+
+ [ UTL, UTR, ...
+ UBL, UBR ] = FLA_Part_2x2( U, ...
+ 0, 0, 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Part_2x1( y, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( UTL, 1 ) < size( U, 1 ) )
+
+ [ U00, u01, U02, ...
+ u10t, upsilon11, u12t, ...
+ U20, u21, U22 ] = FLA_Repart_2x2_to_3x3( UTL, UTR, ...
+ UBL, UBR, ...
+ 1, 1, 'FLA_BR' );
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+ [ y0, ...
+ psi1, ...
+ y2 ] = FLA_Repart_2x1_to_3x1( yT, ...
+ yB, ...
+ 1, 'FLA_BOTTOM' );
+ %------------------------------------------------------------%
+
+ psi1 = laff_dots( upsilon11, chi1, psi1 );
+ psi1 = laff_dots( u12t, x2, psi1 );
+
+ %------------------------------------------------------------%
+ [ UTL, UTR, ...
+ UBL, UBR ] = FLA_Cont_with_3x3_to_2x2( U00, u01, U02, ...
+ u10t, upsilon11, u12t, ...
+ U20, u21, U22, ...
+ 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Cont_with_3x1_to_2x1( y0, ...
+ psi1, ...
+ y2, ...
+ 'FLA_TOP' );
+ end
+
+ y_out = [ yT
+ yB ];
+
+return
\ No newline at end of file
diff --git a/Answers/Week04/Trmvp_un_unb_var2.m b/Answers/Week04/Trmvp_un_unb_var2.m
new file mode 100755
index 0000000..71d1e07
--- /dev/null
+++ b/Answers/Week04/Trmvp_un_unb_var2.m
@@ -0,0 +1,56 @@
+function [ y_out ] = Trmvp_un_unb_var2( U, x, y )
+
+ [ UTL, UTR, ...
+ UBL, UBR ] = FLA_Part_2x2( U, ...
+ 0, 0, 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Part_2x1( x, ...
+ 0, 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Part_2x1( y, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( UTL, 1 ) < size( U, 1 ) )
+
+ [ U00, u01, U02, ...
+ u10t, upsilon11, u12t, ...
+ U20, u21, U22 ] = FLA_Repart_2x2_to_3x3( UTL, UTR, ...
+ UBL, UBR, ...
+ 1, 1, 'FLA_BR' );
+ [ x0, ...
+ chi1, ...
+ x2 ] = FLA_Repart_2x1_to_3x1( xT, ...
+ xB, ...
+ 1, 'FLA_BOTTOM' );
+ [ y0, ...
+ psi1, ...
+ y2 ] = FLA_Repart_2x1_to_3x1( yT, ...
+ yB, ...
+ 1, 'FLA_BOTTOM' );
+ %------------------------------------------------------------%
+
+ y0 = laff_axpy( chi1, u01, y0 );
+ psi1 = laff_axpy( chi1, upsilon11, psi1 );
+
+ %------------------------------------------------------------%
+ [ UTL, UTR, ...
+ UBL, UBR ] = FLA_Cont_with_3x3_to_2x2( U00, u01, U02, ...
+ u10t, upsilon11, u12t, ...
+ U20, u21, U22, ...
+ 'FLA_TL' );
+ [ xT, ...
+ xB ] = FLA_Cont_with_3x1_to_2x1( x0, ...
+ chi1, ...
+ x2, ...
+ 'FLA_TOP' );
+ [ yT, ...
+ yB ] = FLA_Cont_with_3x1_to_2x1( y0, ...
+ psi1, ...
+ y2, ...
+ 'FLA_TOP' );
+ end
+
+ y_out = [ yT
+ yB ];
+
+return
\ No newline at end of file
diff --git a/Answers/Week04/Week4Algorithms.pdf b/Answers/Week04/Week4Algorithms.pdf
new file mode 100755
index 0000000..bfe963e
Binary files /dev/null and b/Answers/Week04/Week4Algorithms.pdf differ
diff --git a/Answers/Week04/test_Mvmult_t_unb_var1.m b/Answers/Week04/test_Mvmult_t_unb_var1.m
new file mode 100755
index 0000000..b1ea46d
--- /dev/null
+++ b/Answers/Week04/test_Mvmult_t_unb_var1.m
@@ -0,0 +1,10 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+y = randi( [ -2, 2 ], 4, 1 )
+
+if ( isequal( Mvmult_t_unb_var1( A, x, y ), A' * x + y ) )
+ disp( 'Mvmult_t_unb_var1 appears to be correct' )
+else
+ disp( 'Mvmult_t_unb_var1 has a problem' )
+end
+
diff --git a/Answers/Week04/test_Mvmult_t_unb_var2.m b/Answers/Week04/test_Mvmult_t_unb_var2.m
new file mode 100755
index 0000000..4051638
--- /dev/null
+++ b/Answers/Week04/test_Mvmult_t_unb_var2.m
@@ -0,0 +1,10 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+y = randi( [ -2, 2 ], 4, 1 )
+
+if ( isequal( Mvmult_t_unb_var2( A, x, y ), A' * x + y ) )
+ disp( 'Mvmult_t_unb_var2 appears to be correct' )
+else
+ disp( 'Mvmult_t_unb_var2 has a problem' )
+end
+
diff --git a/Answers/Week04/test_Mvmult_unb_var1B.m b/Answers/Week04/test_Mvmult_unb_var1B.m
new file mode 100755
index 0000000..241c411
--- /dev/null
+++ b/Answers/Week04/test_Mvmult_unb_var1B.m
@@ -0,0 +1,10 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+y = randi( [ -2, 2 ], 4, 1 )
+
+if ( isequal( Mvmult_n_unb_var1B( A, x, y ), A * x + y ) )
+ disp( 'Mvmult_unb_var1B appears to be correct' )
+else
+ disp( 'Mvmult_unb_var1B has a problem' )
+end
+
diff --git a/Answers/Week04/test_Mvmult_unb_var2B.m b/Answers/Week04/test_Mvmult_unb_var2B.m
new file mode 100755
index 0000000..6116e9a
--- /dev/null
+++ b/Answers/Week04/test_Mvmult_unb_var2B.m
@@ -0,0 +1,10 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+y = randi( [ -2, 2 ], 4, 1 )
+
+if ( isequal( Mvmult_n_unb_var2B( A, x, y ), A * x + y ) )
+ disp( 'Mvmult_unb_var2B appears to be correct' )
+else
+ disp( 'Mvmult_unb_var2B has a problem' )
+end
+
diff --git a/Answers/Week04/test_Symv_l_unb_var1.m b/Answers/Week04/test_Symv_l_unb_var1.m
new file mode 100755
index 0000000..5f01e69
--- /dev/null
+++ b/Answers/Week04/test_Symv_l_unb_var1.m
@@ -0,0 +1,12 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+y = randi( [ -2, 2 ], 4, 1 )
+
+Asymm = tril( A ) + tril( A, -1 )';
+
+if ( isequal( Symv_l_unb_var1( A, x, y ), Asymm * x + y ) )
+ disp( 'Symv_l_unb_var1 appears to be correct' )
+else
+ disp( 'Symv_l_unb_var1 has a problem' )
+end
+
diff --git a/Answers/Week04/test_Symv_l_unb_var2.m b/Answers/Week04/test_Symv_l_unb_var2.m
new file mode 100755
index 0000000..cfeb42f
--- /dev/null
+++ b/Answers/Week04/test_Symv_l_unb_var2.m
@@ -0,0 +1,12 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+y = randi( [ -2, 2 ], 4, 1 )
+
+Asymm = tril( A ) + tril( A, -1 )';
+
+if ( isequal( Symv_l_unb_var2( A, x, y ), Asymm * x + y ) )
+ disp( 'Symv_l_unb_var2 appears to be correct' )
+else
+ disp( 'Symv_l_unb_var2 has a problem' )
+end
+
diff --git a/Answers/Week04/test_Symv_u_unb_var1.m b/Answers/Week04/test_Symv_u_unb_var1.m
new file mode 100755
index 0000000..9fbbc7d
--- /dev/null
+++ b/Answers/Week04/test_Symv_u_unb_var1.m
@@ -0,0 +1,12 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+y = randi( [ -2, 2 ], 4, 1 )
+
+Asymm = triu( A ) + triu( A, 1 )';
+
+if ( isequal( Symv_u_unb_var1( A, x, y ), Asymm * x + y ) )
+ disp( 'Symv_u_unb_var1 appears to be correct' )
+else
+ disp( 'Symv_u_unb_var1 has a problem' )
+end
+
diff --git a/Answers/Week04/test_Symv_u_unb_var2.m b/Answers/Week04/test_Symv_u_unb_var2.m
new file mode 100755
index 0000000..57116f4
--- /dev/null
+++ b/Answers/Week04/test_Symv_u_unb_var2.m
@@ -0,0 +1,12 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+y = randi( [ -2, 2 ], 4, 1 )
+
+Asymm = triu( A ) + triu( A, 1 )';
+
+if ( isequal( Symv_u_unb_var2( A, x, y ), Asymm * x + y ) )
+ disp( 'Symv_u_unb_var2 appears to be correct' )
+else
+ disp( 'Symv_u_unb_var2 has a problem' )
+end
+
diff --git a/Answers/Week04/test_Symv_u_unb_var3.m b/Answers/Week04/test_Symv_u_unb_var3.m
new file mode 100755
index 0000000..cfe6c88
--- /dev/null
+++ b/Answers/Week04/test_Symv_u_unb_var3.m
@@ -0,0 +1,12 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+y = randi( [ -2, 2 ], 4, 1 )
+
+Asymm = triu( A ) + triu( A, 1 )';
+
+if ( isequal( Symv_u_unb_var3( A, x, y ), Asymm * x + y ) )
+ disp( 'Symv_u_unb_var3 appears to be correct' )
+else
+ disp( 'Symv_u_unb_var3 has a problem' )
+end
+
diff --git a/Answers/Week04/test_Trmv_ln_unb_var1.m b/Answers/Week04/test_Trmv_ln_unb_var1.m
new file mode 100755
index 0000000..0c440be
--- /dev/null
+++ b/Answers/Week04/test_Trmv_ln_unb_var1.m
@@ -0,0 +1,9 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+
+if ( isequal( Trmv_ln_unb_var1( A, x ), tril( A ) * x ) )
+ disp( 'Trmv_ln_unb_var1 appears to be correct' )
+else
+ disp( 'Trmv_ln_unb_var1 has a problem' )
+end
+
diff --git a/Answers/Week04/test_Trmv_ln_unb_var2.m b/Answers/Week04/test_Trmv_ln_unb_var2.m
new file mode 100755
index 0000000..711fbfe
--- /dev/null
+++ b/Answers/Week04/test_Trmv_ln_unb_var2.m
@@ -0,0 +1,9 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+
+if ( isequal( Trmv_ln_unb_var2( A, x ), tril( A ) * x ) )
+ disp( 'Trmv_ln_unb_var2 appears to be correct' )
+else
+ disp( 'Trmv_ln_unb_var2 has a problem' )
+end
+
diff --git a/Answers/Week04/test_Trmv_un_unb_var1.m b/Answers/Week04/test_Trmv_un_unb_var1.m
new file mode 100755
index 0000000..29bbec9
--- /dev/null
+++ b/Answers/Week04/test_Trmv_un_unb_var1.m
@@ -0,0 +1,9 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+
+if ( isequal( Trmv_un_unb_var1( A, x ), triu( A ) * x ) )
+ disp( 'Trmv_un_unb_var1 appears to be correct' )
+else
+ disp( 'Trmv_un_unb_var1 has a problem' )
+end
+
diff --git a/Answers/Week04/test_Trmv_un_unb_var2.m b/Answers/Week04/test_Trmv_un_unb_var2.m
new file mode 100755
index 0000000..3d94d0b
--- /dev/null
+++ b/Answers/Week04/test_Trmv_un_unb_var2.m
@@ -0,0 +1,9 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+
+if ( isequal( Trmv_un_unb_var2( A, x ), triu( A ) * x ) )
+ disp( 'Trmv_un_unb_var2 appears to be correct' )
+else
+ disp( 'Trmv_un_unb_var2 has a problem' )
+end
+
diff --git a/Answers/Week04/test_Trmvp_ln_unb_var1.m b/Answers/Week04/test_Trmvp_ln_unb_var1.m
new file mode 100755
index 0000000..e0fbe62
--- /dev/null
+++ b/Answers/Week04/test_Trmvp_ln_unb_var1.m
@@ -0,0 +1,10 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+y = randi( [ -2, 2 ], 4, 1 )
+
+if ( isequal( Trmvp_ln_unb_var1( A, x, y ), tril( A ) * x + y ) )
+ disp( 'Trmvp_ln_unb_var1 appears to be correct' )
+else
+ disp( 'Trmvp_ln_unb_var1 has a problem' )
+end
+
diff --git a/Answers/Week04/test_Trmvp_ln_unb_var2.m b/Answers/Week04/test_Trmvp_ln_unb_var2.m
new file mode 100755
index 0000000..77fd9ba
--- /dev/null
+++ b/Answers/Week04/test_Trmvp_ln_unb_var2.m
@@ -0,0 +1,10 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+y = randi( [ -2, 2 ], 4, 1 )
+
+if ( isequal( Trmvp_ln_unb_var2( A, x, y ), tril( A ) * x + y ) )
+ disp( 'Trmvp_ln_unb_var2 appears to be correct' )
+else
+ disp( 'Trmvp_ln_unb_var2 has a problem' )
+end
+
diff --git a/Answers/Week04/test_Trmvp_un_unb_var1.m b/Answers/Week04/test_Trmvp_un_unb_var1.m
new file mode 100755
index 0000000..e7f7cc6
--- /dev/null
+++ b/Answers/Week04/test_Trmvp_un_unb_var1.m
@@ -0,0 +1,10 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+y = randi( [ -2, 2 ], 4, 1 )
+
+if ( isequal( Trmvp_un_unb_var1( A, x, y ), triu( A ) * x + y ) )
+ disp( 'Trmvp_un_unb_var1 appears to be correct' )
+else
+ disp( 'Trmvp_un_unb_var1 has a problem' )
+end
+
diff --git a/Answers/Week04/test_Trmvp_un_unb_var2.m b/Answers/Week04/test_Trmvp_un_unb_var2.m
new file mode 100755
index 0000000..ede8f75
--- /dev/null
+++ b/Answers/Week04/test_Trmvp_un_unb_var2.m
@@ -0,0 +1,10 @@
+A = randi( [ -2, 2 ], 4, 4 )
+x = randi( [ -2, 2 ], 4, 1 )
+y = randi( [ -2, 2 ], 4, 1 )
+
+if ( isequal( Trmvp_un_unb_var2( A, x, y ), triu( A ) * x + y ) )
+ disp( 'Trmvp_un_unb_var2 appears to be correct' )
+else
+ disp( 'Trmvp_un_unb_var2 has a problem' )
+end
+
diff --git a/Answers/Week05/Gemm_unb_var1.m b/Answers/Week05/Gemm_unb_var1.m
new file mode 100755
index 0000000..bb10fb4
--- /dev/null
+++ b/Answers/Week05/Gemm_unb_var1.m
@@ -0,0 +1,35 @@
+function [ C_out ] = Gemm_unb_var1( A, B, C )
+
+ [ BL, BR ] = FLA_Part_1x2( B, ...
+ 0, 'FLA_LEFT' );
+
+ [ CL, CR ] = FLA_Part_1x2( C, ...
+ 0, 'FLA_LEFT' );
+
+ while ( size( BL, 2 ) < size( B, 2 ) )
+
+ [ B0, b1, B2 ]= FLA_Repart_1x2_to_1x3( BL, BR, ...
+ 1, 'FLA_RIGHT' );
+
+ [ C0, c1, C2 ]= FLA_Repart_1x2_to_1x3( CL, CR, ...
+ 1, 'FLA_RIGHT' );
+
+ %------------------------------------------------------------%
+
+ c1 = laff_gemv( 'No transpose', 1, A, b1, 1, c1 );
+
+ %------------------------------------------------------------%
+
+ [ BL, BR ] = FLA_Cont_with_1x3_to_1x2( B0, b1, B2, ...
+ 'FLA_LEFT' );
+
+ [ CL, CR ] = FLA_Cont_with_1x3_to_1x2( C0, c1, C2, ...
+ 'FLA_LEFT' );
+
+ end
+
+ C_out = [ CL, CR ];
+
+return
+
+
diff --git a/Answers/Week05/Gemm_unb_var2.m b/Answers/Week05/Gemm_unb_var2.m
new file mode 100755
index 0000000..9130ffe
--- /dev/null
+++ b/Answers/Week05/Gemm_unb_var2.m
@@ -0,0 +1,50 @@
+function [ C_out ] = Gemm_unb_var2( A, B, C )
+
+ [ AT, ...
+ AB ] = FLA_Part_2x1( A, ...
+ 0, 'FLA_TOP' );
+
+ [ CT, ...
+ CB ] = FLA_Part_2x1( C, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( AT, 1 ) < size( A, 1 ) )
+
+ [ A0, ...
+ a1t, ...
+ A2 ] = FLA_Repart_2x1_to_3x1( AT, ...
+ AB, ...
+ 1, 'FLA_BOTTOM' );
+
+ [ C0, ...
+ c1t, ...
+ C2 ] = FLA_Repart_2x1_to_3x1( CT, ...
+ CB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ c1t = laff_gemv( 'Transpose', 1, B, a1t, 1, c1t );
+
+ %------------------------------------------------------------%
+
+ [ AT, ...
+ AB ] = FLA_Cont_with_3x1_to_2x1( A0, ...
+ a1t, ...
+ A2, ...
+ 'FLA_TOP' );
+
+ [ CT, ...
+ CB ] = FLA_Cont_with_3x1_to_2x1( C0, ...
+ c1t, ...
+ C2, ...
+ 'FLA_TOP' );
+
+ end
+
+ C_out = [ CT
+ CB ];
+
+return
+
+
diff --git a/Answers/Week05/Gemm_unb_var3.m b/Answers/Week05/Gemm_unb_var3.m
new file mode 100755
index 0000000..c6057a1
--- /dev/null
+++ b/Answers/Week05/Gemm_unb_var3.m
@@ -0,0 +1,42 @@
+function [ C_out ] = Gemm_unb_var3( A, B, C )
+
+ [ AL, AR ] = FLA_Part_1x2( A, ...
+ 0, 'FLA_LEFT' );
+
+ [ BT, ...
+ BB ] = FLA_Part_2x1( B, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( AL, 2 ) < size( A, 2 ) )
+
+ [ A0, a1, A2 ]= FLA_Repart_1x2_to_1x3( AL, AR, ...
+ 1, 'FLA_RIGHT' );
+
+ [ B0, ...
+ b1t, ...
+ B2 ] = FLA_Repart_2x1_to_3x1( BT, ...
+ BB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ C = laff_ger( 1, a1, b1t, C );
+
+ %------------------------------------------------------------%
+
+ [ AL, AR ] = FLA_Cont_with_1x3_to_1x2( A0, a1, A2, ...
+ 'FLA_LEFT' );
+
+ [ BT, ...
+ BB ] = FLA_Cont_with_3x1_to_2x1( B0, ...
+ b1t, ...
+ B2, ...
+ 'FLA_TOP' );
+
+ end
+
+ C_out = C;
+
+
+return
+
diff --git a/Answers/Week05/MatMatMult.m b/Answers/Week05/MatMatMult.m
new file mode 100755
index 0000000..ca97ace
--- /dev/null
+++ b/Answers/Week05/MatMatMult.m
@@ -0,0 +1,15 @@
+function [ C_out ] = MatMatMult( A, B, C )
+
+[ m, n ] = size( C );
+[ m_A, k ] = size( A );
+[ m_B, n_B ] = size( B );
+
+for j = 1:n
+ for i = 1:m
+ for p = 1:k
+ C( i,j ) = A( i, p ) * B( p, j ) + C( i, j );
+ end
+ end
+end
+
+C_out = C;
diff --git a/Answers/Week05/Trtrmm_unb_var1.m b/Answers/Week05/Trtrmm_unb_var1.m
new file mode 100755
index 0000000..b717c10
--- /dev/null
+++ b/Answers/Week05/Trtrmm_unb_var1.m
@@ -0,0 +1,76 @@
+function [ C_out ] = Trtrmm_unb_var1( U, R, C )
+
+ [ UTL, UTR, ...
+ UBL, UBR ] = FLA_Part_2x2( U, ...
+ 0, 0, 'FLA_TL' );
+
+ [ RTL, RTR, ...
+ RBL, RBR ] = FLA_Part_2x2( R, ...
+ 0, 0, 'FLA_TL' );
+
+ [ CTL, CTR, ...
+ CBL, CBR ] = FLA_Part_2x2( C, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( UTL, 1 ) < size( U, 1 ) )
+
+ [ U00, u01, U02, ...
+ u10t, upsilon11, u12t, ...
+ U20, u21, U22 ] = FLA_Repart_2x2_to_3x3( UTL, UTR, ...
+ UBL, UBR, ...
+ 1, 1, 'FLA_BR' );
+
+ [ R00, r01, R02, ...
+ r10t, rho11, r12t, ...
+ R20, r21, R22 ] = FLA_Repart_2x2_to_3x3( RTL, RTR, ...
+ RBL, RBR, ...
+ 1, 1, 'FLA_BR' );
+
+ [ C00, c01, C02, ...
+ c10t, gamma11, c12t, ...
+ C20, c21, C22 ] = FLA_Repart_2x2_to_3x3( CTL, CTR, ...
+ CBL, CBR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ % Computing c01 = U00 * r01 is a bit tricky because
+ % laff_trmv( 'Upper triangular', 'No transpose', 'Nonunit diag', ...
+ % U00, c01 ) overwrites c01 with U00 * c01.
+ % So, we have to copy r01 to c01 first.
+ c01 = laff_copy( r01, c01 );
+ c01 = laff_trmv( 'Upper triangular', 'No transpose', 'Nonunit diag', ...
+ U00, c01 );
+
+ % Next we add rho11 * u01 to c01
+ c01 = laff_axpy( rho11, u01, c01 );
+
+ % Finally, gamma11 = upsilon11 * rho11
+ gamma11 = laff_dot( upsilon11, rho11 );
+
+ %------------------------------------------------------------%
+
+ [ UTL, UTR, ...
+ UBL, UBR ] = FLA_Cont_with_3x3_to_2x2( U00, u01, U02, ...
+ u10t, upsilon11, u12t, ...
+ U20, u21, U22, ...
+ 'FLA_TL' );
+
+ [ RTL, RTR, ...
+ RBL, RBR ] = FLA_Cont_with_3x3_to_2x2( R00, r01, R02, ...
+ r10t, rho11, r12t, ...
+ R20, r21, R22, ...
+ 'FLA_TL' );
+
+ [ CTL, CTR, ...
+ CBL, CBR ] = FLA_Cont_with_3x3_to_2x2( C00, c01, C02, ...
+ c10t, gamma11, c12t, ...
+ C20, c21, C22, ...
+ 'FLA_TL' );
+
+ end
+
+ C_out = [ CTL, CTR
+ CBL, CBR ];
+
+return
\ No newline at end of file
diff --git a/Answers/Week05/test_Gemm_unb_var1.m b/Answers/Week05/test_Gemm_unb_var1.m
new file mode 100755
index 0000000..45d58fc
--- /dev/null
+++ b/Answers/Week05/test_Gemm_unb_var1.m
@@ -0,0 +1,21 @@
+m = 5;
+n = 3;
+k = 4;
+
+C = randi( [-2,2], m, n )
+A = randi( [-2,2], m, k )
+B = randi( [-2,2], k, n )
+
+% Compute A * B + C via MatMatMult
+Gemm_unb_var1( A, B, C )
+
+% Compute A * B + C
+A * B + C
+
+% Check if they compute the same
+if ( isequal( Gemm_unb_var1( A, B, C ), A * B + C ) )
+ disp( 'it appears Gemm_unb_var1 computes correctly' )
+else
+ disp( 'Gemm_unb_var1 has a problem' )
+end
+
diff --git a/Answers/Week05/test_Gemm_unb_var2.m b/Answers/Week05/test_Gemm_unb_var2.m
new file mode 100755
index 0000000..6dcbe47
--- /dev/null
+++ b/Answers/Week05/test_Gemm_unb_var2.m
@@ -0,0 +1,21 @@
+m = 5;
+n = 3;
+k = 4;
+
+C = randi( [-2,2], m, n )
+A = randi( [-2,2], m, k )
+B = randi( [-2,2], k, n )
+
+% Compute A * B + C via MatMatMult
+Gemm_unb_var2( A, B, C )
+
+% Compute A * B + C
+A * B + C
+
+% Check if they compute the same
+if ( isequal( Gemm_unb_var2( A, B, C ), A * B + C ) )
+ disp( 'it appears Gemm_unb_var2 computes correctly' )
+else
+ disp( 'Gemm_unb_var2 has a problem' )
+end
+
diff --git a/Answers/Week05/test_Gemm_unb_var3.m b/Answers/Week05/test_Gemm_unb_var3.m
new file mode 100755
index 0000000..14751c1
--- /dev/null
+++ b/Answers/Week05/test_Gemm_unb_var3.m
@@ -0,0 +1,21 @@
+m = 5;
+n = 3;
+k = 4;
+
+C = randi( [-2,2], m, n )
+A = randi( [-2,2], m, k )
+B = randi( [-2,2], k, n )
+
+% Compute A * B + C via MatMatMult
+Gemm_unb_var3( A, B, C )
+
+% Compute A * B + C
+A * B + C
+
+% Check if they compute the same
+if ( isequal( Gemm_unb_var3( A, B, C ), A * B + C ) )
+ disp( 'it appears Gemm_unb_var3 computes correctly' )
+else
+ disp( 'Gemm_unb_var3 has a problem' )
+end
+
diff --git a/Answers/Week05/test_MatMatMult.m b/Answers/Week05/test_MatMatMult.m
new file mode 100755
index 0000000..7b7e868
--- /dev/null
+++ b/Answers/Week05/test_MatMatMult.m
@@ -0,0 +1,21 @@
+m = 5;
+n = 3;
+k = 4;
+
+C = randi( [-2,2], m, n )
+A = randi( [-2,2], m, k )
+B = randi( [-2,2], k, n )
+
+% Compute A * B + C via MatMatMult
+MatMatMult( A, B, C )
+
+% Compute A * B + C
+A * B + C
+
+% Check if they compute the same
+if ( isequal( MatMatMult( A, B, C ), A * B + C ) )
+ disp( 'it appears MatMatMult computes correctly' )
+else
+ disp( 'MatMatMult has a problem' )
+end
+
diff --git a/Answers/Week05/test_Trtrmm_unb_var1.m b/Answers/Week05/test_Trtrmm_unb_var1.m
new file mode 100755
index 0000000..159dc3b
--- /dev/null
+++ b/Answers/Week05/test_Trtrmm_unb_var1.m
@@ -0,0 +1,23 @@
+U = randi( [-2,2], 4, 4 );
+R = randi( [-2,2], 4, 4 );
+C = randi( [-2,2], 4, 4 );
+
+Cout = Trtrmm_unb_var1( U, R, C );
+
+% Now, remember that only the upper triangular part changed. So,
+% tril( Cout,-1 ) should equal tril( C,-1 ) and triu( Cout ) should equal
+% triu( U ) * triu( R )
+
+if ~isequal( tril( Cout, -1 ), tril( C, -1 ) )
+
+ disp( 'TROUBLE: The lower triangular part of C was corrupted' )
+
+elseif ~isequal( triu( Cout ), triu( U ) * triu( R ) )
+
+ disp( 'TROUBLE: The lower triangular part of C was corrupted' )
+
+else
+
+ disp( 'Trtrmm_unb_var1 appears to give the right answer' )
+
+end
\ No newline at end of file
diff --git a/Answers/Week06/ForwardSubstitution.m b/Answers/Week06/ForwardSubstitution.m
new file mode 100755
index 0000000..7ae7a3b
--- /dev/null
+++ b/Answers/Week06/ForwardSubstitution.m
@@ -0,0 +1,49 @@
+function [ b_out ] = ForwardSubstitution( A, b )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ [ bT, ...
+ bB ] = FLA_Part_2x1( b, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ [ b0, ...
+ beta1, ...
+ b2 ] = FLA_Repart_2x1_to_3x1( bT, ...
+ bB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ b2 = laff_axpy( -beta1, a21, b2 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ [ bT, ...
+ bB ] = FLA_Cont_with_3x1_to_2x1( b0, ...
+ beta1, ...
+ b2, ...
+ 'FLA_TOP' );
+
+ end
+
+ b_out = [ bT
+ bB ];
+
+return
+
diff --git a/Answers/Week06/GaussianElimination.m b/Answers/Week06/GaussianElimination.m
new file mode 100755
index 0000000..b71f293
--- /dev/null
+++ b/Answers/Week06/GaussianElimination.m
@@ -0,0 +1,34 @@
+function [ A_out ] = GaussianElimination( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a21 = laff_invscal( alpha11, a21 );
+ A22 = laff_ger( -1, a21, a12t, A22 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
+
diff --git a/Answers/Week06/LU_unb_var5.m b/Answers/Week06/LU_unb_var5.m
new file mode 100755
index 0000000..f9d0e26
--- /dev/null
+++ b/Answers/Week06/LU_unb_var5.m
@@ -0,0 +1,34 @@
+function [ A_out ] = LU_unb_var5( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a21 = laff_invscal( alpha11, a21 );
+ A22 = laff_ger( -1, a21, a12t, A22 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
+
diff --git a/Answers/Week06/Ltrsv_unb_var1.m b/Answers/Week06/Ltrsv_unb_var1.m
new file mode 100755
index 0000000..2454b3e
--- /dev/null
+++ b/Answers/Week06/Ltrsv_unb_var1.m
@@ -0,0 +1,49 @@
+function [ b_out ] = Ltrsv_unb_var1( L, b )
+
+ [ LTL, LTR, ...
+ LBL, LBR ] = FLA_Part_2x2( L, ...
+ 0, 0, 'FLA_TL' );
+
+ [ bT, ...
+ bB ] = FLA_Part_2x1( b, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( LTL, 1 ) < size( L, 1 ) )
+
+ [ L00, l01, L02, ...
+ l10t, lambda11, l12t, ...
+ L20, l21, L22 ] = FLA_Repart_2x2_to_3x3( LTL, LTR, ...
+ LBL, LBR, ...
+ 1, 1, 'FLA_BR' );
+
+ [ b0, ...
+ beta1, ...
+ b2 ] = FLA_Repart_2x1_to_3x1( bT, ...
+ bB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ b2 = laff_axpy( -beta1, l21, b2 );
+
+ %------------------------------------------------------------%
+
+ [ LTL, LTR, ...
+ LBL, LBR ] = FLA_Cont_with_3x3_to_2x2( L00, l01, L02, ...
+ l10t, lambda11, l12t, ...
+ L20, l21, L22, ...
+ 'FLA_TL' );
+
+ [ bT, ...
+ bB ] = FLA_Cont_with_3x1_to_2x1( b0, ...
+ beta1, ...
+ b2, ...
+ 'FLA_TOP' );
+
+ end
+
+ b_out = [ bT
+ bB ];
+
+return
+
diff --git a/Answers/Week06/Solve.m b/Answers/Week06/Solve.m
new file mode 100755
index 0000000..b6bb288
--- /dev/null
+++ b/Answers/Week06/Solve.m
@@ -0,0 +1,15 @@
+function [ A_out, b_out ] = Solve( A, b )
+% Solves A x = b
+
+LU = LU_unb_var5( A );
+
+z = Ltrsv_unb_var1( LU, b );
+
+x = Utrsv_unb_var1( LU, z );
+
+A_out = LU;
+
+b_out = x;
+
+end
+
diff --git a/Answers/Week06/Utrsv_unb_var1.m b/Answers/Week06/Utrsv_unb_var1.m
new file mode 100755
index 0000000..35f6fb7
--- /dev/null
+++ b/Answers/Week06/Utrsv_unb_var1.m
@@ -0,0 +1,49 @@
+function [ b_out ] = Utrsv_unb_var1( U, b )
+
+ [ UTL, UTR, ...
+ UBL, UBR ] = FLA_Part_2x2( U, ...
+ 0, 0, 'FLA_BR' );
+
+ [ bT, ...
+ bB ] = FLA_Part_2x1( b, ...
+ 0, 'FLA_BOTTOM' );
+
+ while ( size( UBR, 1 ) < size( U, 1 ) )
+
+ [ U00, u01, U02, ...
+ u10t, upsilon11, u12t, ...
+ U20, u21, U22 ] = FLA_Repart_2x2_to_3x3( UTL, UTR, ...
+ UBL, UBR, ...
+ 1, 1, 'FLA_TL' );
+
+ [ b0, ...
+ beta1, ...
+ b2 ] = FLA_Repart_2x1_to_3x1( bT, ...
+ bB, ...
+ 1, 'FLA_TOP' );
+
+ %------------------------------------------------------------%
+
+ beta1 = beta1 - laff_dot( u12t, b2 );
+ beta1 = beta1 / upsilon11;
+
+ %------------------------------------------------------------%
+
+ [ UTL, UTR, ...
+ UBL, UBR ] = FLA_Cont_with_3x3_to_2x2( U00, u01, U02, ...
+ u10t, upsilon11, u12t, ...
+ U20, u21, U22, ...
+ 'FLA_BR' );
+
+ [ bT, ...
+ bB ] = FLA_Cont_with_3x1_to_2x1( b0, ...
+ beta1, ...
+ b2, ...
+ 'FLA_BOTTOM' );
+
+ end
+
+ b_out = [ bT
+ bB ];
+
+return
diff --git a/Answers/Week06/test_GaussianElimination.m b/Answers/Week06/test_GaussianElimination.m
new file mode 100755
index 0000000..ac4066c
--- /dev/null
+++ b/Answers/Week06/test_GaussianElimination.m
@@ -0,0 +1,40 @@
+% Create a matrix. (This matrix was carefully chosen so that only integers
+% are encountered during the process.)
+
+A = [
+ 2 0 1 2
+ -2 -1 1 -1
+ 4 -1 5 4
+ -4 1 -3 -8
+]
+
+% Perform Gaussian elimination
+
+LU = GaussianElimination( A )
+
+% Create a right-hand side. We are going to solve A x = b
+
+b = [
+ 2
+ 2
+ 11
+ -3
+]
+
+% Perform forward substitution
+
+bhat = ForwardSubstitution( LU, b )
+
+% Extract the upper triangular matrix from the matrix that resulted from
+% Gaussian elminination:
+
+U = triu( LU )
+
+% Solve U x = bhat
+
+x = U \ bhat
+
+% Check the answer
+
+b - A * x
+
diff --git a/Answers/Week06/test_LU_unb_var5.m b/Answers/Week06/test_LU_unb_var5.m
new file mode 100755
index 0000000..2cba169
--- /dev/null
+++ b/Answers/Week06/test_LU_unb_var5.m
@@ -0,0 +1,25 @@
+% Create a matrix. (This matrix was carefully chosen so that only integers
+% are encountered during the process.)
+
+A = [
+ 2 0 1 2
+ -2 -1 1 -1
+ 4 -1 5 4
+ -4 1 -3 -8
+]
+
+% Perform LU factorization
+
+LU = LU_unb_var5( A )
+
+% Extract the unit lower triangular matrix
+
+L = tril( LU, -1 ) + eye( size( LU ) )
+
+% Extract the upper triangular matrix
+
+U = triu( LU )
+
+% Check that A = L * U
+
+A - L * U
diff --git a/Answers/Week06/test_Ltrsv_unb_var1.m b/Answers/Week06/test_Ltrsv_unb_var1.m
new file mode 100755
index 0000000..c23df2b
--- /dev/null
+++ b/Answers/Week06/test_Ltrsv_unb_var1.m
@@ -0,0 +1,28 @@
+% Create a unit lower triangular matrixmatrix.
+% (This matrix was carefully chosen so that only integers
+% are encountered during the process.)
+
+L = [
+ 1 0 0 0
+ -1 1 0 0
+ 2 1 1 0
+ -2 -1 1 1
+]
+
+% Create a right-hand side. We are going to solve L x = b
+
+b = [
+ 2
+ 2
+ 11
+ -3
+]
+
+% Solve L x = b
+
+x = Ltrsv_unb_var1( L, b )
+
+% Check that L x = b
+
+b - L * x
+
diff --git a/Answers/Week06/test_Solve.m b/Answers/Week06/test_Solve.m
new file mode 100755
index 0000000..d1aedde
--- /dev/null
+++ b/Answers/Week06/test_Solve.m
@@ -0,0 +1,26 @@
+% Create a matrix. (This matrix was carefully chosen so that only integers
+% are encountered during the process.)
+
+A = [
+ 2 0 1 2
+ -2 -1 1 -1
+ 4 -1 5 4
+ -4 1 -3 -8
+]
+
+% Create a right-hand size vector b
+
+b = [
+ 2
+ 2
+ 11
+ -3
+]
+
+% Solve A x = b
+
+[ LU, x ] = Solve( A, b )
+
+% Check that A x = b
+
+b - A * x
diff --git a/Answers/Week06/test_Utrsv_unb_var1.m b/Answers/Week06/test_Utrsv_unb_var1.m
new file mode 100755
index 0000000..758f51a
--- /dev/null
+++ b/Answers/Week06/test_Utrsv_unb_var1.m
@@ -0,0 +1,30 @@
+% Create an upper triangular matrixmatrix.
+% (This matrix was carefully chosen so that only integers
+% are encountered during the process.)
+
+U = [
+ 2 0 1 2
+ 0 -1 2 1
+ 0 0 1 -1
+ 0 0 0 -2
+
+]
+
+% Create a right-hand side. We are going to solve U x = b
+
+b = [
+ 2
+ 4
+ 3
+ 2
+
+]
+
+% Solve U x = b
+
+x = Utrsv_unb_var1( U, b )
+
+% Check that U x = b
+
+b - U * x
+
diff --git a/Answers/Week07/Ltrsv_unb_var2.m b/Answers/Week07/Ltrsv_unb_var2.m
new file mode 100755
index 0000000..04d2cb6
--- /dev/null
+++ b/Answers/Week07/Ltrsv_unb_var2.m
@@ -0,0 +1,49 @@
+function [ b_out ] = Ltrsv_unb_var2( L, b )
+
+ [ LTL, LTR, ...
+ LBL, LBR ] = FLA_Part_2x2( L, ...
+ 0, 0, 'FLA_TL' );
+
+ [ bT, ...
+ bB ] = FLA_Part_2x1( b, ...
+ 0, 'FLA_TOP' );
+
+ while ( size( LTL, 1 ) < size( L, 1 ) )
+
+ [ L00, l01, L02, ...
+ l10t, lambda11, l12t, ...
+ L20, l21, L22 ] = FLA_Repart_2x2_to_3x3( LTL, LTR, ...
+ LBL, LBR, ...
+ 1, 1, 'FLA_BR' );
+
+ [ b0, ...
+ beta1, ...
+ b2 ] = FLA_Repart_2x1_to_3x1( bT, ...
+ bB, ...
+ 1, 'FLA_BOTTOM' );
+
+ %------------------------------------------------------------%
+
+ beta1 = beta1 - laff_dot( l10t, b0 );
+
+ %------------------------------------------------------------%
+
+ [ LTL, LTR, ...
+ LBL, LBR ] = FLA_Cont_with_3x3_to_2x2( L00, l01, L02, ...
+ l10t, lambda11, l12t, ...
+ L20, l21, L22, ...
+ 'FLA_TL' );
+
+ [ bT, ...
+ bB ] = FLA_Cont_with_3x1_to_2x1( b0, ...
+ beta1, ...
+ b2, ...
+ 'FLA_TOP' );
+
+ end
+
+ b_out = [ bT
+ bB ];
+
+return
+
diff --git a/Answers/Week07/test_Ltrsv_unb_var2.m b/Answers/Week07/test_Ltrsv_unb_var2.m
new file mode 100755
index 0000000..f27b5d6
--- /dev/null
+++ b/Answers/Week07/test_Ltrsv_unb_var2.m
@@ -0,0 +1,28 @@
+% Create a unit lower triangular matrixmatrix.
+% (This matrix was carefully chosen so that only integers
+% are encountered during the process.)
+
+L = [
+ 1 0 0 0
+ -1 1 0 0
+ 2 1 1 0
+ -2 -1 1 1
+]
+
+% Create a right-hand side. We are going to solve L x = b
+
+b = [
+ 2
+ 2
+ 11
+ -3
+]
+
+% Solve L x = b
+
+x = Ltrsv_unb_var2( L, b )
+
+% Check that L x = b
+
+b - L * x
+
diff --git a/Answers/Week08/GJ_Inverse_alt_unb.m b/Answers/Week08/GJ_Inverse_alt_unb.m
new file mode 100755
index 0000000..25dcebf
--- /dev/null
+++ b/Answers/Week08/GJ_Inverse_alt_unb.m
@@ -0,0 +1,66 @@
+function [ B_out ] = GJ_Inverse_alt_unb( A, B )
+
+ B = eye( size( A ) );
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ [ BTL, BTR, ...
+ BBL, BBR ] = FLA_Part_2x2( B, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ [ B00, b01, B02, ...
+ b10t, beta11, b12t, ...
+ B20, b21, B22 ] = FLA_Repart_2x2_to_3x3( BTL, BTR, ...
+ BBL, BBR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a01 = laff_invscal( alpha11, a01 ); A02 = laff_ger( -1, a01, a12t, A02 );
+
+ a21 = laff_invscal( alpha11, a21 ); A22 = laff_ger( -1, a21, a12t, A22 );
+
+ B00 = laff_ger( -1, a01, b10t, B00 ); b01 = laff_scal( -1, a01 );
+
+ B20 = laff_ger( -1, a21, b10t, B20 ); b21 = laff_scal( -1, a21 );
+
+ a01 = laff_zerov( a01 );
+ a21 = laff_zerov( a21 );
+ a12t = laff_invscal( alpha11, a12t );
+
+ b10t = laff_invscal( alpha11, b10t );
+ beta11 = 1./alpha11;
+
+ alpha11 = laff_onev( alpha11 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ [ BTL, BTR, ...
+ BBL, BBR ] = FLA_Cont_with_3x3_to_2x2( B00, b01, B02, ...
+ b10t, beta11, b12t, ...
+ B20, b21, B22, ...
+ 'FLA_TL' );
+
+ end
+
+ B_out = [ BTL, BTR
+ BBL, BBR ];
+
+return
+
diff --git a/Answers/Week08/GJ_Inverse_inplace_unb.m b/Answers/Week08/GJ_Inverse_inplace_unb.m
new file mode 100755
index 0000000..090912a
--- /dev/null
+++ b/Answers/Week08/GJ_Inverse_inplace_unb.m
@@ -0,0 +1,44 @@
+function [ A_out ] = GJ_Inverse_inplace_unb( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a01 = laff_invscal( alpha11, a01 ); A02 = laff_ger( -1, a01, a12t, A02 );
+
+ a21 = laff_invscal( alpha11, a21 ); A22 = laff_ger( -1, a21, a12t, A22 );
+
+ A00 = laff_ger( -1, a01, a10t, A00 ); a01 = laff_scal( -1, a01 );
+
+ A20 = laff_ger( -1, a21, a10t, A20 ); a21 = laff_scal( -1, a21 );
+
+ a12t = laff_invscal( alpha11, a12t );
+
+ a10t = laff_invscal( alpha11, a10t );
+
+ alpha11 = laff_invscal( alpha11, 1. );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
+
diff --git a/Answers/Week08/GJ_Inverse_inplace_unb_var2.m b/Answers/Week08/GJ_Inverse_inplace_unb_var2.m
new file mode 100755
index 0000000..a02920e
--- /dev/null
+++ b/Answers/Week08/GJ_Inverse_inplace_unb_var2.m
@@ -0,0 +1,44 @@
+function [ A_out ] = GJ_Inverse_inplace_unb( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a01 = laff_invscal( -alpha11, a01 );
+
+ a21 = laff_invscal( -alpha11, a21 );
+
+ A00 = laff_ger( 1, a01, a10t, A00 ); A02 = laff_ger( 1, a01, a12t, A02 );
+
+ A20 = laff_ger( 1, a21, a10t, A20 ); A22 = laff_ger( 1, a21, a12t, A22 );
+
+ a12t = laff_invscal( alpha11, a12t );
+
+ a10t = laff_invscal( alpha11, a10t );
+
+ alpha11 = laff_invscal( alpha11, 1. );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
+
diff --git a/Answers/Week08/Homework_8_2_2_2_Answer.m b/Answers/Week08/Homework_8_2_2_2_Answer.m
new file mode 100755
index 0000000..bc0852f
--- /dev/null
+++ b/Answers/Week08/Homework_8_2_2_2_Answer.m
@@ -0,0 +1,55 @@
+% Start with a matrix and right-hand side vector
+A = [ -2 2 -5
+ 2 -3 7
+ -4 3 -7 ]
+
+b = [ -7
+ 11
+ -9 ]
+
+% Create an appended matrix
+A_appended = [ A b ]
+
+% Create the first Gauss transform to introduce zeros in the first column
+G0 = [ 1 0 0
+ 1 1 0
+ -2 0 1 ]
+
+% Apply the Gauss transform to the appended system
+A0 = G0 * A_appended
+
+% Create the second Gauss transform to introduce zeros in the second column
+G1 = [ 1 2 0
+ 0 1 0
+ 0 -1 1 ]
+
+% Apply the Gauss transform to the appended system
+A1 = G1 * A0
+
+% Create the third Gauss transform to introduce zeros in the third column
+G2 = [ 1 0 1
+ 0 1 -2
+ 0 0 1 ]
+
+% Apply the Gauss transform to the appended system
+A2 = G2 * A1
+
+% Create a diagonal matrix to set the diagonal elements to one
+D3 = [ -1/2 0 0
+ 0 -1 0
+ 0 0 1 ]
+
+% Apply the diagonal matrix to the appended system
+A3 = D3 * A2
+
+% Extract the solution vector from the appended column
+x = A3( :, 4 )
+
+% Check that the inverse was computed
+b - A * x
+
+% The result should be a zero vector of size 3
+
+
+
+
diff --git a/Answers/Week08/Homework_8_2_3_2_Answer.m b/Answers/Week08/Homework_8_2_3_2_Answer.m
new file mode 100755
index 0000000..337037b
--- /dev/null
+++ b/Answers/Week08/Homework_8_2_3_2_Answer.m
@@ -0,0 +1,55 @@
+% Start with a matrix and a matrix with two right-hand side vectors
+A = [ -2 2 -5
+ 2 -3 7
+ -4 3 -7 ]
+
+B = [ -7 8
+ 11 -13
+ -9 9 ]
+
+% Create an appended matrix
+A_appended = [ A B ]
+
+% Create the first Gauss transform to introduce zeros in the first column
+G0 = [ 1 0 0
+ 1 1 0
+ -2 0 1 ]
+
+% Apply the Gauss transform to the appended system
+A0 = G0 * A_appended
+
+% Create the second Gauss transform to introduce zeros in the second column
+G1 = [ 1 2 0
+ 0 1 0
+ 0 -1 1 ]
+
+% Apply the Gauss transform to the appended system
+A1 = G1 * A0
+
+% Create the third Gauss transform to introduce zeros in the third column
+G2 = [ 1 0 1
+ 0 1 -2
+ 0 0 1 ]
+
+% Apply the Gauss transform to the appended system
+A2 = G2 * A1
+
+% Create a diagonal matrix to set the diagonal elements to one
+D3 = [ -1/2 0 0
+ 0 -1 0
+ 0 0 1 ]
+
+% Apply the diagonal matrix to the appended system
+A3 = D3 * A2
+
+% Extract the solutions vector from the appended column
+X = A3( :, 4:5 )
+
+% Check that the inverse was computed
+B - A * X
+
+% The result should be a zero matrix of size 3 x 2
+
+
+
+
diff --git a/Answers/Week08/Homework_8_2_8_2.m b/Answers/Week08/Homework_8_2_8_2.m
new file mode 100755
index 0000000..6a93901
--- /dev/null
+++ b/Answers/Week08/Homework_8_2_8_2.m
@@ -0,0 +1,47 @@
+% Start with a matrix
+A = [ -2 2 -5
+ 2 -3 7
+ -4 3 -7 ]
+
+% Create an appended matrix by appending the identity
+A_appended = [ A eye(size(A)) ]
+
+% Create the first Gauss transform to introduce zeros in the first column
+G0 = [ 1 0 0
+ ? 1 0
+ ? 0 1 ]
+
+% Apply the Gauss transform to the appended system
+A0 = G0 * A_appended
+
+% Create the second Gauss transform to introduce zeros in the second column
+G1 = [ 1 ? 0
+ 0 1 0
+ 0 ? 1 ]
+
+% Apply the Gauss transform to the appended system
+A1 = G1 * A0
+
+% Create the third Gauss transform to introduce zeros in the third column
+G2 = [ 1 0 ?
+ 0 1 ?
+ 0 0 1 ]
+
+% Apply the Gauss transform to the appended system
+A2 = G2 * A1
+
+% Create a diagonal matrix to set the diagonal elements to one
+D3 = [ -1/2 0 0
+ 0 -1 0
+ 0 0 1 ]
+
+% Apply the diagonal matrix to the appended system
+A3 = D3 * A2
+
+% Extract the (updated) appended columns
+Ainv = A3( :, 4:6 )
+
+% Check that the inverse was computed
+A * Ainv
+
+% The result should be a 3x3 identity matrix
diff --git a/Answers/Week08/Homework_8_2_8_2_Answer.m b/Answers/Week08/Homework_8_2_8_2_Answer.m
new file mode 100755
index 0000000..80e6a44
--- /dev/null
+++ b/Answers/Week08/Homework_8_2_8_2_Answer.m
@@ -0,0 +1,51 @@
+% Start with a matrix
+A = [ -2 2 -5
+ 2 -3 7
+ -4 3 -7 ]
+
+% Create an appended matrix by appending the identity
+A_appended = [ A eye(size(A)) ]
+
+% Create the first Gauss transform to introduce zeros in the first column
+G0 = [ 1 0 0
+ 1 1 0
+ -2 0 1 ]
+
+% Apply the Gauss transform to the appended system
+A0 = G0 * A_appended
+
+% Create the second Gauss transform to introduce zeros in the second column
+G1 = [ 1 2 0
+ 0 1 0
+ 0 -1 1 ]
+
+% Apply the Gauss transform to the appended system
+A1 = G1 * A0
+
+% Create the third Gauss transform to introduce zeros in the third column
+G2 = [ 1 0 1
+ 0 1 -2
+ 0 0 1 ]
+
+% Apply the Gauss transform to the appended system
+A2 = G2 * A1
+
+% Create a diagonal matrix to set the diagonal elements to one
+D3 = [ -1/2 0 0
+ 0 -1 0
+ 0 0 1 ]
+
+% Apply the diagonal matrix to the appended system
+A3 = D3 * A2
+
+% Extract the (updated) appended columns
+Ainv = A3( :, 4:6 )
+
+% Check that the inverse was computed
+A * Ainv
+
+% The result should be a 3x3 identity matrix
+
+
+
+
diff --git a/Answers/Week08/LU_unb.m b/Answers/Week08/LU_unb.m
new file mode 100755
index 0000000..32671d9
--- /dev/null
+++ b/Answers/Week08/LU_unb.m
@@ -0,0 +1,33 @@
+function [ A_out ] = LU_unb( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a21 = a21 / alpha11;
+ A22 = A22 - a21 * a12t;
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
\ No newline at end of file
diff --git a/Answers/Week08/test_GJ_Inverse_alt_unb.m b/Answers/Week08/test_GJ_Inverse_alt_unb.m
new file mode 100755
index 0000000..073ab00
--- /dev/null
+++ b/Answers/Week08/test_GJ_Inverse_alt_unb.m
@@ -0,0 +1,19 @@
+% We are going to take a bit of a risk, and start with a random matrix A
+% with integer values... There is no guarantee that it is invertible
+% without pivoting, or invertible at all...
+
+A = randi( [-9,9], 4, 4 );
+
+B = zeros( size( A ) );
+
+Ainv = GJ_Inverse_alt_unb( A, B );
+
+disp( 'The below should equal approximately the identity:' )
+
+Ainv * A
+
+disp( 'Note: if the above shows "NaN", this means that the Gauss-Jordan' )
+disp( 'algorithm encountered a divide by zero' )
+disp( 'Just execute this script again, and see if you get luckier...' )
+
+
diff --git a/Answers/Week08/test_GJ_Inverse_inplace_unb.m b/Answers/Week08/test_GJ_Inverse_inplace_unb.m
new file mode 100755
index 0000000..b374bbb
--- /dev/null
+++ b/Answers/Week08/test_GJ_Inverse_inplace_unb.m
@@ -0,0 +1,17 @@
+% We are going to take a bit of a risk, and start with a random matrix A
+% with integer values... There is no guarantee that it is invertible
+% without pivoting, or invertible at all...
+
+A = randi( [-9,9], 4, 4 );
+
+Ainv = GJ_Inverse_inplace_unb( A );
+
+disp( 'The below should equal approximately the identity:' )
+
+Ainv * A
+
+disp( 'Note: if the above shows "NaN", this means that the Gauss-Jordan' )
+disp( 'algorithm encountered a divide by zero, resulting in a "Not a Number"' )
+disp( 'Just execute this script again, and see if you get luckier...' )
+
+
diff --git a/Answers/Week08/test_GJ_Inverse_inplace_unb_var2.m b/Answers/Week08/test_GJ_Inverse_inplace_unb_var2.m
new file mode 100755
index 0000000..6f785f9
--- /dev/null
+++ b/Answers/Week08/test_GJ_Inverse_inplace_unb_var2.m
@@ -0,0 +1,17 @@
+% We are going to take a bit of a risk, and start with a random matrix A
+% with integer values... There is no guarantee that it is invertible
+% without pivoting, or invertible at all...
+
+A = randi( [-9,9], 4, 4 );
+
+Ainv = GJ_Inverse_inplace_unb_var2( A );
+
+disp( 'The below should equal approximately the identity:' )
+
+Ainv * A
+
+disp( 'Note: if the above shows "NaN", this means that the Gauss-Jordan' )
+disp( 'algorithm encountered a divide by zero, resulting in a "Not a Number"' )
+disp( 'Just execute this script again, and see if you get luckier...' )
+
+
diff --git a/Answers/Week11/Cholesky_unb_var3.m b/Answers/Week11/Cholesky_unb_var3.m
new file mode 100755
index 0000000..3fe0023
--- /dev/null
+++ b/Answers/Week11/Cholesky_unb_var3.m
@@ -0,0 +1,34 @@
+function [ A_out ] = Cholesky_unb_var3( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ alpha11 = sqrt( alpha11 );
+ a21 = laff_invscal( alpha11, a21 );
+ A22 = laff_syr( 'Lower triangular', -1, a21, A22 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
diff --git a/Answers/Week11/CompressPicture.m b/Answers/Week11/CompressPicture.m
new file mode 100755
index 0000000..46251e0
--- /dev/null
+++ b/Answers/Week11/CompressPicture.m
@@ -0,0 +1,56 @@
+% Close all figures
+close all
+
+% Read the picture in building.png into matrix B
+[ B, map ] = imread( 'building.png' );
+
+% Show the picture in a figure
+imshow( B );
+
+% Choose the (approximate) number of columns you want to use for the
+% aproximation.
+k = 30;
+
+% Extract the number of rows and columns in B
+[ m, n ] = size( B )
+
+% B starts as an integer array. To do the computations, we need to
+% make it into floating point numbers.
+
+B = double( B );
+
+% Pick A as the matrix consisting of about k equally spaced columns of
+% B.
+stride = round( n / k );
+A = B( :, 1:stride:n );
+
+% Replace the comments below with their respective operations from the notebook
+
+% C = A^T A
+
+
+% V = A^T B
+
+
+% Overwrite C with its LU factorization
+
+
+% Extract the unit lower triangular matrix L and upper triangular matrix U.
+L = tril( C, -1 ) + eye( size( C ) );
+U = triu( C );
+
+% Solve L(UX) = V, overwriting V with X
+V = L \ V;
+V = U \ V;
+
+% Create a new figure in which you show the approximated picture. Notice
+% that A and V are matrices of doubles, which much be converted to unsigned
+% 8 byte integers for imshow to work.
+figure
+imshow( uint8( A * V ) );
+
+% The two figures may be on top of each other. You may have to move the
+% second one next to the first one.
+
+% Play around by changing the number of columns you use for the
+% approximation!
diff --git a/Answers/Week11/CompressPictureWithSVD.m b/Answers/Week11/CompressPictureWithSVD.m
new file mode 100755
index 0000000..c1a45ac
--- /dev/null
+++ b/Answers/Week11/CompressPictureWithSVD.m
@@ -0,0 +1,68 @@
+% Close all figures
+close all
+
+% Read the picture in building.png into matrix B
+[ B, map ] = imread( 'building.png' );
+
+% Show the picture in a figure
+imshow( B );
+
+% Choose the (approximate) number of columns you want to use for the
+% aproximation.
+k = 30;
+
+% Extract the number of rows and columns in B
+[ m, n ] = size( B )
+
+% B starts as an integer array. To do the computations, we need to
+% make it into floating point numbers.
+
+B = double( B );
+
+% Pick A as the matrix consisting of about k equally spaced columns of
+% B.
+stride = round( n / k );
+A = B( :, 1:stride:n );
+
+% Replace the comments below with their respective operations from the notebook
+
+% C = A^T A
+C = A' * A;
+
+% V = A^T B
+V = A' * B;
+
+% Overwrite C with its LU factorization
+C = LU_unb_var5( C );
+
+% Extract the unit lower triangular matrix L and upper triangular matrix U.
+L = tril( C, -1 ) + eye( size( C ) );
+U = triu( C );
+
+% Solve L(UX) = V, overwriting V with X
+V = L \ V;
+V = U \ V;
+
+% Create a new figure in which you show the approximated picture. Notice
+% that A and V are matrices of doubles, which much be converted to unsigned
+% 8 byte integers for imshow to work.
+figure
+
+imshow( uint8( A * V ) );
+
+% Now let's use the SVD
+
+% Compute the SVD
+[ U, Sigma, V ] = svd( B );
+
+% Use the first k columns of U and V and the first k singular value to
+% approximate
+
+figure
+imshow( uint8( U( :, 1:k ) * Sigma( 1:k, 1:k ) * V( :, 1:k )' ) );
+
+% The three figures may be on top of each other. You may have to move the
+% second one next to the first one.
+
+% Play around by changing the number of columns you use for the
+% approximation!
diff --git a/Answers/Week11/CompressPicture_Answer.m b/Answers/Week11/CompressPicture_Answer.m
new file mode 100755
index 0000000..ef3a437
--- /dev/null
+++ b/Answers/Week11/CompressPicture_Answer.m
@@ -0,0 +1,56 @@
+% Close all figures
+close all
+
+% Read the picture in building.png into matrix B
+[ B, map ] = imread( 'building.png' );
+
+% Show the picture in a figure
+imshow( B );
+
+% Choose the (approximate) number of columns you want to use for the
+% aproximation.
+k = 30;
+
+% Extract the number of rows and columns in B
+[ m, n ] = size( B )
+
+% B starts as an integer array. To do the computations, we need to
+% make it into floating point numbers.
+
+B = double( B );
+
+% Pick A as the matrix consisting of about k equally spaced columns of
+% B.
+stride = round( n / k );
+A = B( :, 1:stride:n );
+
+% Replace the comments below with their respective operations from the notebook
+
+% C = A^T A
+C = A' * A;
+
+% V = A^T B
+V = A' * B;
+
+% Overwrite C with its LU factorization
+C = LU_unb_var5( C );
+
+% Extract the unit lower triangular matrix L and upper triangular matrix U.
+L = tril( C, -1 ) + eye( size( C ) );
+U = triu( C );
+
+% Solve L(UX) = V, overwriting V with X
+V = L \ V;
+V = U \ V;
+
+% Create a new figure in which you show the approximated picture. Notice
+% that A and V are matrices of doubles, which much be converted to unsigned
+% 8 byte integers for imshow to work.
+figure
+imshow( uint8( A * V ) );
+
+% The two figures may be on top of each other. You may have to move the
+% second one next to the first one.
+
+% Play around by changing the number of columns you use for the
+% approximation!
diff --git a/Answers/Week11/LU_unb_var5.m b/Answers/Week11/LU_unb_var5.m
new file mode 100755
index 0000000..946b1ba
--- /dev/null
+++ b/Answers/Week11/LU_unb_var5.m
@@ -0,0 +1,34 @@
+function [ A_out ] = LU_unb_var5( A )
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Part_2x2( A, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( ATL, 1 ) < size( A, 1 ) )
+
+ [ A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22 ] = FLA_Repart_2x2_to_3x3( ATL, ATR, ...
+ ABL, ABR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ a21 = laff_invscal( alpha11, a21 );
+ A22 = laff_ger( -1, a21, a12t, A22 );
+
+ %------------------------------------------------------------%
+
+ [ ATL, ATR, ...
+ ABL, ABR ] = FLA_Cont_with_3x3_to_2x2( A00, a01, A02, ...
+ a10t, alpha11, a12t, ...
+ A20, a21, A22, ...
+ 'FLA_TL' );
+
+ end
+
+ A_out = [ ATL, ATR
+ ABL, ABR ];
+
+return
+
diff --git a/Answers/Week11/QR_unb_Answer.m b/Answers/Week11/QR_unb_Answer.m
new file mode 100755
index 0000000..72ee9ba
--- /dev/null
+++ b/Answers/Week11/QR_unb_Answer.m
@@ -0,0 +1,57 @@
+function [ Q_out, R_out ] = QR_unb( A, Q, R )
+
+ [ AL, AR ] = FLA_Part_1x2( A, ...
+ 0, 'FLA_LEFT' );
+
+ [ QL, QR ] = FLA_Part_1x2( Q, ...
+ 0, 'FLA_LEFT' );
+
+ [ RTL, RTR, ...
+ RBL, RBR ] = FLA_Part_2x2( R, ...
+ 0, 0, 'FLA_TL' );
+
+ while ( size( AL, 2 ) < size( A, 2 ) )
+
+ [ A0, a1, A2 ]= FLA_Repart_1x2_to_1x3( AL, AR, ...
+ 1, 'FLA_RIGHT' );
+
+ [ Q0, q1, Q2 ]= FLA_Repart_1x2_to_1x3( QL, QR, ...
+ 1, 'FLA_RIGHT' );
+
+ [ R00, r01, R02, ...
+ r10t, rho11, r12t, ...
+ R20, r21, R22 ] = FLA_Repart_2x2_to_3x3( RTL, RTR, ...
+ RBL, RBR, ...
+ 1, 1, 'FLA_BR' );
+
+ %------------------------------------------------------------%
+
+ %r01 = Q0' * a1;
+ r01 = laff_gemv( 'Transpose', 1, Q0, a1, 0, r01 );
+ a1perp = a1 - Q0 * r01;
+ rho11 = norm( a1perp );
+ q1 = a1perp / rho11;
+
+ %------------------------------------------------------------%
+
+ [ AL, AR ] = FLA_Cont_with_1x3_to_1x2( A0, a1, A2, ...
+ 'FLA_LEFT' );
+
+ [ QL, QR ] = FLA_Cont_with_1x3_to_1x2( Q0, q1, Q2, ...
+ 'FLA_LEFT' );
+
+ [ RTL, RTR, ...
+ RBL, RBR ] = FLA_Cont_with_3x3_to_2x2( R00, r01, R02, ...
+ r10t, rho11, r12t, ...
+ R20, r21, R22, ...
+ 'FLA_TL' );
+
+ end
+
+ Q_out = [ QL, QR ];
+
+ R_out = [ RTL, RTR
+ RBL, RBR ];
+
+return
+
diff --git a/Answers/Week11/building.png b/Answers/Week11/building.png
new file mode 100755
index 0000000..7117644
Binary files /dev/null and b/Answers/Week11/building.png differ
diff --git a/Answers/Week12/CreateMatrixForEigenvalueProblem.m b/Answers/Week12/CreateMatrixForEigenvalueProblem.m
new file mode 100755
index 0000000..8707666
--- /dev/null
+++ b/Answers/Week12/CreateMatrixForEigenvalueProblem.m
@@ -0,0 +1,23 @@
+function [ A, V ] = CreateMatrixForEigenvalueProblem( eigs )
+% Given a column vector eigs with desired eigenvalues, this routine creates
+% a diagonalizable matrix A with eigenvalues eigs, and matrix V the columns
+% of which equal normalized eigenvectors corresponding to the given
+% eigenvalues, in order.
+
+% extract the number of eigenvalues
+n = size( eigs, 1 );
+
+% create a random matrix that is n x n. Almost surely, it is nonsingular.
+V = rand( n, n );
+
+% normalize the columns of V to have norm 1
+for i=1:n
+ V( :, i ) = V( :, i ) / norm( V ( :, i ) );
+end
+
+% Set A = V * diag( x ) * inv( V ) so that the columns of V equal the
+% eigenvectors of A corresponding to the eigenvalues, in order.
+A = V * diag( eigs ) / V;
+
+end
+
diff --git a/Answers/Week12/InversePowerMethodScript.m b/Answers/Week12/InversePowerMethodScript.m
new file mode 100755
index 0000000..1dd0d9c
--- /dev/null
+++ b/Answers/Week12/InversePowerMethodScript.m
@@ -0,0 +1,87 @@
+format long
+
+% Choose the maximum number of iterations of the Inverse Power Method
+% that will be performed.
+k = 20;
+
+% Choose the eigenvalues
+disp( 'input a vector of eigenvalues. e.g.: [ 4; 3; 2; 1 ] ' );
+eigs = input('');
+
+% Make sure that the last entry is equal to smallest in absolute value
+[ eig_min ] = min( abs( eigs( 1:n-1 ) ) );
+if eig_max < abs( eigs( n ) )
+ disp( 'The last entry should be equal to smallest in absolute value.' );
+ break;
+end
+
+% extract the number of eigenvalues
+n = size( eigs, 1 );
+
+[ A, V ] = CreateMatrixForEigenvalueProblem( eigs );
+
+disp( 'Matrix A:' )
+disp( A );
+
+% Print V
+disp( 'Matrix of eigenvectors:' );
+disp( V );
+
+% Print eigenvalues
+disp( 'Eigenvalues:' );
+disp( eigs );
+
+% Create a random initial vector x, and normalize it to have unit length
+x = rand( n, 1 );
+x = x / norm( x );
+
+disp( 'Initial random vector:' )
+disp( x )
+
+disp( 'iteration' );
+disp( 0 );
+
+% Print the length of the component of x orthogonal to the eigenvector
+% associated with the smallest eigenvalue (in magnitude)
+disp( 'The length of the component of x orthogonal to V( :, n ) is ' );
+disp( norm( x - x' * V( :, n ) * V( :, n ) ) );
+
+% Compute the Rayleigh quotient (no need to divide by x' * x since x is
+% of unit length)
+disp( 'Rayleigh quotient:' );
+disp( x' * A * x );
+
+% Compute the LU factorization (with pivoting) of A
+[ L, U, P ] = lu( A );
+
+cont = 1;
+% Perform at most k steps of the Inverse Power Method
+for i=1:k
+ cont = input( 'continue? (0=NO, return = YES)' );
+ if cont == 0
+ break;
+ end
+
+ disp( 'iteration' );
+ disp( i );
+
+ % Next step of Inverse Power Method
+ % x = A \ x; Let's use the LU factorization instead.
+ x = P * x;
+ x = L \ x;
+ x = U \ x;
+ x = x / norm( x );
+
+ % Print the length of the component of x orthogonal to the eigenvector
+ % associated with the smallest eigenvalue (in magnitude)
+ disp( 'The length of the component of x orthogonal to V( :, n ) is ' );
+ disp( norm( x - x' * V( :, n ) * V( :, n ) ) );
+
+ % Compute the Rayleigh quotient (no need to divide by x' * x since x is
+ % of unit length)
+ disp( 'Rayleigh quotient:' );
+ disp( x' * A * x );
+end
+
+
+
diff --git a/Answers/Week12/PowerMethodScript.m b/Answers/Week12/PowerMethodScript.m
new file mode 100755
index 0000000..0cec42d
--- /dev/null
+++ b/Answers/Week12/PowerMethodScript.m
@@ -0,0 +1,83 @@
+format long
+
+% Choose the maximum number of iterations of the power method that will be performed.
+k = 20;
+
+% Choose the eigenvalues
+disp( 'input a vector of eigenvalues. e.g.: [ 4; 3; 2; 1 ] ' );
+eigs = input('');
+
+% Make sure that the first entry is equal to largest in absolute value
+[ eig_max ] = max( abs( eigs( 2:n ) ) );
+if eig_max > abs( eigs( 1 ) )
+ disp( 'The first entry should be equal to largest in absolute value.' );
+ break;
+end
+
+% Create a diagonalizable matrix A with eigenvalues given by eigs and
+% matrix V the columns of which are the corresponding eigenvectors,
+% normalized to have length 1.
+[ A, V ] = CreateMatrixForEigenvalueProblem( eigs )
+
+% extract the number of eigenvalues
+n = size( eigs, 1 );
+
+% Print A
+disp( 'Matrix A:' )
+disp( A );
+
+% Print V
+disp( 'Matrix of eigenvectors:' );
+disp( V );
+
+% Print eigenvalues
+disp( 'Eigenvalues:' );
+disp( eigs );
+
+% Create a random initial vector x, and normalize it to have unit length
+x = rand( n, 1 );
+x = x / norm( x );
+
+disp( 'Initial random vector:' )
+disp( x )
+
+disp( 'iteration' );
+disp( 0 );
+
+% Print the length of the component of x orthogonal to the eigenvector
+% associated with the largest eigenvalue (in magnitude)
+disp( 'The length of the component of x orthogonal to V( :, 1 ) is ' );
+disp( norm( x - x' * V( :, 1 ) * V( :, 1 ) ) );
+
+% Compute the Rayleigh quotient (no need to divide by x' * x since x is
+% of unit length)
+disp( 'Rayleigh quotient:' );
+disp( x' * A * x );
+
+cont = 1;
+
+% Perform at most k steps of the power method
+for i=1:k
+ cont = input( 'continue? (0=NO, return = YES)' );
+ if cont == 0
+ break;
+ end
+
+ disp( 'iteration' );
+ disp( i );
+
+ % Next step of Power Method
+ x = A * x;
+ x = x / norm( x );
+
+ % Print the length of the component of x orthogonal to the eigenvector
+ % associated with the largest eigenvalue (in magnitude)
+ disp( 'The length of the component of x orthogonal to V( :, 1 ) is ' );
+ disp( norm( x - x' * V( :, 1 ) * V( :, 1 ) ) );
+
+ % Compute the Rayleigh quotient (no need to divide by x' * x since x is
+ % of unit length)
+ disp( 'Rayleigh quotient:' );
+ disp( x' * A * x );
+end
+
diff --git a/Answers/Week12/PowerMethodScript2.m b/Answers/Week12/PowerMethodScript2.m
new file mode 100755
index 0000000..a6b62b9
--- /dev/null
+++ b/Answers/Week12/PowerMethodScript2.m
@@ -0,0 +1,90 @@
+format long
+
+% Choose the maximum number of iterations of the power method that will be performed.
+k = 20;
+
+% Choose the eigenvalues
+disp( 'input a vector of eigenvalues. e.g.: [ 4; 3; 2; 1 ] ' );
+eigs = input('');
+
+% Make sure that the first entry is equal to largest in absolute value
+[ eig_max ] = max( abs( eigs( 2:n ) ) );
+if eig_max > abs( eigs( 1 ) )
+ disp( 'The first entry should be equal to largest in absolute value.' );
+ break;
+end
+
+% extract the number of eigenvalues
+n = size( eigs, 1 );
+
+
+disp( 'Now we set the second eigenvalue equal to the negative of the ' );
+disp( 'first one' );
+
+eigs( 2 ) = -eigs( 1 );
+
+[ A, V ] = CreateMatrixForEigenvalueProblem( eigs );
+
+disp( 'Matrix A:' )
+disp( A );
+
+% Print V
+disp( 'Matrix of eigenvectors:' );
+disp( V );
+
+% Print eigenvalues
+disp( 'Eigenvalues:' );
+disp( eigs );
+
+input( 'hit return to continue' );
+
+% Create a random initial vector x, and normalize it to have unit length
+x = rand( n, 1 );
+x = x / norm( x );
+
+disp( 'Initial random vector:' )
+disp( x )
+
+disp( 'iteration' );
+disp( 0 );
+
+% Compute the Rayleigh quotient (no need to divide by x' * x since x is
+% of unit length)
+disp( 'Rayleigh quotient:' );
+disp( x' * A * x );
+
+cont = 1; % (continue = YES)
+
+% Perform at most k steps of the power method
+for i=1:k
+ cont = input( 'continue? (0=NO, return = YES)' );
+ if cont == 0
+ break;
+ end
+
+ disp( 'iteration' );
+ disp( i );
+
+ % Next step of Power Method
+ x = A * x;
+ x = x / norm( x );
+
+ % Print the length of the component of x orthogonal to the eigenvector
+ % associated with the largest eigenvalue (in magnitude)
+ disp( 'The length of the component of x orthogonal to V( :, 1 ) is ' );
+ disp( norm( x - x' * V( :, 1 ) * V( :, 1 ) ) );
+
+ % Compute the Rayleigh quotient (no need to divide by x' * x since x is
+ % of unit length)
+ disp( 'Rayleigh quotient: (notice that this doesnt converge)' );
+ disp( x' * A * x );
+
+ % Print the length of the component of x orthogonal to the eigenvector
+ % associated with the largest eigenvalue (in magnitude)
+ disp( 'The length of the component of x orthogonal to the spaces ' );
+ disp( ' spanned by V( :, 1 ) and V( :, 2 ) is ' );
+ disp( norm( x - ...
+ V( :, 1:2 ) * inv( V( :, 1:2 )' * V( :, 1:2 ) ) * V( :, 1:2 )' * x ) );
+
+end
+
diff --git a/Answers/Week12/RayleighQuotientIterationScript.m b/Answers/Week12/RayleighQuotientIterationScript.m
new file mode 100755
index 0000000..1dec8eb
--- /dev/null
+++ b/Answers/Week12/RayleighQuotientIterationScript.m
@@ -0,0 +1,90 @@
+format long
+
+% Choose the maximum number of iterations of the Inverse Power Method
+% that will be performed.
+k = 20;
+
+% Choose the eigenvalues
+disp( 'input a vector of eigenvalues. e.g.: [ 4; 3; 2; 1 ] ' );
+eigs = input('');
+
+% Make sure that the last entry is equal to smallest in absolute value
+[ eig_min ] = min( abs( eigs( 1:n-1 ) ) );
+if eig_max < abs( eigs( n ) )
+ disp( 'The last entry should be equal to smallest in absolute value.' );
+ break;
+end
+
+% extract the number of eigenvalues
+n = size( eigs, 1 );
+
+
+[ A, V ] = CreateMatrixForEigenvalueProblem( eigs );
+
+disp( 'Matrix A:' )
+disp( A );
+
+% Print V
+disp( 'Matrix of eigenvectors:' );
+disp( V );
+
+% Print eigenvalues
+disp( 'Eigenvalues:' );
+disp( eigs );
+
+% Create a random initial vector x, and normalize it to have unit length
+x = rand( n, 1 );
+x = x / norm( x );
+
+disp( 'Initial random vector:' )
+disp( x )
+
+disp( 'iteration' );
+disp( 0 );
+
+% Print the length of the component of x orthogonal to the eigenvector
+% associated with the smallest eigenvalue (in magnitude)
+disp( 'The length of the component of x orthogonal to V( :, n ) is ' );
+disp( norm( x - x' * V( :, n ) * V( :, n ) ) );
+
+% Compute the Rayleigh quotient (no need to divide by x' * x since x is
+% of unit length)
+disp( 'initial Rayleigh quotient (shift):' );
+sigma = x' * A * x;
+disp( sigma );
+
+% Compute the LU factorization (with pivoting) of A - \sigma I
+% [ L, U, P ] = lu( A - sigma * ( eye( size( A ) ) ));
+
+cont = 1;
+% Perform at most k steps of the Rayleigh Quotient
+for i=1:k
+ cont = input( 'continue? (0=NO, return = YES)' );
+ if cont == 0
+ break;
+ end
+
+ disp( 'iteration' );
+ disp( i );
+
+ % Next step of Rayleigh Quotient Iteration
+ x = ( A - sigma * eye( size( A ) ) ) \ x;
+
+ x = x / norm( x );
+
+ % Since you don't know which eigenvalue and vector the method is
+ % homing in on, showing the length of the component orthogonal to
+ % the last eigenvector is not meaningful.
+ % disp( 'The length of the component of x orthogonal to V( :, n ) is ' );
+ % disp( norm( x - x' * V( :, n ) * V( :, n ) ) );
+
+ % Compute the next Rayleigh quotient (no need to divide by x' * x since x is
+ % of unit length)
+ sigma = x' * A * x;
+
+ disp( 'Rayleigh quotient:' );
+ disp( sigma );
+end
+
+
+
diff --git a/Answers/Week12/ShiftedInversePowerMethodScript.m b/Answers/Week12/ShiftedInversePowerMethodScript.m
new file mode 100755
index 0000000..8106144
--- /dev/null
+++ b/Answers/Week12/ShiftedInversePowerMethodScript.m
@@ -0,0 +1,87 @@
+format long
+
+% Choose the maximum number of iterations of the Inverse Power Method
+% that will be performed.
+k = 20;
+
+% Choose the eigenvalues
+disp( 'input a vector of eigenvalues. e.g.: [ 4; 3; 2; 1 ] ' );
+eigs = input('');
+
+% Make sure that the last entry is equal to smallest in absolute value
+[ eig_min ] = min( abs( eigs( 1:n-1 ) ) );
+if eig_max < abs( eigs( n ) )
+ disp( 'The last entry should be equal to smallest in absolute value.' );
+ break;
+end
+
+[ A, V ] = CreateMatrixForEigenvalueProblem( eigs );
+
+disp( 'Matrix A:' )
+disp( A );
+
+% Print V
+disp( 'Matrix of eigenvectors:' );
+disp( V );
+
+% Print eigenvalues
+disp( 'Eigenvalues:' );
+disp( eigs );
+
+% Ask for a shift
+sigma = input( 'enter a shift to use: (a number close to the smallest eigenvalue) ' );
+
+% Create a random initial vector x, and normalize it to have unit length
+x = rand( n, 1 );
+x = x / norm( x );
+
+disp( 'Initial random vector:' )
+disp( x )
+
+disp( 'iteration' );
+disp( 0 );
+
+% Print the length of the component of x orthogonal to the eigenvector
+% associated with the smallest eigenvalue (in magnitude)
+disp( 'The length of the component of x orthogonal to V( :, n ) is ' );
+disp( norm( x - x' * V( :, n ) * V( :, n ) ) );
+
+% Compute the Rayleigh quotient (no need to divide by x' * x since x is
+% of unit length)
+disp( 'Rayleigh quotient:' );
+disp( x' * A * x );
+
+% Compute the LU factorization (with pivoting) of A - \sigma I
+[ L, U, P ] = lu( A - sigma * ( eye( size( A ) ) ));
+
+cont = 1;
+% Perform at most k steps of the Shifted Inverse Power Method
+for i=1:k
+ cont = input( 'continue? (0=NO, return = YES)' );
+ if cont == 0
+ break;
+ end
+
+ disp( 'iteration' );
+ disp( i );
+
+ % Next step of Inverse Power Method
+ % x = ( A - sigma I ) \ x; Let's use the LU factorization instead.
+ x = P * x;
+ x = L \ x;
+ x = U \ x;
+ x = x / norm( x );
+
+ % Print the length of the component of x orthogonal to the eigenvector
+ % associated with the smallest eigenvalue (in magnitude)
+ disp( 'The length of the component of x orthogonal to V( :, n ) is ' );
+ disp( norm( x - x' * V( :, n ) * V( :, n ) ) );
+
+ % Compute the Rayleigh quotient (no need to divide by x' * x since x is
+ % of unit length)
+ disp( 'Rayleigh quotient:' );
+ disp( x' * A * x );
+end
+
+
+
diff --git a/PictureFLAME/PictureFLAME.html b/PictureFLAME/PictureFLAME.html
new file mode 100755
index 0000000..9e83a42
--- /dev/null
+++ b/PictureFLAME/PictureFLAME.html
@@ -0,0 +1,283 @@
+
+
+
+
+ Picture FLAME
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PictureFLAME
+
+
+
+
+
diff --git a/PictureFLAME/animator.js b/PictureFLAME/animator.js
new file mode 100755
index 0000000..875ef7d
--- /dev/null
+++ b/PictureFLAME/animator.js
@@ -0,0 +1,79 @@
+function Animator(head, foot, loop, maxStep){
+ var auto_next_id = null;
+
+ this.loopHeader = head;
+ this.loopFooter = foot;
+ this.loopCounter = loop;
+
+ this.animation_step = -1;
+ this.max_step = maxStep;
+
+ this.auto_play = false;
+ this.play_id = null;
+
+ this.callback_fn = null;
+}
+
+Animator.prototype.run = function(callback){
+ this.callback_fn = callback;
+ this.auto_play = true;
+ this.next_animation();
+ this.play_id = setTimeout(next, 250);
+}
+
+Animator.prototype.stop = function(){
+ this.auto_play = false;
+ this.play_id = null;
+
+ this.callback_fn.apply();
+}
+
+Animator.prototype.next_animation = function(){
+ //reset to default state
+ if (this.animation_step >= 0){
+ unhighlight_code(this.animation_step);
+ for (var i = 0; i != operands.length; ++i){
+ operands[i].clear_select();
+ }
+ if (this.auto_play)
+ this.play_id = setTimeout(next, 250);
+ }
+
+ //if we are at the end of a loop
+ if (this.animation_step == this.loopFooter){
+
+ //if there are more iterations, decrease loopCount and goto start of loop
+ if (this.loopCounter != 0){
+ this.loopCounter -= 1;
+ this.animation_step = this.loopHeader;
+ }
+ else //otherwise just proceed to the next statement after the loop
+ this.animation_step += 1;
+ }
+ else
+ //if we are at the start of the loop, then check if the loop needs to be executed
+ if (this.animation_step == this.loopHeader){
+ //if loop counter is zero then skip to the end of the loop
+ if (this.loopCounter == 0){
+ this.animation_step = this.loopFooter+1;
+
+ //stop Animation
+ this.stop();
+
+ }
+ else //loop still needs to be executed so proceed
+ this.animation_step += 1;
+ }
+ else { //we are neither at the start nor at the end of the loop
+ this.animation_step += 1;
+ }
+
+ if (this.animation_step < this.max_step){
+ highlight_code(this.animation_step);
+
+ if (this.animation_step != this.loopHeader &&
+ this.animation_step != this.loopFooter)
+ interprete_code(this.animation_step);
+ }
+}
+
\ No newline at end of file
diff --git a/PictureFLAME/codefrags.js b/PictureFLAME/codefrags.js
new file mode 100755
index 0000000..2b8b269
--- /dev/null
+++ b/PictureFLAME/codefrags.js
@@ -0,0 +1,25 @@
+/* function part(operand, type, dir){
+ var elmt = document.getElementById(operand);
+ var tbl = elmt.childNodes[1];
+ if (type=='2x1' || type=='2x2'){
+ tbl.rows[0].className = 'T';
+ }
+ if (type=='1x2' || type=='2x2'){
+ for (var i = 0; i != tbl.rows.length; ++i){
+ tbl.rows[i].cells[0].className += 'L';
+ }
+ }
+ }
+
+*/
+
+ /*
+ repart(oprdExpr.exec(stmt)[0].replace(/\(\s*/g, '').charAt(0),
+ partTypeExpr.exec(stmt)[0], false,
+ partDirExpr.exec(stmt)[0].substring(4));
+*/
+
+/* cont_with(oprdExpr.exec(stmt)[0].replace(/\(\s*/g, '').charAt(0),
+ partTypeExpr.exec(stmt)[0], false,
+ partDirExpr.exec(stmt)[0]);
+*/ }
\ No newline at end of file
diff --git a/PictureFLAME/display_code.js b/PictureFLAME/display_code.js
new file mode 100755
index 0000000..a446fb0
--- /dev/null
+++ b/PictureFLAME/display_code.js
@@ -0,0 +1,22 @@
+
+ function make_statement_frags(stmt){
+ return '';
+ }
+
+ function display_code(stmts){
+ var output = '';
+ for (var i = 0; i != stmts.length; ++i){
+ output += make_statement_frags(stmts[i]);
+ }
+ document.getElementById('display_code').innerHTML = output;
+ }
+
+ function highlight_code(stmtNum){
+ document.getElementById('display_code').childNodes[stmtNum].className
+ = 'curStat';
+ }
+
+ function unhighlight_code(stmtNum){
+ document.getElementById('display_code').childNodes[stmtNum].className = '';
+ }
+
diff --git a/PictureFLAME/display_operand.js b/PictureFLAME/display_operand.js
new file mode 100755
index 0000000..d1f57aa
--- /dev/null
+++ b/PictureFLAME/display_operand.js
@@ -0,0 +1,225 @@
+Operand.prototype.greek = ['alpha','beta','gamma','delta',
+ 'epsilon','phi','chi','eta',
+ 'lambda','mu','nu','pi',
+ 'chi','rho','sigma','tau',
+ 'upsilon','nu','omega','chi',
+ 'psi','zeta'];
+Operand.prototype.caps = ['A','B','C','D',
+ 'E','F','G','H',
+ 'L','M','N','P',
+ 'Q','R','S','T',
+ 'U','V','W','X',
+ 'Y','Z'];
+
+function Operand(tagName, mm, nn){
+ this.tag = tagName;
+ var m = mm;
+ var n = nn;
+
+ var off_m = mm;
+ var off_n = nn;
+
+ var partType = null;
+ var partDir = null;
+
+ var curTop = -1;
+ var curLeft = -1;
+
+ this.subregion = function(index){
+ var elmt = document.getElementById(this.tag);
+ var tbl = elmt.childNodes[1];
+
+ var rStart = 0; var rEnd = tbl.rows.length-1;
+ var cStart = 0; var cEnd = tbl.rows[0].cells.length-1;
+ if (partType != null){
+ if (partType.charAt(0) == '2'){ //2x1 || 2x2
+ if (index.charAt(0) == '0'){ //00, 01, 02
+ rEnd = Math.min(curTop, off_m);
+ }
+
+ if (index.charAt(0) == '1'){
+ rStart = Math.min(curTop, off_m);
+ rEnd = Math.max(curTop, off_m);
+ }
+
+ if (index.charAt(0) == '2'){
+ rStart = Math.max(curTop, off_m);
+ }
+
+ }
+ if (partType.charAt(2) == '2'){ //1x2 || 2x2
+ if (index.charAt(index.length-1) == '0'){
+ cEnd = Math.min(curLeft, off_n);
+ }
+ if (index.charAt(index.length-1) == '1'){
+ cStart = Math.min(curLeft, off_n);
+ cEnd = Math.max(curLeft, off_n);
+ }
+
+ if (index.charAt(index.length-1) == '2'){
+ cStart = Math.max(curLeft, off_n);
+ }
+
+ }
+ }
+
+ return (new Region(this, rStart, rEnd, cStart, cEnd));
+ }
+
+
+ this.match = function (test){
+ var result = false;
+ if (test.length == 1){
+ result =(this.tag.toUpperCase() == test.toUpperCase());
+ }
+ else if (this.tag.length > 1){
+ //this is a scalar operand
+ result = (test == this.tag);
+ }
+ else{
+ //check if greek
+ for (var i = 0; i != this.greek.length; ++i){
+ if (test==this.greek[i]){
+ result |= (this.caps[i] == this.tag.toUpperCase());
+ }
+ }
+ }
+
+ return result;
+ }
+
+ this.clear_select = function(){
+ var elmt = document.getElementById(this.tag);
+ var tbl = elmt.childNodes[1];
+
+
+ for (var i = 0; i != tbl.rows.length; ++i){
+ for (var j = 0; j != tbl.rows[0].cells.length; ++j){
+ if (tbl.rows[i].cells[j].style.backgroundColor != '' ||
+ tbl.rows[i].cells[j].style.backgroundColor != 'undefined')
+ tbl.rows[i].cells[j].style.backgroundColor = '';
+ }
+ }
+ }
+
+ this.select = function (part, color){
+ var region = this.subregion(part);
+
+ if (!color)
+ color='lightblue';
+
+ for (var i= 0; i < region.m(); ++i){
+ for (var j=0; j < region.n(); ++j){
+ var elmt = region.getElementNodeAt(i,j);
+ elmt.style.backgroundColor = color;
+ }
+ }
+
+ }
+
+
+ this.display = function(){
+ var output = '';
+ var colgroup = '';
+ for (var i = 0; i != m+1 ; ++i){
+ var row = '';
+ for (var j = 0; j != n+1; ++j){
+ colgroup += '';
+ row += '| '+
+ (i==0 || j==0?'':String(Math.floor(Math.random()*10)-5).substring(0,7))+
+ ' | ';
+ }
+ row += '
';
+ colgroup += '';
+ output += colgroup;
+ output += row;
+ }
+ output += '
';
+ return output;
+ }
+
+ this.partition = function(type, dir){
+ partType = type;
+
+ partDir = dir;
+ if (dir.length > 2){
+ partDir = dir.charAt(0);
+ }
+
+ var elmt = document.getElementById(this.tag);
+ var tbl = elmt.childNodes[1];
+ if (type=='2x1' || type=='2x2'){
+ if (partDir.charAt(0) == 'T'){
+ curTop = 0;
+ }
+ else{
+ curTop = tbl.rows.length-1;
+ }
+ tbl.rows[curTop].className = 'T';
+ }
+ if (type=='1x2' || type=='2x2'){
+ if (partDir.charAt(partDir.length-1) == 'L')
+ curLeft = 0;
+ else{
+ curLeft = tbl.rows[0].cells.length-1;
+ }
+ for (var i = 0; i != tbl.rows.length; ++i){
+ tbl.rows[i].cells[curLeft].className = 'L';
+ }
+
+ }
+ }
+
+ this.repartition = function(mm, nn){
+ mm = (typeof(mm) !== 'undefined'? mm : 1);
+ nn = (typeof(nn) !== 'undefined'? nn : 1);
+
+ var elmt = document.getElementById(this.tag);
+ var tbl = elmt.childNodes[1];
+
+ if (partDir.charAt(0) == 'B')
+ mm *= -1;
+ if (partDir.charAt(partDir.length-1) == 'R'){
+ nn *= -1;
+ }
+
+ //repartition
+ if (partType=='2x1' || partType=='2x2'){
+ tbl.rows[curTop+mm].className = 'B';
+ off_m = curTop+mm;
+ }
+ if (partType=='1x2' || partType=='2x2'){
+ for (var i = 0; i != tbl.rows.length; ++i){
+ tbl.rows[i].cells[curLeft+nn].className = 'R';
+ }
+ off_n = curLeft+nn;
+ }
+ }
+
+ this.cont_with = function (){
+ var elmt = document.getElementById(this.tag);
+ var tbl = elmt.childNodes[1];
+
+ for (var i = 0; i != tbl.rows.length; ++i){
+ if (tbl.rows[i].className == 'T')
+ tbl.rows[i].className = '';
+ else if (tbl.rows[i].className == 'B'){
+ tbl.rows[i].className = 'T';
+ curTop = i;
+ }
+
+ for (var j = 0; j != tbl.rows[i].cells.length; ++j){
+
+ if (tbl.rows[i].cells[j].className == 'L')
+ tbl.rows[i].cells[j].className = '';
+ else if (tbl.rows[i].cells[j].className == 'R'){
+ tbl.rows[i].cells[j].className = 'L';
+ curLeft = j;
+ }
+
+ }
+
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/PictureFLAME/parse_code.js b/PictureFLAME/parse_code.js
new file mode 100755
index 0000000..d7ea2e4
--- /dev/null
+++ b/PictureFLAME/parse_code.js
@@ -0,0 +1,187 @@
+ function parse_fn(stmt){
+ var paramExpr = /\(.*\)/gi;
+ var fnNameExpr = /laff\.[^\(]+/gi;
+
+ var fnName = fnNameExpr.exec(stmt);
+ var oprds = new Array();
+ if (fnName){
+ //there exist a laff function
+
+ //get name
+ fnName = fnName[0];
+
+ //get parameters
+ var params = paramExpr.exec(stmt)[0];
+
+ var paramList = params.split(',');
+
+ //remove ( and ) from the first and last param
+ paramList[0] = paramList[0].substr(1);
+ paramList[paramList.length-1] = paramList[paramList.length-1].substr(0,paramList[paramList.length-1].length-1);
+
+ //parse arguments
+ for (var i = 0; i != paramList.length; ++i)
+ oprds.push(parse_oprd(paramList[i]));
+
+ }
+
+ return {fn:fnName, args:oprds}
+ }
+
+ function parse_stmt(stmt){
+ //remove ending ; and empty spaces
+ stmt = stmt.replace(';','').replace(/\s+/g, '');
+
+ var operators = /[=]/gim;
+ var exprs = stmt.split(operators);
+ // var fns = new Array();
+ var rtn;
+
+ switch (exprs.length){
+ case 1: //blas like function call
+ rtn = parse_fn(stmt);
+ break;
+ case 2:
+ //A = f() or A=B
+ new_stmt = exprs[1].replace("_", ".");
+ if (exprs[1].substr(0, 4) == 'laff'){
+ //A = f()
+
+ rtn = parse_fn(new_stmt);
+ //check if we need to add the additional operand from the lhs
+ output = parse_oprd(exprs[0]);
+
+ if (rtn.args[rtn.args.length-1].op != output.op){
+ rtn.args.push(output);
+ }
+
+ }
+ else{
+ alert("Please use the laff functions\n");
+ }
+ break;
+
+ default:
+ alert("Unable to parse code\n")
+ break;
+ }
+
+ return rtn;
+ }
+
+
+ function parse_oprd(oprd){
+ //remove transpose
+ oprd = oprd.replace(/t$/gi,'');
+
+ var comdExpr = /\'.*\'/gi;
+
+ if (Number(oprd).toString() == oprd ||
+ Number(oprd).toString()+".0" == oprd){
+ return {op:'',subregion:oprd}
+ }
+ else if (comdExpr.exec(oprd)){
+ return {op:'', subregion:oprd}
+ }
+ else{
+ var name = oprd.match(/[A-z]+/gi)[0];
+ var anyIndex = oprd.match(/[012]+/gi);
+ var index = null;
+ if (anyIndex)
+ index = anyIndex[0];
+
+ return {op:name, subregion:index};
+ }
+ }
+
+
+
+ function parse_fn_header(fnHeader){
+
+ var fnNameExpr = /([A-z_]+[_A-z0-9]*\s*)\(/g;
+ var fnName = fnNameExpr.exec(fnHeader)[0].replace(/\s/g,'');
+
+ var fnParamsExpr = /\((.|\s)*\)/gm;
+ var params = fnParamsExpr.exec(fnHeader)[0].replace(/\s/g,'');
+ params = params.substring(1,params.length-1);
+
+ var blked_alg = params.search(/nb_alg/gi);
+ if (blked_alg != -1)
+ params.replace(",nb_alg", '');
+
+ return {name: fnName.substring(0,fnName.length-1),
+ blocked: (blked_alg==-1),
+ operands: params.split(',')};
+ }
+
+ function parse(code){
+ //parse input file
+ //remove comments
+ var newCode = code.replace(/\%.*\n/g, '');
+ if (DEFAULT_MODE == 2){
+ newCode = code.replace(/\#.*\n/g,'');
+ newCode = newCode.replace('import flame','');
+ }
+
+ //remove empty lines
+ newCode = newCode.replace(/\s*\n+/g,'\n');
+
+ //function header
+ var fnHeaderExpr = /^\s*function(.*)/m;
+ if (DEFAULT_MODE == 2)
+ fnHeaderExpr = /^\s*def(.*)/m;
+
+ var fnHeader = fnHeaderExpr.exec(newCode)[0];
+ newCode = newCode.replace(fnHeaderExpr, '');
+
+ //identify loop
+ var loopExpr = /\s*while(\s|\S)*end/m;
+ if (DEFAULT_MODE == 2)
+ loopExpr = /\s*while((\s|\S)(?!flame\.merge))*/gm;
+
+ var loop = loopExpr.exec(newCode)[0];
+
+ var headerExpr = /\s*while(.*)/;
+ if (DEFAULT_MODE == 2)
+ headerExpr = /\s*while.*:/;
+ var header = headerExpr.exec(loop);
+ loop = loop.replace(header[0],'');
+
+ var footerExpr = /\s*end/gmi;
+ var footer = footerExpr.exec(loop);
+ if (DEFAULT_MODE == 2)
+ footer = [""];
+
+ if (DEFAULT_MODE == 1)
+ loop = loop.replace(/end$/gim,'');
+
+ var codeParts = newCode.split(loopExpr);
+
+ //identify statements
+ var stmtExpr= /[^;]+;/gm;
+ if (DEFAULT_MODE == 2)
+ stmtExpr = /[^)]*\)/gm;
+
+ //initialization
+ var codeStmts = codeParts[0].match(stmtExpr);
+
+ var loopHeadPos = codeStmts.length;
+
+ // loop header
+ codeStmts.push(header[0]);
+
+ //looped statment
+ codeStmts = codeStmts.concat(loop.match(stmtExpr));
+
+ var loopFootPos = codeStmts.length;
+
+ // loop end
+ codeStmts.push(footer[0]);
+
+ //clean up
+// codeStmts = codeStmts.concat(codeParts[1].match(stmtExpr));
+
+
+ return {fn:fnHeader, code:codeStmts,
+ head:loopHeadPos, foot:loopFootPos};
+ }
diff --git a/PictureFLAME/regions.js b/PictureFLAME/regions.js
new file mode 100755
index 0000000..75a5e66
--- /dev/null
+++ b/PictureFLAME/regions.js
@@ -0,0 +1,35 @@
+function Region(op, sr, er, sc, ec){
+
+ var startRow = sr;
+ var startCol = sc;
+
+ var endRow = er;
+ var endCol = ec;
+
+ var oprd = op;
+
+ var elmt = document.getElementById(op.tag);
+ var tbl = elmt.childNodes[1];
+
+
+ this.getElementAt = function (i,j){
+ return Number(tbl.rows[i+startRow+1].cells[j+startCol+1].innerHTML);
+ }
+
+ this.getElementNodeAt = function (i,j){
+ return tbl.rows[i+startRow+1].cells[j+startCol+1];
+ }
+
+ this.setElementAt = function (i,j, newVal){
+ tbl.rows[i+startRow+1].cells[j+startCol+1].innerHTML = Number(newVal);//toFixed(5);
+ }
+
+ this.m = function(){
+ return endRow - startRow;
+ }
+
+ this.n = function(){
+ return endCol - startCol;
+ }
+
+}
\ No newline at end of file
diff --git a/PictureFLAME/routines.js b/PictureFLAME/routines.js
new file mode 100755
index 0000000..2d95176
--- /dev/null
+++ b/PictureFLAME/routines.js
@@ -0,0 +1,68 @@
+function gemv(tt, aa, AA, xx, bb, yy){
+ var x_op, y_op, A_op, alpha_op, beta_op;
+
+ var scala = extract_scalar_value(aa);
+ var scalb = extract_scalar_value(bb);
+
+ var x = extract_region(xx);
+ var y = extract_region(yy);
+ var A = extract_region(AA);
+
+ var transa = tt.subregion;
+
+ if ( y.m() == A.m()
+ && x.m() == A.n()){
+ //both x, y are column vector
+ }
+ else if ( y.n() == A.m()
+ && x.m() == A.n()){
+ //y is a row, x is a column
+ }
+ else if ( y.n() == A.m()
+ && x.n() == A.n()){
+ //both are rows
+ }
+ else if ( y.m() == A.m()
+ && x.n() == A.n()){
+ //x is a row, y is a column
+ }
+
+ if (transa == "'Notranspose'"){
+ for (var i = 0; i != A.m(); ++i){
+ y.setElementAt(i,0,
+ scalb * y.getElementAt(i,0));
+
+ for (var j = 0; j != A.n(); ++j){ //dot product
+ y.setElementAt(i,0,
+ y.getElementAt(i,0) +
+ scala * x.getElementAt(j,0) * A.getElementAt(i,j));
+ }
+ }
+
+ }
+ else{
+ for (var i = 0; i != A.n(); ++i){
+ if (y.m() == 1){ //y is a row vector
+ y.setElementAt(0,i,
+ scalb * y.getElementAt(0,i));
+ }
+ else{ //y is a column vector
+ y.setElementAt(i,0,
+ scalb * y.getElementAt(i,0));
+ }
+
+ for (var j = 0; j != A.m(); ++j){ //dot product
+ accum += x.getElementAt(0,j) * A.getElementAt(j,i);
+ }
+
+ if (y.m() == 1){ //y is a row vector
+ y.setElementAt(0,i,
+ y.getElementAt(0,i) + scala * accum );
+ }
+ else{ //y is a column vector
+ y.setElementAt(i,0,
+ y.getElementAt(i,0) + scala * accum );
+ }
+ }
+ }
+}
diff --git a/PictureFLAME/routines_2.js b/PictureFLAME/routines_2.js
new file mode 100755
index 0000000..4abd707
--- /dev/null
+++ b/PictureFLAME/routines_2.js
@@ -0,0 +1,326 @@
+function execute_BLAS(stmt){
+ if (stmt.fn == 'laff.zerov'){
+ assign(stmt.args[0], 0.0000);
+ }
+ if (stmt.fn == 'laff.onev'){
+ assign(stmt.args[0], 1.0000);
+ }
+ if (stmt.fn == 'laff.copy'){
+ copy(stmt.args[0], stmt.args[1]);
+ }
+ if (stmt.fn == 'laff.scal'){
+ scal(stmt.args[0], stmt.args[1], false);
+ }
+ if (stmt.fn == 'laff.invscal'){
+ scal(stmt.args[0], stmt.args[1], true);
+ }
+ if (stmt.fn == 'laff.add'){
+ add(stmt.args[0], stmt.args[1], stmt.args[2]);
+ }
+ if (stmt.fn == 'laff.dots'){
+ dot(stmt.args[0], stmt.args[1], stmt.args[2], true);
+ }
+ if (stmt.fn == 'laff.dot'){
+ dot(stmt.args[0], stmt.args[1], stmt.args[2], false);
+ }
+ if (stmt.fn == 'laff.axpy'){
+ axpy(stmt.args[0], stmt.args[1], stmt.args[2]);
+ }
+
+ if (stmt.fn == 'laff.mac'){
+ mac(stmt.args[0], stmt.args[1], stmt.args[2]);
+ }
+ if (stmt.fn == 'laff.ger'){
+ ger(stmt.args[0], stmt.args[1], stmt.args[2], stmt.args[3]);
+ }
+ if (stmt.fn == 'laff.gemv'){
+ gemv(stmt.args[0], stmt.args[1], stmt.args[2], stmt.args[3], stmt.args[4], stmt.args[5]);
+ }
+
+}
+
+
+function extract_region(xx){
+ var x_op;
+ //find operands
+ for (var i = 0; i != operands.length; ++i){
+ if (operands[i].match(xx.op))
+ x_op = i;
+ }
+
+ //get region
+ return operands[x_op].subregion(xx.subregion);
+}
+
+function is_scalar(aa){
+ var rtn;
+ rtn = (aa.op=='');
+ if (!rtn){
+ var alpha = extract_region(aa);
+ rtn = (alpha.m()== 1 && alpha.n()==1);
+ }
+ return rtn;
+}
+
+function extract_scalar_value(aa){
+ var scal = 1;
+
+ if (aa.op== ''){
+ //alpha is a constant
+ scal = Number(aa.subregion);
+ }
+ else{
+ //alpha is an operand
+
+ var alpha = extract_region(aa);
+ scal = Number(alpha.getElementAt(0,0));
+ }
+ return scal;
+}
+
+
+function assign(xx, val){
+ var x = extract_region(xx);
+
+ for (var j = 0; j < x.m(); ++j){
+ for (var k = 0; k < x.n(); ++k){
+ x.setElementAt(j, k, val);
+ }
+ }
+}
+
+
+function copy(oprdOld, oprdNew){
+ var src_region = extract_region(oprdOld);
+ var dst_region = extract_region(oprdNew);
+
+ if (src_region.m() == dst_region.m() &&
+ src_region.n() == dst_region.n()){ //same shape
+
+ for (var j = 0; j < src_region.m(); ++j){
+ for (var k = 0; k < src_region.n(); ++k){
+ dst_region.setElementAt(j,k,
+ src_region.getElementAt(j,k));
+ }
+ }
+ }
+
+ if (src_region.m() == dst_region.n() &&
+ src_region.n() == dst_region.m() ){ //transposed vector
+
+ for (var j = 0; j < dst_region.m(); ++j){
+ for (var k = 0; k < dst_region.n(); ++k){
+ dst_region.setElementAt(j,k,
+ src_region.getElementAt(k,j));
+ }
+ }
+ }
+}
+
+function scal(aa, xx, inv){
+ var x_op, scal;
+
+ scal = extract_scalar_value(aa);
+ //find operands
+ for (var i = 0; i != operands.length; ++i){
+ if (operands[i].match(xx.op))
+ x_op = i;
+ }
+
+ //get region
+ var x = operands[x_op].subregion(xx.subregion);
+
+ for (var j = 0; j != x.m(); ++j){
+ for (var k = 0; k != x.n(); ++k){
+ if (!inv)
+ x.setElementAt(j, k, x.getElementAt(j, k) * scal);
+ else
+ x.setElementAt(j, k, x.getElementAt(j, k) / scal);
+ }
+ }
+}
+
+function add(xx, yy, zz){
+ var x = extract_region(xx);
+ var y = extract_region(yy);
+ var z = extract_region(zz);
+
+ if (x.m() == y.m() &&
+ x.n() == y.n() &&
+ x.m() == z.m() &&
+ x.n() == z.n() ){
+ for (var i = 0; i != x.m(); ++i){
+ for (var j = 0; j != x.n(); ++j){
+ z.setElementAt(i, j, x.getElementAt(i, j) + y.getElementAt(i, j));
+ }
+ }
+ }
+}
+
+
+function dot(xx, yy, aa, add_alpha){
+ var x_op, y_op, alpha_op;
+
+ var x = extract_region(xx);
+ var y = extract_region(yy);
+ var alpha = extract_region(aa);
+
+ var outputVal = 0;
+
+ //check dimensions
+ if (x.m() == 1 && y.m()== 1){
+ //both row vectors
+ for ( var i = 0; i != x.n(); ++i){
+ outputVal +=
+ Number(x.getElementAt(0,i)) * Number(y.getElementAt(0,i));
+ }
+ }
+ else if (x.n() == 1 && y.m()== 1){
+ //x is col vector, y is row vector
+ for ( var i = 0; i != x.m(); ++i){
+ outputVal +=
+ Number(x.getElementAt(i,0)) * Number(y.getElementAt(0,i));
+ }
+ }
+ else if (x.m() == 1 && y.n()== 1){
+ //y is col vector, x is row vector
+ for ( var i = 0; i != x.n(); ++i){
+ outputVal +=
+ Number(x.getElementAt(0,i)) * Number(y.getElementAt(i,0));
+ }
+ }
+ else if (x.n() == 1 && y.n()== 1){
+ //both col vectors
+ for ( var i = 0; i != x.m(); ++i){
+ outputVal +=
+ Number(x.getElementAt(i,0)) * Number(y.getElementAt(i,0));
+ }
+ }
+ if (add_alpha){
+ alpha.setElementAt(0,0, outputVal + alpha.getElementAt(0, 0));
+ }
+ else{
+ alpha.setElementAt(0,0, outputVal);
+ }
+}
+
+
+function axpy(aa, xx, yy){
+
+ var scal = extract_scalar_value(aa);
+ var x = extract_region(xx);
+ var y = extract_region(yy);
+
+ //compute
+ if (x.m() == 1 && y.m()== 1){
+ //both row vectors
+ for ( var i = 0; i != x.n(); ++i){
+ y.setElementAt(0,i,
+ scal * Number(x.getElementAt(0,i))
+ + Number(y.getElementAt(0,i)));
+ }
+ }
+ else if (x.n() == 1 && y.m()== 1){
+ //y is a row vector, x is a column
+ for ( var i = 0; i != x.m(); ++i){
+ y.setElementAt(0,i,
+ scal * Number(x.getElementAt(i,0))
+ + Number(y.getElementAt(0,i)));
+ }
+ }
+ else if (x.m() == 1 && y.n()== 1){
+ //x is a row vector, y is a column
+ for ( var i = 0; i != x.n(); ++i){
+ y.setElementAt(i,0,
+ scal * Number(x.getElementAt(0,i))
+ + Number(y.getElementAt(i,0)));
+ }
+ }
+ else if (x.n() == 1 && y.n() == 1){
+ //both col vectors
+ for ( var i = 0; i != x.m(); ++i){
+ y.setElementAt(i,0,
+ scal * Number(x.getElementAt(i,0))
+ + Number(y.getElementAt(i,0)));
+ }
+ }
+}
+
+
+function mac(xx, yy, aa){
+ var x = extract_region(xx);
+ var y = extract_region(yy);
+ var alpha = extract_region(aa);
+
+ if (x.m() == 1 && y.m() == 1 &&
+ x.n() == 1 && y.n() == 1 &&
+ alpha.m() == 1 && alpha.n() == 1){
+ //everything is a scalar
+
+ alpha.setElementAt(0, 0, x.getElementAt(0,0) + y.getElementAt(0,0));
+ }
+}
+
+
+function ger(aa, xx, yy, CC){
+ var scal = extract_scalar_value(aa);
+
+ var x = extract_region(xx);
+ var y = extract_region(yy);
+ var C = extract_region(CC);
+
+ if (x.m() == C.m() && y.n() == C.n() &&
+ x.n() == 1 && y.m() == 1){
+
+ for (var i = 0; i != C.m(); ++i){
+ for (var j = 0; j != C.n(); ++j){
+ C.setElementAt(i, j,
+ C.getElementAt(i,j) + scal * x.getElementAt(i,0)*y.getElementAt(0,j));
+ }
+ }
+ }
+
+}
+
+
+function gemv(tt, aa, AA, xx, bb, yy){
+ var alpha = extract_scalar_value(aa);
+ var beta = extract_scalar_value(bb);
+
+ var A = extract_region(AA);
+ var x = extract_region(xx);
+ var y = extract_region(yy);
+
+ var trans = (tt.subregion != "'Notranspose'");
+
+ var tmp = 0;
+ if (!trans){ //y = alpha Ax + beta y
+ //x and y are both column vectors
+ if (x.n()==1 && y.n()==1){
+ for (var i = 0; i != A.m(); ++i){
+ tmp = 0;
+ for (var j = 0; j != A.n(); ++j){
+ tmp += A.getElementAt(i, j) * x.getElementAt(j, 0);
+ }
+ y.setElementAt(i,0,
+ alpha * tmp + beta * y.getElementAt(i,0));
+ }
+ }
+ //x and y are both row vectors
+ //x is a column and y is a row
+ //y is a column and x is a row
+ }
+ else{ //y = alpha A'x + beta y
+ //x and y are both row vectors
+ if (x.m()==1 && y.m()==1){
+ for (var i = 0; i != A.n(); ++i){
+ tmp = 0;
+ for (var j = 0; j != A.m(); ++j){
+ tmp += A.getElementAt(j,i) * x.getElementAt(0,j);
+ }
+ y.setElementAt(0, i,
+ alpha * tmp + beta * y.getElementAt(0, i));
+ }
+ }
+ }
+}
diff --git a/PictureFLAME/style.css b/PictureFLAME/style.css
new file mode 100755
index 0000000..ca3db94
--- /dev/null
+++ b/PictureFLAME/style.css
@@ -0,0 +1,192 @@
+body {
+ font-family:"Trebuchet MS", Helvetica, sans-serif;
+}
+
+div {
+ padding:0px;
+ margin:0px;
+}
+
+table.matrix{
+ border-collapse:collapse;
+ margin:20px;
+ padding-top:0px;
+ margin-left: -7px;
+ margin-top: -23px;
+}
+table.matrix tr.T {
+ border-bottom:6px solid black;
+ padding-bottom:-6px;
+}
+table.matrix tr.B {
+ border-bottom:2px solid black;
+ height:14px;
+}
+table.matrix td.L {
+ border-right:6px solid black;
+ padding-right:-6px;
+}
+
+table.matrix td.R {
+ border-right:2px solid black;
+ width:14px;
+}
+
+table.matrix td, .defaulttd {
+ text-align:center;
+ width:16px;
+ height:16px;
+ padding:5px;
+ font-size:small;
+}
+
+.defaulttr{
+ border:0px none black;
+}
+
+.group_header{
+ display:box;
+ margin:10px;
+ padding:10px;
+ width:582px;
+ border:1px solid lightgray;
+ font-size:large;
+ background-color:orange;
+}
+
+#display_code, #display_pic{
+ display:box;
+ margin:10px;
+ padding:10px;
+ float:left;
+}
+
+#display_code{
+ width:582px;
+ margin:10px;
+ border:1px solid orange;
+ font-size:small;
+}
+
+#display_code .curStat{
+ color:red;
+}
+
+#display_pic{
+ float:right;
+ padding:0px;
+ margin:0px;
+}
+
+#display_pic .operand0 {
+ font-size:x-large;
+ float:left;
+ clear:left;
+}
+
+#display_pic .operand1 {
+ font-size:x-large;
+ float:left;
+}
+
+#display_pic .operand .matrix{
+
+}
+
+
+#footer{
+ margin-left:auto;
+ margin-right:auto;
+ width:60%;
+}
+
+#footer li {
+ display:inline;
+ list-style-type:none;
+}
+
+#footer li a{
+ padding: 0px 5px;
+ border-left:1px solid orange;
+ border-right:1px solid orange;
+ font-size:small;
+ color:gray;
+ text-decoration:none;
+}
+
+#footer li a:visited{
+ color:gray;
+}
+
+#footer li a:hover{
+ color:orange;
+}
+
+
+#nav {
+ height:40px;
+}
+#nav ul{
+ background-color:orange;
+ padding-left:0px;
+ padding-top:10px;
+ padding-bottom:10px;;
+ margin-left:0px;
+}
+#nav li{
+ display:inline;
+ list-style-type:none;
+ background-color:orange;
+ padding:0px 20px;
+ font-size:large;
+}
+
+#nav a:link, #nav a:visited {
+ color:black;
+ text-decoration:none;
+}
+#nav a:hover {
+ color:white;
+ text-decoration:none;
+}
+
+#display_block{
+// border:1px solid blue;
+ height:350px;
+}
+
+#display_header ul{
+ background-color:orange;
+ margin-left:0px;
+}
+
+#display_header li{
+ display:inline;
+ font-size:x-large;
+ padding:0px 25px;
+ margin:0px;
+}
+#display_header li.spacer{
+ display:inline;
+ font-size:xx-large;
+ font-weight:bolder;
+ padding:0px;
+ margin:0px;
+}
+
+
+.display_item .header a:link, .display_item .header a:visited {
+ color:black;
+ text-decoration:none;
+}
+
+.display_item .header a:hover{
+ text-decoration:none;
+ color:white;
+}
+
+.display_item div{
+ padding:10px;
+}
+
+#publications ul li{
diff --git a/Practice/GaussianEliminationPractice/4x4.html b/Practice/GaussianEliminationPractice/4x4.html
new file mode 100755
index 0000000..7380211
--- /dev/null
+++ b/Practice/GaussianEliminationPractice/4x4.html
@@ -0,0 +1,182 @@
+
+
+
+LU
+
+
+
+
+
+
+
+
+
+
+
6.2.1 Reducing a System of Linear Equations to an Upper
+ Triangular System
+
+
+
Original Equation
+
+
+
+
After 1 Step
+
+
+
+
After 2 Steps
+
+
+
+
After 3 Steps
+
+
+
+
+
6.2.2 Appended Matrix
+
+
+
Original Appended Matrix
+
+
+
+
After 1 Step
+
+
+
+
After 2 Steps
+
+
+
+
After 3 Steps
+
+
+
+
+
6.2.3 Gauss Transforms
+
+
+
Original Appended Matrix
+
+
+
+
After 1 Step
+
+
+
+
After 2 Steps
+
+
+
+
After 3 Steps
+
+
+
+
+
6.2.4 Separate Forward Substitution
+
+
+
+
Original Matrix A
+
+
+
+
After 1 Step
+
+
+
+
After 2 Steps
+
+
+
+
After 3 Steps
+
+
+
+
+
Original Vector b
+
+
+
After 1 Step
+
+
+
After 2 Steps
+
+
+
After 3 Steps
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
6.2.1 Reducing a System of Linear Equations to an Upper
+ Triangular System
+
+
+
Original Equation
+
+
+
+
After 1 Step
+
+
+
+
After 2 Steps
+
+
+
+
+
6.2.2 Appended Matrix
+
+
+
Original Appended Matrix
+
+
+
+
After 1 Step
+
+
+
+
After 2 Steps
+
+
+
+
+
6.2.3 Gauss Transforms
+
+
+
Original Appended Matrix
+
+
+
+
After 1 Step
+
+
+
+
After 2 Steps
+
+
+
+
+
6.2.4 Separate Forward Substitution
+
+
+
+
Original Matrix A
+
+
+
+
After 1 Step
+
+
+
+
After 2 Steps
+
+
+
+
+
Original Vector b
+
+
+
After 1 Step
+
+
+
After 2 Steps
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
6.2.1 Reducing a System of Linear Equations to an Upper
+ Triangular System
+
+
+
Original Equation
+
+
+
+
After 1 Step
+
+
+
+
After 2 Steps
+
+
+
+
+
6.2.2 Appended Matrix
+
+
+
Original Appended Matrix
+
+
+
+
After 1 Step
+
+
+
+
After 2 Steps
+
+
+
+
+
6.2.3 Gauss Transforms
+
+
+
Original Appended Matrix
+
+
+
+
After 1 Step
+
+
+
+
After 2 Steps
+
+
+
+
+
6.2.4 Separate Forward Substitution
+
+
+
+
Original Matrix A
+
+
+
+
After 1 Step
+
+
+
+
After 2 Steps
+
+
+
+
+
Original Vector b
+
+
+
After 1 Step
+
+
+
After 2 Steps
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Pick an output language:
+
+
+
+
+
+
+
+
+
+Additional Information
+
+
+
+
+| Name of Author |
+
+
+ |
+
+
+| E-mail of Author |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+