%
%
%  Row reduction via multiplication
%  by Elementary matrices.
%
%  Turn "diary" on. All output to Command Window
%  will then be
%
diary on
%
%
%
disp('LU Decomposition of the following matrix A')
%
A=[1,2,2;2,1,1;1,-1,1]
%
E21=Elem(3,2,1,-2);
E31=Elem(3,3,1,-1);
%
E32=Elem(3,3,2,-1);
%
disp('Elementary matrices E1,E2')
%
E1=E31*E21
E2=E32
%
%
disp('Lower Triangular L and Upper Triangular U')
%
% The single matlab command for "a" LU decomposition
%
% [L,U]=lu(A)
%
L=inv(E1)*inv(E2)
U=E2*E1*A
%
%
disp('Check the result: Does LU-A=0?')
%
check=L*U-A
%
%
diary off

