home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 2.ddi / MUTOOLS2.DI$ / SYLV.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  700 b   |  32 lines

  1. % function X = sylv(A,B,C)
  2. %   sylv(A,B,C) solves the Sylvester equation A*X+X*B=C
  3. %   The method forms the single vector equation using Kroneker
  4. %   products.  This is not generally efficient but is when
  5. %   A or B have low dimension (e.g. 2) and the other is in
  6. %   either Hessenberg or Schur form.
  7.  
  8. function X = sylv(A,B,C)
  9. [ma,na] = size(A);
  10. [mb,nb] = size(B);
  11.  
  12. K = zeros(ma*mb,na*nb);
  13. jj = 1-nb:0;
  14.  
  15. EA = eye(na);
  16.  
  17. for i = 1:ma
  18.         ik = i:na:(na*mb-na+i);
  19.         K(ik,ik) = B';
  20.         end
  21. end
  22.  
  23. for i = 1:mb
  24.         ik = 1+(i-1)*ma:i*ma;
  25.         K(ik,ik) = K(ik,ik) + A;
  26. end
  27.  
  28. X = zeros(na,mb);
  29. X(:) = K\C(:);
  30. %
  31. % Copyright MUSYN INC 1991,  All Rights Reserved
  32.