home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 2.ddi / MUTOOLS1.DI$ / UNWRAPP.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  1.3 KB  |  61 lines

  1. % function pert = unwrapp(pvec,blk)
  2. %
  3. %   Unwraps the perturbation matrix PVEC (from a lower 
  4. %   bound MU calculation) into the block diagonal form.
  5. %
  6. %
  7. %   See also: MU and UNWRAPD.
  8.  
  9. function pert = unwrapp(rvpert,blk)
  10.  if nargin < 2
  11.    disp('usage: pert = unwrapp(pvec,blk)')
  12.    return
  13.  end
  14.  [nblk,dum] = size(blk);
  15.  if dum ~= 2
  16.    error('block data incorrect format')
  17.    return
  18.  end
  19.  wp = 0;
  20.  nrp = 0;
  21.  ncp = 0;
  22.  for i=1:nblk
  23.    nrp = nrp + blk(i,1);
  24.    if blk(i,2) == 0
  25.      ncp = ncp + blk(i,1);
  26.      wp = wp+1;
  27.    else
  28.      wp = wp + blk(i,1)*blk(i,2);
  29.      ncp = ncp + blk(i,2);
  30.    end
  31.  end
  32.  [mtype,mrows,mcols,mnum] = minfo(rvpert);
  33.  if mtype == 'vary'
  34.    if mrows == 1 & mcols == wp
  35.      pert = zeros(nrp*mnum,ncp);
  36.      ff = (mnum+1)*nrp;
  37.      pout = 1:nrp:ff;
  38.      poutm1 = pout(2:mnum+1) - 1;
  39.      for i=1:mnum
  40.        pert(pout(i):poutm1(i),1:ncp) = ...
  41.            mkpfrv(rvpert(i,1:mcols),blk,nrp,ncp);
  42.      end
  43.      pert = vpck(pert,rvpert(1:mnum,mcols+1));
  44.    else
  45.      error('incompatible dimensions')
  46.      return
  47.    end
  48.  elseif mtype == 'cons'
  49.    if mrows == 1 & mcols == wp
  50.      pert = mkpfrv(rvpert,blk,nrp,ncp);
  51.    else
  52.      error('incompatible dimensions')
  53.      return
  54.    end
  55.  else
  56.   error('row vector should not be a SYSTEM matrix')
  57.   return
  58.  end
  59. %
  60. % Copyright MUSYN INC 1991,  All Rights Reserved
  61.