kusano 7d535a
function spypart(S, rp, cp);
kusano 7d535a
%SPYPART Spy plot with partitioning.
kusano 7d535a
%   SPYPART(S,rp,cp) plots the sparsity pattern of a matrix S,
kusano 7d535a
%   with lines marking a block partition described by 
kusano 7d535a
%   rp (rows) and cp (columns).
kusano 7d535a
%   If S is square, cp may be omitted and defaults to rp.
kusano 7d535a
%
kusano 7d535a
%   Partitions are specified as in the output of DMPERM:
kusano 7d535a
%   There are length(rp)-1 row blocks, of sizes diff(rp), with rp(1)=1.
kusano 7d535a
kusano 7d535a
%   Copyright (c) 1984-98 by The MathWorks, Inc.
kusano 7d535a
%   $Revision: 5.3 $  $Date: 1997/11/21 23:27:12 $
kusano 7d535a
kusano 7d535a
if (nargin < 3), cp = rp; end
kusano 7d535a
kusano 7d535a
spy(S)
kusano 7d535a
hold on
kusano 7d535a
kusano 7d535a
[m,n] = size(S);
kusano 7d535a
if length(rp) > 2
kusano 7d535a
   k = length(rp)-2;
kusano 7d535a
   X = [zeros(1,k); n+ones(1,k)];
kusano 7d535a
   Y = rp(2:k+1) - 0.5;
kusano 7d535a
   Y = [Y; Y];
kusano 7d535a
   plot(X,Y,'w-') 
kusano 7d535a
end
kusano 7d535a
if length(cp) > 2
kusano 7d535a
   k = length(cp)-2;
kusano 7d535a
   X = cp(2:k+1) - .5;
kusano 7d535a
   X = [X; X];
kusano 7d535a
   Y = [zeros(1,k); m+ones(1,k)];
kusano 7d535a
   plot(X,Y,'w-') 
kusano 7d535a
end
kusano 7d535a
axis('ij')
kusano 7d535a
hold off