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

  1. % function out = vrho(matin)
  2. %
  3. %   Spectral radius of a square, VARYING/CONSTANT matrix.
  4. %   The spectral radius is defined as MAX(ABS(EIG(MATIN)))
  5. %   for a CONSTANT matrix and as  MAX(ABS(EIG(XTRACTI(MATIN,I)))) 
  6. %   for each INDEPENDENT VARIABLE of the VARYING matrix MATIN.
  7. %
  8. %   See also: EIG and VEIG.
  9.  
  10. function out = vrho(matin)
  11.  if nargin == 0
  12.    disp('usage: out = vrho(matin)');
  13.    return
  14.  end
  15.  [mtype,mrows,mcols,mnum] = minfo(matin);
  16.  if mtype == 'cons'
  17.    if mrows ~= mcols
  18.      error('VRHO is undefined for nonsquare matrices')
  19.      return
  20.    end
  21.    out = max(abs(eig(matin)));
  22.  elseif mtype == 'vary'
  23.    if mrows ~= mcols
  24.      error('VRHO is undefined for nonsquare matrices')
  25.      return
  26.    end
  27.    npts = mnum;
  28.    nrout = mnum;
  29.    ncout = 2;
  30.    out = zeros(npts+1,2);
  31.    ff = (npts+1)*mrows;
  32.    pt = 1:mrows:ff;
  33.    ptm1 = pt(2:npts+1)-1;
  34.    for i=1:npts
  35.      out(i,1) = max(abs(eig(matin(pt(i):ptm1(i),1:mcols))));
  36.    end
  37.    out(1:npts,2) = matin(1:npts,mcols+1);
  38.    out(npts+1,1) = npts;
  39.    out(npts+1,2) = inf;
  40.  elseif mtype == 'syst'
  41.    error('VRHO is undefined for SYSTEM matrices');
  42.    return
  43.  else
  44.   out = [];
  45.  end
  46. %
  47. % Copyright MUSYN INC 1991,  All Rights Reserved
  48.