%function pert = mkpfrv(rv,blk,nrp,ncp)
function pert = mkpfrv(rv,blk,nrp,ncp)
 [nblk,x] = size(blk);
 tot = 0;
 for i=1:nblk
  if blk(i,2) == 0
    tot = tot + 1;
  else
    tot = tot + blk(i,1)*blk(i,2);
  end
 end
 if tot == max(size(rv))
   pert = zeros(nrp,ncp);
   rp=1; cp = 1;
   loc = 1;
   for i=1:nblk
    if blk(i,2) == 0
      pert(rp:rp+blk(i,1)-1,cp:cp+blk(i,1)-1) = ...
         rv(loc)*eye(blk(i,1));
      loc = loc + 1;
      rp = rp + blk(i,1); cp = cp + blk(i,1);
    else
      tmp = zeros(blk(i,1),blk(i,2));
      for j=1:blk(i,1)
        tmp(j,:) = rv(loc:loc+blk(i,2)-1);
        loc =  loc + blk(i,2);
      end
      pert(rp:rp+blk(i,1)-1,cp:cp+blk(i,2)-1) = tmp;
      rp = rp + blk(i,1); cp = cp + blk(i,2);
    end
   end
 else
   error('inconsistent block and perturbation data')
   return
 end
%
% Copyright MUSYN INC 1991,  All Rights Reserved
