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

  1. function [Qo, To] = schord(Qi, Ti, index)
  2. %SCHORD    Ordered schur decomposition.
  3. %    [Qo, To] = schord(Qi, Ti, index)  Given the square (possibly 
  4. %    complex) upper-triangular matrix Ti and orthogonal matrix Qi
  5. %    (as output, for example, from the function SCHUR),
  6. %    SCHORD finds an orthogonal matrix Q so that the eigenvalues
  7. %    appearing on the diagonal of Ti are ordered according to the
  8. %    increasing values of the array index where the i-th element
  9. %    of index corresponds to the eigenvalue appearing as the
  10. %    element  Ti(i,i).
  11. %
  12. %    The input argument list may be [Qi, Ti, index] or [Ti, index].
  13. %    The output list may be [Qo, To] or [To].
  14. %
  15. %    The orthogonal matrix Q is accumulated in Qo as  Qo = Qi*Q.
  16. %         If Qi is not given it is set to the identity matrix.
  17. %
  18. %          *** WARNING: SCHORD will not reorder REAL Schur forms.
  19.  
  20. %    Copyright (c) 1986-93 by The MathWorks, Inc.
  21.  
  22. %  written-
  23. %       11 May 87  M. Wette, ECE Dep't., Univ. of California,
  24. %                            Santa Barbara, CA  93106, (805) 961-3616
  25. %                  e-mail:   mwette%gauss@hub.ucsb.edu
  26. %                            laub%lanczos@hbu.ucsb.edu
  27. %  revised-
  28. %       09 Sep 87  M. Wette 
  29. %                  (fixed exit on first eigenvalue in correct place)
  30. %       16 Mar 88  Wette & Laub
  31. %                  (documentation)
  32.  
  33. [nr,nc] = size(Ti); n = nr;
  34. if (nr ~= nc), error('Nonsquare Ti'); end;
  35. if (nargin == 2)
  36.     index = Ti; To = Qi;
  37. else
  38.     To = Ti;
  39. end;
  40. if (nargout > 1), if (nargin > 2), Qo = Qi; else Qo = eye(n); end; end;
  41. %
  42. for i = 1:(n-1),
  43.  
  44.     % -- find following element with smaller value of index --
  45.     move = 0; k = i;
  46.     for j = (i+1):n,
  47.     if (index(j) < index(k)), k = j; move = 1; end;
  48.     end;
  49.  
  50.     % -- propagate eigenvalue up the diagonal from k-th to i-th entry --
  51.     if (move),
  52.         for l = k:-1:(i+1)
  53.         l1 = l-1; l2 = l;
  54.         t = givens(To(l1,l1)-To(l2,l2), To(l1,l2));
  55.         t = [t(2,:);t(1,:)];
  56.         To(:,l1:l2) = To(:,l1:l2)*t; To(l1:l2,:) = t'*To(l1:l2,:);
  57.         if (nargout > 1), Qo(:,l1:l2) = Qo(:,l1:l2)*t; end;
  58.         ix = index(l1); index(l1) = index(l2); index(l2) = ix;
  59.         end;
  60.     end;
  61. end;
  62. % --- last line of schord.m ---
  63.