home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / SPARFUN.DI$ / RJR.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  530 b   |  24 lines

  1. function B = rjr(A)
  2. %RJR    Random Jacobi Rotation.
  3. %    B = RJR(A) applies a random symmetry and condition
  4. %    preserving Jacobi rotation.
  5.  
  6. %    R. Schreiber, 1991.
  7. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  8.  
  9. n = max(size(A));
  10. theta = (2*rand-1)*pi;
  11. c = cos(theta);
  12. s = sin(theta);
  13. i = 1 + fix(rand(1) * n);
  14. j = i;
  15. while(j == i),
  16.    j = 1 + fix(rand(1) * n);
  17. end
  18. B = A;
  19. B(i,:) = c * A(i,:) + s * A(j,:);
  20. B(j,:) = c * A(j,:) - s * A(i,:);
  21. A = B;
  22. B(:,i) = c * A(:,i) + s * A(:,j);
  23. B(:,j) = c * A(:,j) - s * A(:,i);
  24.