2023-01-02 16:57:08 +01:00
|
|
|
function [ss, tt, zz, sdim, eigval, info] = mjdgges(e, d, qz_criterium, zhreshold)
|
2008-04-25 14:47:30 +02:00
|
|
|
%
|
|
|
|
% INPUTS
|
|
|
|
% e [double] real square (n*n) matrix.
|
|
|
|
% d [double] real square (n*n) matrix.
|
|
|
|
% qz_criterium [double] scalar (1+epsilon).
|
2018-05-16 17:06:36 +02:00
|
|
|
% zhreshold [double] ignored (in the DLL, this parameter is used for
|
|
|
|
% detecting eigenvalues too close to 0/0)
|
2017-05-16 15:10:20 +02:00
|
|
|
%
|
2008-04-25 14:47:30 +02:00
|
|
|
% OUTPUTS
|
2018-05-16 17:06:36 +02:00
|
|
|
% ss [double] (n*n) quasi-triangular matrix.
|
|
|
|
% tt [double] (n*n) quasi-triangular matrix.
|
|
|
|
% zz [double] (n*n) orthogonal matrix.
|
|
|
|
% sdim [integer] scalar: number of stable eigenvalues.
|
|
|
|
% eigval [complex] (n*1) vector of generalized eigenvalues.
|
2008-04-25 14:47:30 +02:00
|
|
|
% info [integer] scalar.
|
2017-05-16 15:10:20 +02:00
|
|
|
%
|
2008-04-25 14:47:30 +02:00
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% none.
|
2008-08-01 14:40:33 +02:00
|
|
|
|
2023-01-02 16:57:08 +01:00
|
|
|
% Copyright © 1996-2023 Dynare Team
|
2008-08-01 14:40:33 +02:00
|
|
|
%
|
|
|
|
% This file is part of Dynare.
|
|
|
|
%
|
|
|
|
% Dynare is free software: you can redistribute it and/or modify
|
|
|
|
% it under the terms of the GNU General Public License as published by
|
|
|
|
% the Free Software Foundation, either version 3 of the License, or
|
|
|
|
% (at your option) any later version.
|
|
|
|
%
|
|
|
|
% Dynare is distributed in the hope that it will be useful,
|
|
|
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
% GNU General Public License for more details.
|
|
|
|
%
|
|
|
|
% You should have received a copy of the GNU General Public License
|
2021-06-09 17:33:48 +02:00
|
|
|
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
2009-12-16 18:17:34 +01:00
|
|
|
|
2018-05-16 17:06:36 +02:00
|
|
|
if nargin > 5 || nargin < 2 || nargout > 7 || nargout == 0
|
|
|
|
error('MJDGGES: takes 2, 3 or 4 input arguments and between 1 and 7 output arguments.')
|
|
|
|
end
|
|
|
|
|
|
|
|
[me, ne] = size(e);
|
|
|
|
[md, nd] = size(d);
|
|
|
|
if ~isreal(e) || ~isreal(d) || me ~= ne || md ~= nd || me ~= nd
|
2008-06-06 14:50:47 +02:00
|
|
|
error('MJDGGES requires two square real matrices of the same dimension.')
|
2008-04-25 14:47:30 +02:00
|
|
|
end
|
2009-12-08 10:36:03 +01:00
|
|
|
|
2018-05-16 17:06:36 +02:00
|
|
|
if nargin < 3
|
2017-05-16 15:10:20 +02:00
|
|
|
qz_criterium = 1 + 1e-6;
|
2008-04-25 14:47:30 +02:00
|
|
|
end
|
2009-12-08 10:36:03 +01:00
|
|
|
|
|
|
|
info = 0;
|
|
|
|
|
2017-04-21 16:03:38 +02:00
|
|
|
try
|
2023-04-07 10:24:05 +02:00
|
|
|
if isoctave && octave_ver_less_than('9')
|
2023-04-04 18:35:50 +02:00
|
|
|
[ss, tt, qq, zz] = qz(e, d);
|
|
|
|
else
|
|
|
|
[ss, tt, qq, zz] = qz(e, d, 'real');
|
|
|
|
end
|
2018-05-16 17:06:36 +02:00
|
|
|
eigval = ordeig(ss, tt);
|
|
|
|
select = abs(eigval) < qz_criterium;
|
|
|
|
sdim = sum(select);
|
2023-12-18 07:48:27 +01:00
|
|
|
[ss, tt, ~, zz] = ordqz(ss, tt, qq, zz, select);
|
2018-05-16 17:06:36 +02:00
|
|
|
eigval = ordeig(ss, tt);
|
2017-04-21 16:03:38 +02:00
|
|
|
catch
|
2018-05-16 17:06:36 +02:00
|
|
|
info = 1; % Not as precise as lapack's info!
|
2009-12-07 13:25:24 +01:00
|
|
|
end
|
2020-11-13 14:08:31 +01:00
|
|
|
|
2023-01-02 16:57:08 +01:00
|
|
|
return % --*-- Unit tests --*--
|
|
|
|
|
2020-11-13 14:08:31 +01:00
|
|
|
%@test:1
|
2023-01-02 16:57:08 +01:00
|
|
|
try
|
|
|
|
E =[0,0,0,0,0,0,0,-1,0,0;0,0,0,0,0,0,0,0,-1,0;0,0,0,0,0,0,0,0,0,-0.990099009900990;0,0,0,0,0,0,0,0,0,0.0990099009900990;0,0,0,-1.01010101010101,0,0.0427672955974843,0,0,0,0;0,0,0,0,0,0.128301886792453,-1,0,0,0;0.800000000000000,0,0,0,0,0,0,0,0,0;0,1,0,0,0,0,1,0,0,0;0,0,0.900000000000000,0,0,0,0,0,0,0;0,0,0,-1.01010101010101,-1,0,2,0,-1,0];
|
|
|
|
D=[0,0,0,0,-1,0,0,-0.792000000000000,0,0;0,0,0,0,0,0,0,0,-0.990000000000000,0;0,0,0,-0.000493818030899887,0,0,0,0,0,-0.882178217821782;0,0,0,-1.00493818030900,0,0,0,0,0,0.0882178217821782;0,0,0,-1,0.128301886792453,0,0,0,0,0;-1,0,0,0,0,0,-0.990000000000000,0,0,0;1,0,0,0,0,0,0,0,0,0;0,1,0,0,0,0,0,0,0,0;0,0,1,0,0,0,0,0,0,0;0,0,0,0,-1,0,0,0,0,0];
|
|
|
|
[ss, tt, w, sdim, dr.eigval, info1]=mjdgges(E, D, 1.000001, 1e-06);
|
|
|
|
if sdim==5
|
|
|
|
t(1) = 1;
|
|
|
|
else
|
|
|
|
t(1) = 0;
|
|
|
|
end
|
|
|
|
catch
|
|
|
|
t(1) = 0;
|
|
|
|
end
|
|
|
|
T = all(t);
|
2023-04-04 18:35:50 +02:00
|
|
|
%@eof:1
|