Unverified Commit 47477e15 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Bump minimal Octave version to 6.2.0

parent c0ccca26
...@@ -210,7 +210,7 @@ License: GPL-3+ ...@@ -210,7 +210,7 @@ License: GPL-3+
Files: matlab/lmmcp/catstruct.m Files: matlab/lmmcp/catstruct.m
Copyright: 2005 Jos van der Geest <jos@jasen.nl> Copyright: 2005 Jos van der Geest <jos@jasen.nl>
2013 Christophe Gouel 2013 Christophe Gouel
2016-2017 Dynare Team 2016-2021 Dynare Team
License: BSD-2-clause License: BSD-2-clause
Files: matlab/lmmcp/lmmcp.m Files: matlab/lmmcp/lmmcp.m
......
...@@ -303,10 +303,6 @@ end ...@@ -303,10 +303,6 @@ end
% Get indices in params0 for other parameters (optimizing agents share plus parameters related to exogenous variables). % Get indices in params0 for other parameters (optimizing agents share plus parameters related to exogenous variables).
[~, params_id_2] = setdiff(1:length(ipnames_), params_id_1); [~, params_id_2] = setdiff(1:length(ipnames_), params_id_1);
if isoctave && octave_ver_less_than('6')
% Under Octave < 6, setdiff() behaves as with the 'legacy' option (i.e. pre-R2012b behaviour)
params_id_2 = params_id_2';
end
% Get indices in params0 for the parameters associated to the exogenous variables. % Get indices in params0 for the parameters associated to the exogenous variables.
params_id_3 = setdiff(params_id_2, params_id_0); params_id_3 = setdiff(params_id_2, params_id_0);
......
...@@ -111,11 +111,7 @@ for i=1:length(varargin) ...@@ -111,11 +111,7 @@ for i=1:length(varargin)
end end
end end
eqlist = eqlist(1:eqnum,:); eqlist = eqlist(1:eqnum,:);
if isoctave && octave_ver_less_than('6') [~, idx] = unique(eqlist(:,1), 'stable');
[~, idx] = unique_stable(eqlist(:,1));
else
[~, idx] = unique(eqlist(:,1), 'stable');
end
eqlist = eqlist(idx, :); eqlist = eqlist(idx, :);
% Get endogenous variables. % Get endogenous variables.
...@@ -138,11 +134,7 @@ for i=1:length(varargin) ...@@ -138,11 +134,7 @@ for i=1:length(varargin)
fclose(fid); fclose(fid);
end end
elist = elist(1:enum,:); elist = elist(1:enum,:);
if isoctave && octave_ver_less_than('6') [~, idx] = unique(elist(:,1), 'stable');
[~, idx] = unique_stable(elist(:,1));
else
[~, idx] = unique(elist(:,1), 'stable');
end
elist = elist(idx,:); elist = elist(idx,:);
% Get exogenous variables. % Get exogenous variables.
...@@ -170,11 +162,7 @@ for i=1:length(varargin) ...@@ -170,11 +162,7 @@ for i=1:length(varargin)
fclose(fid); fclose(fid);
end end
xlist = xlist(1:xnum,:); xlist = xlist(1:xnum,:);
if isoctave && octave_ver_less_than('6') [~, idx] = unique(xlist(:,1), 'stable');
[~, idx] = unique_stable(xlist(:,1));
else
[~, idx] = unique(xlist(:,1), 'stable');
end
xlist = xlist(idx,:); xlist = xlist(idx,:);
% Get parameter values. % Get parameter values.
......
...@@ -17,7 +17,7 @@ function oo_ = compute_moments_varendo(type, options_, M_, oo_, var_list_) ...@@ -17,7 +17,7 @@ function oo_ = compute_moments_varendo(type, options_, M_, oo_, var_list_)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2008-2020 Dynare Team % Copyright (C) 2008-2021 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -168,11 +168,7 @@ if options_.order==1 ...@@ -168,11 +168,7 @@ if options_.order==1
end end
skipline(); skipline();
if ~all(diag(M_.H)==0) if ~all(diag(M_.H)==0)
if isoctave && octave_ver_less_than('6') [observable_name_requested_vars, varlist_pos] = intersect(var_list_, options_.varobs, 'stable');
[observable_name_requested_vars, varlist_pos] = intersect_stable(var_list_, options_.varobs);
else
[observable_name_requested_vars, varlist_pos] = intersect(var_list_, options_.varobs, 'stable');
end
if ~isempty(observable_name_requested_vars) if ~isempty(observable_name_requested_vars)
NumberOfObservedEndogenousVariables = length(observable_name_requested_vars); NumberOfObservedEndogenousVariables = length(observable_name_requested_vars);
temp = NaN(NumberOfObservedEndogenousVariables, NumberOfExogenousVariables+1); temp = NaN(NumberOfObservedEndogenousVariables, NumberOfExogenousVariables+1);
......
...@@ -17,7 +17,7 @@ function [ConditionalVarianceDecomposition, ConditionalVarianceDecomposition_ME] ...@@ -17,7 +17,7 @@ function [ConditionalVarianceDecomposition, ConditionalVarianceDecomposition_ME]
% h is the number of Steps % h is the number of Steps
% p is the number of state innovations and % p is the number of state innovations and
% Copyright (C) 2010-2020 Dynare Team % Copyright (C) 2010-2021 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -89,11 +89,7 @@ end ...@@ -89,11 +89,7 @@ end
% Measurement error % Measurement error
if ~all(diag(StateSpaceModel.measurement_error)==0) if ~all(diag(StateSpaceModel.measurement_error)==0)
if isoctave && octave_ver_less_than('6') [observable_pos,index_subset,index_observables]=intersect(SubsetOfVariables,StateSpaceModel.observable_pos,'stable');
[observable_pos,index_subset,index_observables]=intersect_stable(SubsetOfVariables,StateSpaceModel.observable_pos);
else
[observable_pos,index_subset,index_observables]=intersect(SubsetOfVariables,StateSpaceModel.observable_pos,'stable');
end
ME_Variance=diag(StateSpaceModel.measurement_error); ME_Variance=diag(StateSpaceModel.measurement_error);
ConditionalVarianceDecomposition_ME = zeros(length(observable_pos),length(Steps),number_of_state_innovations+1); ConditionalVarianceDecomposition_ME = zeros(length(observable_pos),length(Steps),number_of_state_innovations+1);
......
...@@ -63,11 +63,7 @@ if isempty(exogenous_variable_index) ...@@ -63,11 +63,7 @@ if isempty(exogenous_variable_index)
end end
end end
if isoctave && octave_ver_less_than('6') [observable_pos_requested_vars,index_subset,index_observables]=intersect(var_list,options_.varobs,'stable');
[observable_pos_requested_vars,index_subset,index_observables]=intersect_stable(var_list,options_.varobs);
else
[observable_pos_requested_vars,index_subset,index_observables]=intersect(var_list,options_.varobs,'stable');
end
matrix_pos=strmatch(endo, var_list(index_subset),'exact'); matrix_pos=strmatch(endo, var_list(index_subset),'exact');
name_1 = endo; name_1 = endo;
name_2 = exo; name_2 = exo;
......
...@@ -11,7 +11,7 @@ function oo_=disp_moments(y,var_list,M_,options_,oo_) ...@@ -11,7 +11,7 @@ function oo_=disp_moments(y,var_list,M_,options_,oo_)
% OUTPUTS % OUTPUTS
% oo_ [structure] Dynare's results structure, % oo_ [structure] Dynare's results structure,
% Copyright (C) 2001-2020 Dynare Team % Copyright (C) 2001-2021 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -50,11 +50,7 @@ y = y(ivar,options_.drop+1:end)'; ...@@ -50,11 +50,7 @@ y = y(ivar,options_.drop+1:end)';
ME_present=0; ME_present=0;
if ~all(M_.H==0) if ~all(M_.H==0)
if isoctave && octave_ver_less_than('6') [observable_pos_requested_vars, index_subset, index_observables] = intersect(ivar, options_.varobs_id, 'stable');
[observable_pos_requested_vars, index_subset, index_observables] = intersect_stable(ivar, options_.varobs_id);
else
[observable_pos_requested_vars, index_subset, index_observables] = intersect(ivar, options_.varobs_id, 'stable');
end
if ~isempty(observable_pos_requested_vars) if ~isempty(observable_pos_requested_vars)
ME_present=1; ME_present=1;
i_ME = setdiff([1:size(M_.H,1)],find(diag(M_.H) == 0)); % find ME with 0 variance i_ME = setdiff([1:size(M_.H,1)],find(diag(M_.H) == 0)); % find ME with 0 variance
......
...@@ -2,7 +2,7 @@ function oo_ = disp_th_moments(dr, var_list, M_, options_, oo_) ...@@ -2,7 +2,7 @@ function oo_ = disp_th_moments(dr, var_list, M_, options_, oo_)
% Display theoretical moments of variables % Display theoretical moments of variables
% Copyright (C) 2001-2020 Dynare Team % Copyright (C) 2001-2021 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -55,11 +55,7 @@ oo_.var = oo_.gamma_y{1}; ...@@ -55,11 +55,7 @@ oo_.var = oo_.gamma_y{1};
ME_present=0; ME_present=0;
if ~all(diag(M_.H)==0) if ~all(diag(M_.H)==0)
if isoctave && octave_ver_less_than('6') [observable_pos_requested_vars,index_subset,index_observables]=intersect(ivar,options_.varobs_id,'stable');
[observable_pos_requested_vars,index_subset,index_observables]=intersect_stable(ivar,options_.varobs_id);
else
[observable_pos_requested_vars,index_subset,index_observables]=intersect(ivar,options_.varobs_id,'stable');
end
if ~isempty(observable_pos_requested_vars) if ~isempty(observable_pos_requested_vars)
ME_present=1; ME_present=1;
end end
...@@ -106,11 +102,7 @@ if size(stationary_vars, 1) > 0 ...@@ -106,11 +102,7 @@ if size(stationary_vars, 1) > 0
lh = cellofchararraymaxlength(labels)+2; lh = cellofchararraymaxlength(labels)+2;
dyntable(options_, title, headers, labels, 100*oo_.gamma_y{options_.ar+2}(stationary_vars,:), lh, 8, 2); dyntable(options_, title, headers, labels, 100*oo_.gamma_y{options_.ar+2}(stationary_vars,:), lh, 8, 2);
if ME_present if ME_present
if isoctave && octave_ver_less_than('6') [stationary_observables, pos_index_subset] = intersect(index_subset, stationary_vars, 'stable');
[stationary_observables, pos_index_subset] = intersect_stable(index_subset, stationary_vars);
else
[stationary_observables, pos_index_subset] = intersect(index_subset, stationary_vars, 'stable');
end
headers_ME = vertcat(headers, 'ME'); headers_ME = vertcat(headers, 'ME');
labels=get_labels_transformed_vars(M_.endo_names,ivar(stationary_observables),options_,false); labels=get_labels_transformed_vars(M_.endo_names,ivar(stationary_observables),options_,false);
dyntable(options_, [title,' WITH MEASUREMENT ERROR'], headers_ME, labels, ... dyntable(options_, [title,' WITH MEASUREMENT ERROR'], headers_ME, labels, ...
...@@ -213,4 +205,4 @@ if options_.ar > 0 && size(stationary_vars, 1) > 0 ...@@ -213,4 +205,4 @@ if options_.ar > 0 && size(stationary_vars, 1) > 0
dyn_latex_table(M_, options_, title, 'th_autocorr_matrix', headers, labels, z, lh, 8, 4); dyn_latex_table(M_, options_, title, 'th_autocorr_matrix', headers, labels, z, lh, 8, 4);
end end
end end
end end
\ No newline at end of file
...@@ -19,7 +19,7 @@ function [nvar,vartan,NumberOfConditionalDecompFiles] = ... ...@@ -19,7 +19,7 @@ function [nvar,vartan,NumberOfConditionalDecompFiles] = ...
% vartan [char] array of characters (with nvar rows). % vartan [char] array of characters (with nvar rows).
% NumberOfConditionalDecompFiles [integer] scalar, number of prior or posterior data files (for covariance). % NumberOfConditionalDecompFiles [integer] scalar, number of prior or posterior data files (for covariance).
% Copyright (C) 2009-2020 Dynare Team % Copyright (C) 2009-2021 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -84,11 +84,7 @@ MaXNumberOfConditionalDecompLines = ceil(options_.MaxNumberOfBytes/NumberOfSaved ...@@ -84,11 +84,7 @@ MaXNumberOfConditionalDecompLines = ceil(options_.MaxNumberOfBytes/NumberOfSaved
ME_present=0; ME_present=0;
if ~all(diag(M_.H)==0) if ~all(diag(M_.H)==0)
if isoctave && octave_ver_less_than('6') [observable_pos_requested_vars,index_subset,index_observables]=intersect(ivar,options_.varobs_id,'stable');
[observable_pos_requested_vars,index_subset,index_observables]=intersect_stable(ivar,options_.varobs_id);
else
[observable_pos_requested_vars,index_subset,index_observables]=intersect(ivar,options_.varobs_id,'stable');
end
if ~isempty(observable_pos_requested_vars) if ~isempty(observable_pos_requested_vars)
ME_present=1; ME_present=1;
nobs_ME=length(observable_pos_requested_vars); nobs_ME=length(observable_pos_requested_vars);
......
...@@ -18,7 +18,7 @@ function [nvar,vartan,NumberOfDecompFiles] = ... ...@@ -18,7 +18,7 @@ function [nvar,vartan,NumberOfDecompFiles] = ...
% vartan [char] array of characters (with nvar rows). % vartan [char] array of characters (with nvar rows).
% CovarFileNumber [integer] scalar, number of prior or posterior data files (for covariance). % CovarFileNumber [integer] scalar, number of prior or posterior data files (for covariance).
% Copyright (C) 2007-2020 Dynare Team % Copyright (C) 2007-2021 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -87,11 +87,7 @@ MaXNumberOfDecompLines = ceil(options_.MaxNumberOfBytes/NumberOfSavedElementsPer ...@@ -87,11 +87,7 @@ MaXNumberOfDecompLines = ceil(options_.MaxNumberOfBytes/NumberOfSavedElementsPer
ME_present=0; ME_present=0;
if ~all(diag(M_.H)==0) if ~all(diag(M_.H)==0)
if isoctave && octave_ver_less_than('6') [observable_pos_requested_vars,index_subset,index_observables]=intersect(ivar,options_.varobs_id,'stable');
[observable_pos_requested_vars,index_subset,index_observables]=intersect_stable(ivar,options_.varobs_id);
else
[observable_pos_requested_vars,index_subset,index_observables]=intersect(ivar,options_.varobs_id,'stable');
end
if ~isempty(observable_pos_requested_vars) if ~isempty(observable_pos_requested_vars)
ME_present=1; ME_present=1;
nobs_ME=length(observable_pos_requested_vars); nobs_ME=length(observable_pos_requested_vars);
......
...@@ -76,9 +76,9 @@ if isoctave ...@@ -76,9 +76,9 @@ if isoctave
'of precompiled mex files and some\nfeatures, like solution ' ... 'of precompiled mex files and some\nfeatures, like solution ' ...
'of models approximated at third order, will not be available.'], supported_octave_version()) 'of models approximated at third order, will not be available.'], supported_octave_version())
skipline() skipline()
elseif octave_ver_less_than('4.4') % Should match the test in mex/build/octave/configure.ac elseif octave_ver_less_than('6.2.0') % Should match the test in mex/build/octave/configure.ac, and also the one in matlab/modules/dseries/src/initialize_dseries_class.m
skipline() skipline()
warning(['This version of Dynare has only been tested on Octave 4.4 and above. Dynare may fail to run or give unexpected result. Consider upgrading your version of Octave.']) warning(['This version of Dynare has only been tested on Octave 6.2.0 and above. Dynare may fail to run or give unexpected result. Consider upgrading your version of Octave.'])
skipline() skipline()
end end
else else
......
...@@ -85,17 +85,6 @@ if ~isoctave ...@@ -85,17 +85,6 @@ if ~isoctave
p{end+1} = '/missing/vec'; p{end+1} = '/missing/vec';
end end
% ordeig() doesn't exist in Octave < 5
if isoctave && octave_ver_less_than('5')
p{end+1} = '/missing/ordeig';
end
%% intersect(…, 'stable') and unique(…, 'stable') doen't exist in Octave < 6
if isoctave && octave_ver_less_than('6')
p{end+1} = '/missing/intersect_stable';
p{end+1} = '/missing/unique_stable';
end
% Replacements for functions of the MATLAB statistics toolbox % Replacements for functions of the MATLAB statistics toolbox
if isoctave if isoctave
% Under Octave, these functions are in the statistics Forge package. % Under Octave, these functions are in the statistics Forge package.
...@@ -115,8 +104,8 @@ if ~exist('struct2array') ...@@ -115,8 +104,8 @@ if ~exist('struct2array')
p{end+1} = '/missing/struct2array'; p{end+1} = '/missing/struct2array';
end end
% isfile is missing in Octave < 5 and Matlab < R2017b % isfile is missing in MATLAB < R2017b
if (isoctave && octave_ver_less_than('5')) || (~isoctave && matlab_ver_less_than('9.3')) if ~isoctave && matlab_ver_less_than('9.3')
p{end+1} = '/missing/isfile'; p{end+1} = '/missing/isfile';
end end
......
...@@ -48,7 +48,7 @@ function A = catstruct(varargin) ...@@ -48,7 +48,7 @@ function A = catstruct(varargin)
% Copyright (C) 2005 Jos van der Geest <jos@jasen.nl> % Copyright (C) 2005 Jos van der Geest <jos@jasen.nl>
% Copyright (C) 2013 Christophe Gouel % Copyright (C) 2013 Christophe Gouel
% Copyright (C) 2016-2020 Dynare Team % Copyright (C) 2016-2021 Dynare Team
% %
% Redistribution and use in source and binary forms, with or without % Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are % modification, are permitted provided that the following conditions are
...@@ -150,11 +150,7 @@ else ...@@ -150,11 +150,7 @@ else
FN = squeeze(FN) ; FN = squeeze(FN) ;
VAL = squeeze(VAL) ; VAL = squeeze(VAL) ;
MatlabVersion = version; MatlabVersion = version;
if isoctave && octave_ver_less_than('6') [UFN,ind] = unique(FN,'legacy') ;
[UFN,ind] = unique(FN) ;
else
[UFN,ind] = unique(FN,'legacy') ;
end
if numel(UFN) ~= numel(FN) if numel(UFN) ~= numel(FN)
warning('catstruct:DuplicatesFound','Fieldnames are not unique between structures.') ; warning('catstruct:DuplicatesFound','Fieldnames are not unique between structures.') ;
......
% Crude implementation of intersect(…, 'stable'), which is missing in Octave
% Copyright (C) 2019 Dynare Team
%
% 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
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
function [c, ia, ib] = intersect_stable(a, b)
if nargin ~= 2
error('intersect_stable: needs exactly 2 input arguments');
end
if isnumeric (a) && isnumeric (b)
c = [];
elseif iscell (b)
c = {};
else
c = '';
end
ia = [];
ib = [];
if isempty (a) || isempty (b)
return
else
isrowvec = isrow (a) && isrow (b);
for i = 1:numel(a)
if iscellstr(c)
idx = strcmp(a(i), b);
else
idx = a(i) == b;
end
if any(idx) && ~ismember(a(i), c)
c = [c(:); a(i)];
if nargout > 1
ia = [ia, i];
ib = [ib, find(idx)];
end
end
end
%% Adjust output orientation for MATLAB compatibility
if isrowvec
c = c.';
end
end
end
%!test
%! a = [3 4 1 5];
%! b = [2 4 9 1 6];
%! [c,ia,ib]=intersect_stable(a,b);
%! assert(c, [4 1])
%! assert(ia, [2 3])
%! assert(ib, [2 4])
%! assert(a(ia), c)
%! assert(b(ib), c)
%!test
%! a = [3 4 1 5]';
%! b = [2 4 9 1 6]';
%! [c,ia,ib]=intersect_stable(a,b);
%! assert(c, [4 1]')
%! assert(ia, [2 3])
%! assert(ib, [2 4])
%! assert(a(ia), c)
%! assert(b(ib), c)
%!test
%! a = { 'defun', 'mapcar', 'let', 'eval-when'};
%! b = { 'setf', 'let', 'list', 'cdr', 'defun'};
%! [c,ia,ib]=intersect_stable(a,b);
%! assert(c, { 'defun', 'let' })
%! assert(ia, [1 3])
%! assert(ib, [5 2])
%! assert(a(ia), c)
%! assert(b(ib), c)
function eigs = ordeig(t)
% function eval = ordeig(t)
% Computes the eigenvalues of a quasi-triangular matrix
%
% INPUTS
% t: quasi-triangular matrix
%
% OUTPUTS
% eigs: eigenvalues
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2003-2017 Dynare Team
%
% 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
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
n = size(t,2);
eigs = zeros(n,1);
i = 1;
while i <= n
if i == n
eigs(n) = t(n,n);
break
elseif t(i+1,i) == 0
eigs(i) = t(i,i);
i = i+1;
else
k = i:i+1;
eigs(k) = eig(t(k,k));
i = i+2;
end
end
% Crude implementation of unique(…, 'stable'), which is missing in Octave < 6
% Copyright (C) 2021 Dynare Team
%
% 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
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
function [r, idx] = unique_stable(x)
idx = [];
if iscell(x)
r = {};
for i = 1:numel(x)
if ~ismember(x{i}, r)
r{end+1} = x{i};
idx(end+1) = i;
end
end
else
r = [];
for i = 1:numel(x)
if ~ismember(x(i), r)
r(end+1) = x(i);
idx(end+1) = i;
end
end
end
if size(x, 2) == 1
r = r';
end
Subproject commit 479460fee64681232b696745c9f3319700def1de Subproject commit a02a4ce6745c1e23ff9aaedd4db651c1acf3cd47
...@@ -72,9 +72,5 @@ for i = 1:length(tagvalue) ...@@ -72,9 +72,5 @@ for i = 1:length(tagvalue)
end end
end end
assert(~isempty(idx2keep), 'getEquationsByTags: no equations selected'); assert(~isempty(idx2keep), 'getEquationsByTags: no equations selected');
if isoctave && octave_ver_less_than('6') ast = ast(unique(idx2keep,