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

  1. % function [u,t] = vschur(mat)
  2. %
  3. %   Schur decomposition of a VARYING/CONSTANT matrix,
  4. %   identical to MATLAB's SCHUR command, but VSCHUR
  5. %   works with VARYING matrices also.
  6. %     input:
  7. %         MAT - VARYING/CONSTANT matrix
  8. %     outputs:
  9. %         U   - unitary matrix, VARYING/CONSTANT matrix
  10. %                   MAT = MMULT(U,T,TRANSP(U)), and  MMULT(TRANSP(U),U)
  11. %            is the identity of the corresponding type.
  12. %            T   - complex or real schur Schur form depending on the
  13. %            input, VARYING/CONSTANT matrix.
  14. %
  15. %   See also: CSORD, EIG, RSF2CSF, SCHUR, SVD, VEIG and VSVD.
  16.  
  17. function [out1,out2] = vschur(mat)
  18.   if nargin ~= 1
  19.     disp(['usage: [u,t] = vschur(mat)'])
  20.     return
  21.   end
  22.   [mtype,mrows,mcols,mnum] = minfo(mat);
  23.   if mcols ~= mrows
  24.     error(['input to VSCHUR should be square']);
  25.     return
  26.   end
  27.   if mtype == 'cons'
  28.     if nargout <= 1
  29.       out1 = schur(mat);
  30.     else
  31.       [out1,out2] = schur(mat);
  32.     end
  33.   elseif mtype == 'vary'
  34.     indv = mat(1:mnum,mcols+1);
  35.     if nargout <= 1
  36.       npts = mnum;
  37.       nrout = mrows;
  38.       ncout = mcols;
  39.       out = zeros((nrout*npts)+1,ncout+1);
  40.       fone = (npts+1)*mrows;
  41.       pone = 1:mrows:fone;
  42.       ponem1 = pone(2:npts+1) - 1;
  43.       for i=1:npts
  44.         out1(pone(i):ponem1(i),1:mcols) = ...
  45.              schur(mat(pone(i):ponem1(i),1:mcols));
  46.       end
  47.       out1((nrout*npts)+1,ncout+1) = inf;
  48.       out1((nrout*npts)+1,ncout) = npts;
  49.       out1(1:npts,ncout+1) = indv;
  50.     else
  51.       npts = mnum;
  52.       nrout = mrows;
  53.       ncout = mcols;
  54.       out1 = zeros(nrout*npts+1,ncout+1);
  55.       out2 = zeros(nrout*npts+1,ncout+1);
  56.       out1((nrout*npts)+1,ncout+1) = inf;
  57.       out1((nrout*npts)+1,ncout) = npts;
  58.       out1(1:npts,ncout+1) = indv;
  59.       out2((nrout*npts)+1,ncout+1) = inf;
  60.       out2((nrout*npts)+1,ncout) = npts;
  61.       out2(1:npts,ncout+1) = indv;
  62.       fout = (npts+1)*nrout;
  63.       pout = 1:mrows:fout;
  64.       poutm1 = pout(2:npts+1) - 1;
  65.       for i=1:npts
  66.         [tu,ts] = schur(mat(pout(i):poutm1(i),1:mcols));
  67.         out1(pout(i):poutm1(i),1:ncout) = tu;
  68.         out2(pout(i):poutm1(i),1:mcols) = ts;
  69.       end
  70.     end
  71.   elseif mtype == 'syst'
  72.     error('VSCHUR is undefined for SYSTEM matrices')
  73.     return
  74.   end
  75. %
  76. % Copyright MUSYN INC 1991,  All Rights Reserved
  77.