kusano 7d535a
function [r,s] = spart2(A)
kusano 7d535a
% SPART2 : supernode partition
kusano 7d535a
%
kusano 7d535a
% [r,x] = spart2(A) partitions the columns of A according to supernode 
kusano 7d535a
% definition 2:
kusano 7d535a
% A supernode in A = L+U is a sequence of adjacent columns in which
kusano 7d535a
% the diagonal block of L is full,
kusano 7d535a
% and below the diagonal all the columns (of L) have the same row structure.
kusano 7d535a
% Output: row and column partitions r and s suitable for SPYPART(A,r,s)
kusano 7d535a
%
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
[nr,nc] = size(A);
kusano 7d535a
A = spones(A);
kusano 7d535a
A = tril(A) | speye(nr,nc);
kusano 7d535a
kusano 7d535a
A1 = tril([zeros(nr,1) A]);
kusano 7d535a
A2 = [A ones(nr,1)];
kusano 7d535a
kusano 7d535a
signature = sum(xor(A1,A2));
kusano 7d535a
r = find(signature);
kusano 7d535a
r = r';
kusano 7d535a
if nargout > 1,
kusano 7d535a
    s = r;
kusano 7d535a
    r = [1 nr+1];
kusano 7d535a
end;