Home > matlab > qzdiv.m

qzdiv

PURPOSE ^

function [A,B,Q,Z] = qzdiv(stake,A,B,Q,Z)

SYNOPSIS ^

function [A,B,Q,Z] = qzdiv(stake,A,B,Q,Z)

DESCRIPTION ^

function [A,B,Q,Z] = qzdiv(stake,A,B,Q,Z)

 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'.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [A,B,Q,Z] = qzdiv(stake,A,B,Q,Z)
0002 %function [A,B,Q,Z] = qzdiv(stake,A,B,Q,Z)
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'.
0008 
0009 % Original file downloaded from:
0010 % http://sims.princeton.edu/yftp/gensys/mfiles/qzdiv.m
0011 
0012 % Copyright (C) 1993-2007 Christopher Sims
0013 % Copyright (C) 2008-2011 Dynare Team
0014 %
0015 % This file is part of Dynare.
0016 %
0017 % Dynare is free software: you can redistribute it and/or modify
0018 % it under the terms of the GNU General Public License as published by
0019 % the Free Software Foundation, either version 3 of the License, or
0020 % (at your option) any later version.
0021 %
0022 % Dynare is distributed in the hope that it will be useful,
0023 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0024 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0025 % GNU General Public License for more details.
0026 %
0027 % You should have received a copy of the GNU General Public License
0028 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0029 
0030 [n jnk] = size(A);
0031 root = abs([diag(A) diag(B)]);
0032 root(:,1) = root(:,1)-(root(:,1)<1.e-13).*(root(:,1)+root(:,2));
0033 root(:,2) = root(:,2)./root(:,1);
0034 for i = n:-1:1
0035     m=0;
0036     for j=i:-1:1
0037         if (root(j,2) > stake || root(j,2) < -.1) 
0038             m=j;
0039             break
0040         end
0041     end
0042     if (m==0) 
0043         return 
0044     end
0045     for k=m:1:i-1
0046         [A B Q Z] = qzswitch(k,A,B,Q,Z);
0047         tmp = root(k,2);
0048         root(k,2) = root(k+1,2);
0049         root(k+1,2) = tmp;
0050     end
0051 end

Generated on Tue 22-May-2012 02:40:23 by m2html © 2005