function [S,T,Q,Z] = reorder(S,T,Q,Z) % % Takes U.T. matrices S, T, orthonormal matrices Q,Z, rearranges them % so that abs(T(i,i)/S(i,i)) are in ascending order % while preserving U.T. and orthonormal properties and Q'AZ' and % Q'BZ'. % n = size(S,1); i = 1; while i<=n-1; if abs(T(i,i)*S(i+1,i+1))>abs(S(i,i)*T(i+1,i+1)); [S,T,Q,Z] = qzswitch(i,S,T,Q,Z); if ~(i==1);i = i-2;end end i=i+1; end