function [A,B,Q,Z,v] = qzdiv(stake,A,B,Q,Z,v) Takes U.T. matrices A, B, orthonormal matrices Q,Z, rearranges them so that all cases of abs(B(i,i)/A(i,i))>stake are in lower right corner, while preserving U.T. and orthonormal properties and Q'AZ' and Q'BZ'. The columns of v are sorted correspondingly. by Christopher A. Sims modified (to add v to input and output) 7/27/00
0001 function [A,B,Q,Z,v] = qzdiv(stake,A,B,Q,Z,v) 0002 %function [A,B,Q,Z,v] = qzdiv(stake,A,B,Q,Z,v) 0003 % 0004 % Takes U.T. matrices A, B, orthonormal matrices Q,Z, rearranges them 0005 % so that all cases of abs(B(i,i)/A(i,i))>stake are in lower right 0006 % corner, while preserving U.T. and orthonormal properties and Q'AZ' and 0007 % Q'BZ'. The columns of v are sorted correspondingly. 0008 % 0009 % by Christopher A. Sims 0010 % modified (to add v to input and output) 7/27/00 0011 vin = nargin==6; 0012 if ~vin, v=[];, end; 0013 [n jnk] = size(A); 0014 root = abs([diag(A) diag(B)]); 0015 root(:,1) = root(:,1)-(root(:,1)<1.e-13).*(root(:,1)+root(:,2)); 0016 root(:,2) = root(:,2)./root(:,1); 0017 for i = n:-1:1 0018 m=0; 0019 for j=i:-1:1 0020 if (root(j,2) > stake | root(j,2) < -.1) 0021 m=j; 0022 break 0023 end 0024 end 0025 if (m==0) 0026 return 0027 end 0028 for k=m:1:i-1 0029 [A B Q Z] = qzswitch(k,A,B,Q,Z); 0030 tmp = root(k,2); 0031 root(k,2) = root(k+1,2); 0032 root(k+1,2) = tmp; 0033 if vin 0034 tmp=v(:,k); 0035 v(:,k)=v(:,k+1); 0036 v(:,k+1)=tmp; 0037 end 0038 end 0039 end