kusano 7d535a
function info = try4(A,pin);
kusano 7d535a
% TRY4 : test SUPERLU with 4 outputs
kusano 7d535a
%
kusano 7d535a
% info = try4(A,pin);
kusano 7d535a
% normally info is the residual norm; 
kusano 7d535a
% but info is at least 10^6 if the factors are not triangular,
kusano 7d535a
% or the permutations aren't permutations.
kusano 7d535a
% Copyright (c) 1995 by Xerox Corporation.  All rights reserved.
kusano 7d535a
% HELP COPYRIGHT for complete copyright and licensing notice.
kusano 7d535a
kusano 7d535a
kusano 7d535a
n = max(size(A));
kusano 7d535a
info = 0;
kusano 7d535a
kusano 7d535a
if nargin == 1
kusano 7d535a
    [l,u,pr,pc] = superlu(A);
kusano 7d535a
elseif nargin == 2
kusano 7d535a
    [l,u,pr,pc] = superlu(A,pin);
kusano 7d535a
else 
kusano 7d535a
    error('requires 1 or 2 inputs');
kusano 7d535a
end;
kusano 7d535a
kusano 7d535a
% DOES NOT WORK IN MATLAB 5, NOT YET KNOW WHY -- XSL 5-25-98
kusano 7d535a
% figure(2); [r,s] = spart2(l); spypart(l,r,s); title('L');
kusano 7d535a
figure(2); spy(l); title('L');
kusano 7d535a
figure(1); spy(u); title('U');
kusano 7d535a
drawnow;
kusano 7d535a
kusano 7d535a
format compact
kusano 7d535a
disp('SUPERLU with 4 outputs:');
kusano 7d535a
if any(any(triu(l,1)))
kusano 7d535a
    disp('L is *NOT* lower triangular.');
kusano 7d535a
    info = info + 10^6;
kusano 7d535a
else
kusano 7d535a
    disp('L is lower triangular.');
kusano 7d535a
end;
kusano 7d535a
if nnz(l) == nnz(l+l)
kusano 7d535a
    disp('L has no explicit zeros.');
kusano 7d535a
else
kusano 7d535a
    disp('L contains explicit zeros.');
kusano 7d535a
    info = info+10^6;
kusano 7d535a
end;
kusano 7d535a
if any(any(tril(u,-1)))
kusano 7d535a
    disp('U is *NOT* upper triangular.');
kusano 7d535a
    info = info + 10^6;
kusano 7d535a
else
kusano 7d535a
    disp('U is upper triangular.');
kusano 7d535a
end;
kusano 7d535a
if nnz(u) == nnz(u+u)
kusano 7d535a
    disp('U has no explicit zeros.');
kusano 7d535a
else
kusano 7d535a
    disp('U contains explicit zeros.');
kusano 7d535a
    info = info+10^6;
kusano 7d535a
end;
kusano 7d535a
if pr == [1:n]
kusano 7d535a
    disp('PROW is the identity permutation.');
kusano 7d535a
elseif isperm(pr)
kusano 7d535a
    disp('PROW is a non-identity permutation.');
kusano 7d535a
else 
kusano 7d535a
    disp('PROW is *NOT* a permutation.');
kusano 7d535a
    info = info + 10^6;
kusano 7d535a
end;
kusano 7d535a
if pc == [1:n]
kusano 7d535a
    disp('PCOL is the identity permutation.');
kusano 7d535a
elseif isperm(pc)
kusano 7d535a
    disp('PCOL is a non-identity permutation.');
kusano 7d535a
else 
kusano 7d535a
    disp('PCOL is *NOT* a permutation.');
kusano 7d535a
    info = info + 10^6;
kusano 7d535a
end;
kusano 7d535a
if pr == pc
kusano 7d535a
    disp('PROW and PCOL are the same.')
kusano 7d535a
else
kusano 7d535a
    disp('PROW and PCOL are different.')
kusano 7d535a
end;
kusano 7d535a
rnorm = norm(A(pr,pc) - l*u,inf);
kusano 7d535a
fprintf(1,'||A(PROW,PCOL) -  L*U|| = %d\n', rnorm);
kusano 7d535a
info = info + rnorm;
kusano 7d535a
disp(' ');