home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 5.ddi / SPLINES.DI$ / BKBRK.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  1.7 KB  |  50 lines

  1. function [nb,rows,ncols,last,blocks]=bkbrk(blokmat,print)
  2. % BKBRK    Details of almost block diagonal matrix.
  3. %
  4. %        [nb,rows,ncols,last,blocks]=bkbrk(blokmat[,print])
  5. %
  6. % returns the details of the almost block diagonal matrix contained in
  7. %  blokmat , with  rows  and  last  nb-vectors, and  blocks  a matrix of
  8. % size  sum(rows)-by-ncols .
  9.  
  10. % C. de Boor / latest change: March 28, '90
  11. % C. de Boor / latest change: February 1, '91: correct misspelling
  12. % Copyright (c) 1990-92 by Carl de Boor and The MathWorks, Inc.
  13.  
  14. if (blokmat(1)==41), %data type number for the spline block format is 41
  15.    nb=blokmat(2);
  16.    rows=blokmat(2+[1:nb]);
  17.    ncols=blokmat(2+nb+1);
  18.    last=blokmat(3+nb+[1:nb]);
  19.    blocks=zeros(sum(rows),ncols);blocks(:)=blokmat(3+2*nb+[1:sum(rows)*ncols]);
  20.    
  21. elseif (blokmat(1)==40), % data type number for general almost block diagonal
  22.                           % format is 40;
  23.    nb=blokmat(2);
  24.    rows=blokmat(2+[1:nb]);
  25.    cols=blokmat(2+nb+[1:nb]);
  26.    last=blokmat(2+2*nb+[1:nb]);
  27.    row=cumsum([0,rows]);
  28.    ne=sum(rows);ncols=max(cols); 
  29.    len=rows.*cols;
  30.    index=cumsum([2+3*nb len]);
  31.    blocks=zeros(ne,ncols);
  32.    for j=1:nb;
  33.       block=zeros(rows(j),cols(j));
  34.       block(:)=blokmat(index(j)+[1:len(j)]);
  35.       blocks(row(j)+[1:row(j+1)],[1:cols(j)])=block;
  36.    end
  37. else,
  38.    error('argument is not an almost block diagonal matrix'),
  39. end
  40.  
  41. if(nargin>1), %print out the blocks
  42.    rowsum=cumsum([0 rows]);
  43.    for j=1:nb,
  44.       fprintf(['block ',int2str(j),' has ',int2str(rows(j)),' row(s)\n'])
  45.       disp(blocks(rowsum(j)+[1:rows(j)],:))
  46.      fprintf([' next block is shifted over ',int2str(last(j)),' column(s)\n\n'])
  47.    end
  48. end
  49.  
  50.