


function [err,ss,tt,w,sdim,eigval,info] = mjdgges(e,d,qz_criterium)
QZ decomposition, Sims' codes are used.
INPUTS
e [double] real square (n*n) matrix.
d [double] real square (n*n) matrix.
qz_criterium [double] scalar (1+epsilon).
OUTPUTS
err [double] scalar: 1 indicates failure, 0 indicates success
ss [complex] (n*n) matrix.
tt [complex] (n*n) matrix.
w [complex] (n*n) matrix.
sdim [integer] scalar.
eigval [complex] (n*1) vector.
info [integer] scalar.
ALGORITHM
Sims's qzdiv routine is used.
SPECIAL REQUIREMENTS
none.

0001 function [err,ss,tt,w,sdim,eigval,info] = mjdgges(e,d,qz_criterium) 0002 %function [err,ss,tt,w,sdim,eigval,info] = mjdgges(e,d,qz_criterium) 0003 % QZ decomposition, Sims' codes are used. 0004 % 0005 % INPUTS 0006 % e [double] real square (n*n) matrix. 0007 % d [double] real square (n*n) matrix. 0008 % qz_criterium [double] scalar (1+epsilon). 0009 % 0010 % OUTPUTS 0011 % err [double] scalar: 1 indicates failure, 0 indicates success 0012 % ss [complex] (n*n) matrix. 0013 % tt [complex] (n*n) matrix. 0014 % w [complex] (n*n) matrix. 0015 % sdim [integer] scalar. 0016 % eigval [complex] (n*1) vector. 0017 % info [integer] scalar. 0018 % 0019 % ALGORITHM 0020 % Sims's qzdiv routine is used. 0021 % 0022 % SPECIAL REQUIREMENTS 0023 % none. 0024 0025 % Copyright (C) 1996-2010 Dynare Team 0026 % 0027 % This file is part of Dynare. 0028 % 0029 % Dynare is free software: you can redistribute it and/or modify 0030 % it under the terms of the GNU General Public License as published by 0031 % the Free Software Foundation, either version 3 of the License, or 0032 % (at your option) any later version. 0033 % 0034 % Dynare is distributed in the hope that it will be useful, 0035 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0036 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0037 % GNU General Public License for more details. 0038 % 0039 % You should have received a copy of the GNU General Public License 0040 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0041 0042 % Check number of inputs and outputs. 0043 if nargin>3 || nargin<2 || nargout>7 || nargout==0 0044 error('MJDGGES: takes 2 or 3 input arguments and between 1 and 7 output arguments.') 0045 end 0046 % Check the first two inputs. 0047 [me,ne] = size(e); 0048 [md,nd] = size(d); 0049 if ( ~isreal(e) || ~isreal(d) || me~=ne || md~=nd || me~=nd) 0050 % info should be negative in this case, see dgges.f. 0051 error('MJDGGES requires two square real matrices of the same dimension.') 0052 end 0053 0054 % Set default value of qz_criterium. 0055 if nargin <3 0056 qz_criterium = 1 + 1e-6; 0057 end 0058 0059 info = 0; 0060 0061 % qz() function doesn't behave the same way under Octave and MATLAB: 0062 % - under MATLAB, complex decomposition by default, real is also available 0063 % as an option 0064 % - under Octave, only real decomposition available, but grouping of 0065 % eigenvalues <= 1 is implemented as an option (criterium can't be changed) 0066 if exist('OCTAVE_VERSION') 0067 [ss,tt,w,eigval] = qz(e,d,'S'); 0068 sdim = sum(abs(eigval) <= 1.0); 0069 if any(abs(eigval) > 1.0 & abs(eigval) <= qz_criterium) 0070 warning('Some eigenvalues are > 1.0 but <= qz_criterium in modulus. They have nevertheless been considered as explosive, because of a limitation of Octave. To solve this, you should compile the MEX files for Octave.') 0071 end 0072 else 0073 % Initialization of the output arguments. 0074 ss = zeros(ne,ne); 0075 tt = zeros(ne,ne); 0076 w = zeros(ne,ne); 0077 sdim = 0; 0078 eigval = zeros(ne,1); 0079 % Computational part. 0080 try 0081 [ss,tt,qq,w] = qz(e,d); 0082 [tt,ss,qq,w] = qzdiv(qz_criterium,tt,ss,qq,w); 0083 warning_old_state = warning; 0084 warning off; 0085 eigval = diag(ss)./diag(tt); 0086 warning(warning_old_state); 0087 sdim = sum(abs(eigval) < qz_criterium); 0088 catch 0089 info = 1;% Not as precise as lapack's info! 0090 end 0091 end 0092 err = 0;