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

  1. function [x] = lyapkr(a,b,c)
  2. %
  3. % [X] = LYAPKR(A,B,C) produces the solution of a Lyapunov or Sylvester equation
  4. %      The algorithm is simply the Kronecker product of a special
  5. %      kind, i.e :
  6. %
  7. %        A1*X*B1 + A2*X*B2 + A3*X*B3 + ... = Ck
  8. %
  9. %        The solution is
  10. %
  11. %        [KRON(A1,B1') + KRON(A2,B2') + ... ] * S[X] = S(Ck)
  12. %
  13. %        For the Lyapunov or Sylvester equation :
  14. %
  15. %            A1 = A,  B1 = I,  A2 = I, B2 = B,  Ck = -C.
  16. %
  17. %       such that :  A * X + X * B + C = 0
  18. %     
  19.  
  20. % R. Y. Chiang & M. G. Safonov 2/14/87
  21. % Copyright (c) 1988 by the MathWorks, Inc.
  22. % All Rights Reserved.
  23. % -------------------------------------------------------------------
  24. %
  25.  
  26. [ra,ca] = size(a);
  27. [rb,cb] = size(b);
  28. [rc,cc] = size(c);
  29. %
  30. if (ra ~= ca) | (rb ~= cb) | (rc ~= ra) | (cc ~= cb)
  31.         disp(' Error : Inconsistant inputs to LYAP solver.');
  32. end
  33. %
  34. if rc == cc
  35.    krnkr = kron(a,eye(ra)') + kron(eye(rb),b');
  36.    Cr = -c';
  37.    sc = Cr(:);
  38.    xx = inv(krnkr) * sc;
  39.    x  = unstkr(xx,ra,ca);
  40. end
  41. %
  42. if (rc < cc)
  43.     a1 = zeros(cc);
  44.     a1(1:rc,1:rc) = a;
  45.     krnkr = kron(a1,eye(cc)') + kron(eye(cc),b');
  46.     c  = [c;zeros((cc-rc),cc)];
  47.     Cr = -c';
  48.     sc = Cr(:);
  49.     xx = inv(krnkr) * sc;
  50.     x  = unstkr(xx,cc,cc);
  51.     x = x(1:rc,:);
  52. end
  53. %
  54. if (rc > cc)
  55.     b2 = zeros(rc);
  56.     b2(1:cc,1:cc) = b;
  57.     krnkr = kron(a,eye(rc)') + kron(eye(rc),b2');
  58.     c  = [c zeros(rc,(rc-cc))];
  59.     Cr = -c';
  60.     sc = Cr(:);
  61.     xx = inv(krnkr) * sc;
  62.     x  = unstkr(xx,rc,rc);
  63.     x  = x(:,1:cc);
  64. end     
  65. %
  66. % ------ End of LYAPKR.M --- RYC/MGS 
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.