From ad21612967f41a60be01994d7423ca3893e11dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 21 Apr 2017 16:03:38 +0200 Subject: [PATCH] Removed Octave specific part in mjdgges.m function. Also force complex QZ factorization in Octave. --- matlab/qz/mjdgges.m | 55 +++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/matlab/qz/mjdgges.m b/matlab/qz/mjdgges.m index 2225e257b..c78328020 100644 --- a/matlab/qz/mjdgges.m +++ b/matlab/qz/mjdgges.m @@ -22,7 +22,7 @@ function [err,ss,tt,w,sdim,eigval,info] = mjdgges(e,d,qz_criterium, fake) % SPECIAL REQUIREMENTS % none. -% Copyright (C) 1996-2010 Dynare Team +% Copyright (C) 1996-2017 Dynare Team % % This file is part of Dynare. % @@ -43,6 +43,7 @@ function [err,ss,tt,w,sdim,eigval,info] = mjdgges(e,d,qz_criterium, fake) if nargin>4 || nargin<2 || nargout>7 || nargout==0 error('MJDGGES: takes 2 or 3 input arguments and between 1 and 7 output arguments.') end + % Check the first two inputs. [me,ne] = size(e); [md,nd] = size(d); @@ -58,35 +59,29 @@ end info = 0; -% qz() function doesn't behave the same way under Octave and MATLAB: -% - under MATLAB, complex decomposition by default, real is also available -% as an option -% - under Octave, only real decomposition available, but grouping of -% eigenvalues <= 1 is implemented as an option (criterium can't be changed) -if isoctave - [ss,tt,w,eigval] = qz(e,d,'S'); - sdim = sum(abs(eigval) <= 1.0); - if any(abs(eigval) > 1.0 & abs(eigval) <= qz_criterium) - 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.') - end -else - % Initialization of the output arguments. - ss = zeros(ne,ne); - tt = zeros(ne,ne); - w = zeros(ne,ne); - sdim = 0; - eigval = zeros(ne,1); - % Computational part. - try - [ss,tt,qq,w] = qz(e,d); - [tt,ss,qq,w] = qzdiv(qz_criterium,tt,ss,qq,w); - warning_old_state = warning; - warning off; - eigval = diag(ss)./diag(tt); - warning(warning_old_state); - sdim = sum(abs(eigval) < qz_criterium); - catch - info = 1;% Not as precise as lapack's info! +% Initialization of the output arguments. +ss = zeros(ne,ne); +tt = zeros(ne,ne); +w = zeros(ne,ne); +sdim = 0; +eigval = zeros(ne,1); + +% Computational part. +try + if isoctave() + % Force complex QZ factorization. + e = complex(e); + d = complex(d); end + [ss,tt,qq,w,a,b,c] = qz(e, d); + [tt,ss,qq,w] = qzdiv(qz_criterium, tt, ss, qq, w); + warning_old_state = warning; + warning off; + eigval = diag(ss)./diag(tt); + warning(warning_old_state); + sdim = sum(abs(eigval) < qz_criterium); +catch + info = 1;% Not as precise as lapack's info! end + err = 0; \ No newline at end of file