function ShowRankDefLS2()
% Compares two LS solvers when the matrix is rank deficient without a clear
% break between the large and small singular values.
format short
m = 10;
n = 6;
noise = .00000001;
clc
for r = 1:n
% Generate a matrix that is within noise of being rank r
A = randn(m,r)*randn(n,r)' + noise*randn(m,n);
% The right hand side...
b = randn(m,1);
% The "definition" of zero...
tol = .00001*max(max(abs(A)));
% The two solvers...
[xB,rhoxB,rQR] = LSviaQRP(A,b,tol);
[xLS,rhoxLS,rSVD] = LSviaSVD(A,b,tol);
% Display the results...
fprintf('\n*****************************************************\n')

fprintf('\nrank(A) = %1d\n\nrQR = %1d rSVD = %1d\n\n',r,rQR,rSVD)
disp(' xB xLS')
disp([xB xLS])
fprintf('|| A*xB - b || = %10.3f\n',rhoxB)
fprintf('|| A*xLS - b || = %10.3f\n',rhoxLS)
end