function B = rjr(A)
%RJR	Random Jacobi Rotation.
%	B = RJR(A) applies a random symmetry and condition
%	preserving Jacobi rotation.

%	R. Schreiber, 1991.
%	Copyright (c) 1984-93 by The MathWorks, Inc.

n = max(size(A));
theta = (2*rand-1)*pi;
c = cos(theta);
s = sin(theta);
i = 1 + fix(rand(1) * n);
j = i;
while(j == i),
   j = 1 + fix(rand(1) * n);
end
B = A;
B(i,:) = c * A(i,:) + s * A(j,:);
B(j,:) = c * A(j,:) - s * A(i,:);
A = B;
B(:,i) = c * A(:,i) + s * A(:,j);
B(:,j) = c * A(:,j) - s * A(:,i);
