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

  1. function g = givens(x,y)
  2. %GIVENS    Givens rotation matrix.
  3. %    G = GIVENS(x,y) returns the complex Givens rotation matrix
  4. %
  5. %        | c       s |                  | x |     | r | 
  6. %    G = |           |   such that  G * |   |  =  |   |
  7. %           |-conj(s) c |                  | y |     | 0 |
  8. %                                    
  9. %    where c is real, s is complex, and c^2 + |s|^2 = 1. 
  10.  
  11. %    Copyright (c) 1986-93 by The MathWorks, Inc.
  12.  
  13. absx = abs(x);
  14. if absx == 0.0
  15.     c = 0.0; s = 1.0;
  16. else
  17.     nrm = norm([x y]);
  18.     c = absx/nrm;
  19.     s = x/absx*(conj(y)/nrm);
  20. end
  21. g = [c s;-conj(s) c];
  22.