Gauss
Gauss
function rrefmovie(A,tol)
%RREFMOVIE Movie of the computation of the reduced row echelon form.
% RREFMOVIE(A) produces the reduced row echelon form of A.
% RREFMOVIE, by itself, supplies its own 8-by-6 matrix with rank 4.
% RREFMOVIE(A,tol) uses the given tolerance in the rank tests.
%
%
4
0
0
0
2
6
0
0
1
4
7
16
-4
-12
9
5
6
15
8
3
0
0
6
10
12
1
10
13
0
0
12
8
7
14
9
2
0
0
7
11];
end
format rat
more off
clc
home
disp(' Original matrix')
A
disp('Press any key to continue. . .'), pause(0.1)
[m,n] = size(A);
% Compute the default tolerance if none was provided.
if (nargin < 2), tol = max([m,n])*eps*norm(A,'inf'); end
% Loop over the entire matrix.
i = 1;
j = 1;
k = 0;
while (i <= m) & (j <= n)
% Find value and index of largest element in the remainder of column j.
[p,k] = max(abs(A(i:m,j))); k = k+i-1;
if (p <= tol)
% The column is negligible, zero it out.
home
disp([' column ' int2str(j) ' is negligible'])
A(i:m,j) = zeros(m-i+1,1)
disp('Press any key to continue. . .'), pause(0.1)
j = j + 1;
else
if i ~= k
% Swap i-th and k-th rows.
home
disp([' swap rows ' int2str(i) ' and ' int2str(k) blanks(10)])
A([i k],:) = A([k i],:)
disp('Press any key to continue. . .'), pause(0.1)
end
% Divide the pivot row by the pivot element.
home