function B=StoreBandMatrix(A,q,p)
% STOREBANDMATRIX stores the band of a matrix in a rectangular matrix
%   B=StoreBandMatrix(A) stores the band of A (with lower bandwidth p
%   and upper bandwidth q) in the rectangular matrix B of dimensions
%   n*p+q+1.

n=length(A);
B=zeros(n,p+q+1);                                      % reserve space
for i=1:n
  for j=max(1,i-q):min(n,i+p)
    B(i,j-i+q+1)=A(i,j);
  end
end
