Removed Octave specific part in mjdgges.m function.

Also force complex QZ factorization in Octave.
time-shift
Stéphane Adjemian (Charybdis) 2017-04-21 16:03:38 +02:00
parent 7f7cb3ea07
commit ad21612967
1 changed files with 25 additions and 30 deletions

View File

@ -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;