Create repo

This commit is contained in:
Julien Lengrand-Lambert
2018-05-02 09:13:08 +02:00
commit d4dce71599
243 changed files with 19406 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

0
.gitignore vendored Normal file
View File

BIN
1521Instructions.pdf Executable file

Binary file not shown.

BIN
Answers/.DS_Store vendored Normal file

Binary file not shown.

60
Answers/Week01/Dot_unb.m Executable file
View File

@@ -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

View File

@@ -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

73
Answers/Week01/PrintMVProblem.m Executable file
View File

@@ -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<m_A
outstring = '| ';
else
outstring = ' ';
end
for j=1:n_A
if i<=m_A
outstring = [ outstring sprintf( '%2d ', A( i,j ) ) ];
else
outstring = [ outstring ' ' ];
end
end
if m_A == 1 & i == 1
outstring = [ outstring '> ' ];
elseif i == 1
outstring = [ outstring '\ '];
elseif i==m_A
outstring = [ outstring '/ '];
elseif i<m_A
outstring = [ outstring '| '];
else
outstring = [ outstring ' '];
end
if m_x == 1 & i == 1
outstring = [ outstring '< ' ];
elseif i == 1
outstring = [ outstring '/ '];
elseif i==m_x
outstring = [ outstring '\ '];
elseif i<m_x
outstring = [ outstring '| '];
else
outstring = [ outstring ' '];
end
if i <= m_x
outstring = [ outstring sprintf( '%d ', x( i ) ) ];
end
if m_x == 1 & i == 1
outstring = [ outstring '>' ];
elseif i == 1
outstring = [ outstring '\ ' ];
elseif i==m_x
outstring = [ outstring '/ '];
elseif i<m_x
outstring = [ outstring '| ' ];
end
disp( outstring )
end
disp( '=' )
end

47
Answers/Week01/laff_copy.m Executable file
View File

@@ -0,0 +1,47 @@
function [ y_out ] = laff_copy( x, y )
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
[ m_x, n_x ] = size( x );
[ m_y, n_y ] = size( y );
if ~isvector( x ) | ~isvector( y )
disp( 'copy failed' );
y_out = 'FAILED';
return
end
if ~( m_x * n_x == m_y * n_y )
disp( 'copy failed' );
y_out = 'FAILED';
return
end
if n_x == 1 % x is a column
if n_y == 1 % y is a column
for i = 1:m_x
y( i, 1 ) = x( i, 1 );
end
else % y is a row
for i = 1:m_x
y( 1, i ) = x( i, 1 );
end
end
else % x is a row
if n_y == 1 % y is a column
for i = 1:n_x
y( i, 1 ) = x( 1, i );
end
else % y is a row
for i = 1:n_x
y( 1, i ) = x( 1, i );
end
end
end
y_out = y;
return
end

98
Answers/Week01/test_axpy.m Executable file
View File

@@ -0,0 +1,98 @@
% Create some vectors
x = [
1
2
3
]
y = [
0
-1
-2
]
z = [
4
3
2
1
]
% Create a scalar
alpha = -2
% test column - column axpy
disp( 'column - column axpy' )
if ( isequal( laff_axpy( alpha, x, y ), alpha * x + y ) )
disp( 'TEST PASSED' )
else
disp( 'TEST FAILED' )
end
disp( ' ' )
% test column - row axpy
disp( 'column - row axpy' )
if ( isequal( laff_axpy( alpha, x, y' ), alpha * x' + y' ) )
disp( 'TEST PASSED' )
else
disp( 'TEST FAILED' )
end
disp( ' ' )
% test row - column axpy
disp( 'row - column axpy' )
if ( isequal( laff_axpy( alpha, x', y ), alpha * x + y ) )
disp( 'TEST PASSED' )
else
disp( 'TEST FAILED' )
end
disp( ' ' )
% test row -> 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

95
Answers/Week01/test_copy.m Executable file
View File

@@ -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

95
Answers/Week01/test_dot.m Executable file
View File

@@ -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

47
Answers/Week01/test_norm2.m Executable file
View File

@@ -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

54
Answers/Week01/test_scal.m Executable file
View File

@@ -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

BIN
Answers/Week03/AllAlgorithms.pdf Executable file

Binary file not shown.

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

25
Answers/Week03/ZeroMatrix_unb.m Executable file
View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

Binary file not shown.

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

35
Answers/Week05/Gemm_unb_var1.m Executable file
View File

@@ -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

50
Answers/Week05/Gemm_unb_var2.m Executable file
View File

@@ -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

42
Answers/Week05/Gemm_unb_var3.m Executable file
View File

@@ -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

15
Answers/Week05/MatMatMult.m Executable file
View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

34
Answers/Week06/LU_unb_var5.m Executable file
View File

@@ -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

49
Answers/Week06/Ltrsv_unb_var1.m Executable file
View File

@@ -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

15
Answers/Week06/Solve.m Executable file
View File

@@ -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

49
Answers/Week06/Utrsv_unb_var1.m Executable file
View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

26
Answers/Week06/test_Solve.m Executable file
View File

@@ -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

View File

@@ -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

49
Answers/Week07/Ltrsv_unb_var2.m Executable file
View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

Some files were not shown because too many files have changed in this diff Show More