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

  1. % function [bnds,dvec,sens,pvec] = mu(matin,blk,opt)
  2. %
  3. %   Calculates structured singular value (mu) 
  4. %   of a VARYING matrix
  5. %    inputs:
  6. %    MATIN - input matrix, CONSTANT/VARYING
  7. %    BLK   - block structure
  8. %    OPT   - character string describing the 
  9. %        desired computation.    
  10. %                 'l' lower bound, power iteration
  11. %                 't' increase iterations (to 300) in lower bound
  12. %                 'r' start with D=I for EACH independent variable
  13. %                 'c' upper bound, subgradient method
  14. %                 'o' upper bound, modified Osborne's method
  15. %                 'p' upper bound, Perron vector method
  16. %                 'u' upper bound, depending on the block 
  17. %             structure, Osborne or Perron method
  18. %          's' suppress printing information about calculation
  19. %          'L' only compute lower bound
  20. %          'R' start lower bound with RANDOM vectors
  21. %        DEFAULT is 'lu'
  22. %
  23. %   See also: BLKNORM, DYPERT, H2NORM, HINFNORM, NORM, RANDEL,
  24. %             UNWRAPD, UNWRAPP, VNORM, VRHO, and VSVD.
  25.  
  26. function [bnds,rvdl,sens,rvpert,pinfos] = mu(matin,blk,opt)
  27.   if nargin < 1
  28.     disp('usage: [bnds,dvec,sens,pvec] = mu(matin,blk,opt)')
  29.     return
  30.   end
  31.  
  32.   [mtype,mrows,mcols,mnum] = minfo(matin);
  33.  
  34.   if nargin < 2
  35.     if mrows==mcols 
  36.         opt = 'lu';
  37.         blk = ones(mrows,2);
  38.     else
  39.         disp('usage: [bnds,dvec,sens,pvec] = mu(matin,blk,opt)')
  40.         disp('Nonsquare MATIN must have BLK specified')
  41.         return
  42.     end % if mrows
  43.    elseif nargin == 2
  44.     opt = 'lu';
  45.    else
  46.     opt = [opt 'lu'];
  47.    end %if nargin
  48.    initreset = 0;
  49.    if any(opt)=='r'
  50.      initreset = 1;
  51.    end
  52.  
  53. %
  54.   if mtype == 'syst'
  55.     disp('MU for SYSTEM matrices is not implemented yet')
  56.     return
  57.   end
  58. % set up pointers for block structure
  59.   [nblk,dum] = size(blk);
  60.   for i=1:nblk
  61.     if blk(i,2) == 0 & blk(i,1) == 1
  62.       blk(i,2) = 1;
  63.     end
  64.   end
  65.   [blkp,repp,fulp,wd,wpert,nrd,ncd,rnblk,rblk,rblkp] = ptrs(blk);
  66. % see PTRS.M for definitions of these variables
  67.   if nrd ~= mcols | ncd ~= mrows
  68.     error('MATIN dimensions incompatible with BLK dimensions')
  69.     return
  70.   end
  71.   if strcmp(mtype,'cons')
  72. %   CONSTANT matrix
  73.     [bnds,dleft,drighti,rvpert,sens,pinfos] = ...
  74.         mu_comp(matin,nblk,blk,blkp,wpert,repp,fulp,rnblk,rblk,rblkp,opt);
  75.     [rvdl,condd] = dscl_vec(dleft,nblk,blk,blkp);
  76.     rvdl(1:wd) = rvdl(1:wd)/rvdl(wd);
  77.   elseif strcmp(mtype,'vary')
  78. %   VARYING matrix - initialize output matrices
  79.     initdl = eye(mrows);
  80.     initdri = eye(mcols);
  81.     ff = (mnum+1)*mrows;
  82.     pp = 1:mrows:ff;
  83.     ppm1 = pp(2:mnum+1) - 1;
  84. %
  85.     rvdl = zeros(mnum+1,wd+1);
  86.     rvdl(1:mnum,wd+1) = matin(1:mnum,mcols+1);
  87.     rvdl(mnum+1,wd+1) = inf;
  88.     rvdl(mnum+1,wd) =mnum;
  89. %
  90.     bnds = zeros(mnum+1,3);
  91.     bnds(1:mnum,3) = matin(1:mnum,mcols+1);
  92.     bnds(mnum+1,3) = inf;
  93.     bnds(mnum+1,2) = mnum;
  94. %
  95.     sens = zeros(mnum+1,nblk+1);
  96.     sens(1:mnum,nblk+1) = matin(1:mnum,mcols+1);
  97.     sens(mnum+1,nblk+1) = inf;
  98.     sens(mnum+1,nblk) = mnum;
  99. %
  100. %   if length(opt) > 1
  101.     if any(opt=='l') | any(opt=='t')
  102.       rvpert = zeros(mnum+1,wpert+1);
  103.       rvpert(1:mnum,wpert+1) = matin(1:mnum,mcols+1);
  104.       rvpert(mnum+1,wpert+1) = inf;
  105.       rvpert(mnum+1,wpert) = mnum;
  106.       pinfos = bnds;
  107.     end
  108. %   main loop on varying matrix
  109.     if nblk == 2 & length(repp) == 0
  110.       idd = 0;
  111.     end
  112.     count = 0;
  113.     if ~any(opt=='s')
  114.       fprintf('points completed....\n')
  115.     end
  116.     for i = 1:mnum
  117.       tmp = matin(pp(i):ppm1(i),1:mcols);
  118.       if nblk == 2 & length(repp) == 0
  119.         [up,dl,dri,sen,rowp,lb,err] = twobl(tmp,blk,idd);
  120.         if err == 0
  121.           idd = log(dl(1,1));
  122.           bnd = [up up];
  123.           pinfo = [err err];
  124.         else
  125.           idd = 0;
  126.           bnd = [up lb];
  127.           pinfo = [err err];
  128.         end
  129.       else
  130.         [bnd,dl,dri,rowp,sen,pinfo] = ...
  131.              mu_comp(tmp,nblk,blk,blkp,wpert,repp,fulp,...
  132.              rnblk,rblk,rblkp,opt,initdl,initdri);
  133.       end
  134.       count = count + 1;
  135.       if count < 18
  136.         if ~any(opt=='s')
  137.           fprintf([int2str(i) '.'])
  138.         end
  139.       else
  140.         if ~any(opt=='s')
  141.           fprintf('\n')
  142.           fprintf([int2str(i) '.'])
  143.         end
  144.         count = 0;
  145.       end
  146.       if any(opt=='l') | any(opt=='t')
  147.         rvpert(i,1:wpert) = rowp;
  148.         pinfos(i,1:2) = pinfo;
  149.       end
  150.       [rvdl(i,1:wd),condd] = dscl_vec(dl,nblk,blk,blkp);
  151.       if condd > 1e6
  152.         disp(['WARNING: D scaling matrices are poorly conditioned...'])
  153.         disp(['check upper and lower bound results carefully'])
  154.       end
  155.       bnds(i,1:2) = bnd;
  156.       if initreset == 1
  157.         initdl = eye(mrows);
  158.         initdri = eye(mcols);
  159.       else
  160.         initdl = dl/rvdl(i,wd);
  161.         initdri = dri*rvdl(i,wd);
  162.       end
  163.       sens(i,1:nblk) = sen;
  164.     end % for i
  165.     if ~any(opt=='s')
  166.       fprintf('\n')
  167.     end
  168.   end
  169.  
  170.   if ~any(opt=='l') & ~any(opt=='t') & ~any(opt=='L')
  171.     bnds = sel(bnds,1,1);
  172.   end
  173. %
  174. % Copyright MUSYN INC 1991,  All Rights Reserved
  175.