OLS + aggregate: compatibility fix for Octave < 6
unique(…, 'stable') does not exist in Octave 5.time-shift
parent
6c5d61355b
commit
8f07a134a3
|
@ -2,7 +2,7 @@ function aggregate(ofile, dynopt, rootfolder, varargin)
|
|||
|
||||
% Agregates cherry-picked models.
|
||||
|
||||
% Copyright (C) 2019 Dynare Team
|
||||
% Copyright (C) 2019-2021 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -101,7 +101,11 @@ for i=1:length(varargin)
|
|||
end
|
||||
end
|
||||
eqlist = eqlist(1:eqnum,:);
|
||||
[~, idx] = unique(eqlist(:,1), 'stable');
|
||||
if isoctave && octave_ver_less_than('6')
|
||||
[~, idx] = unique_stable(eqlist(:,1));
|
||||
else
|
||||
[~, idx] = unique(eqlist(:,1), 'stable');
|
||||
end
|
||||
eqlist = eqlist(idx, :);
|
||||
|
||||
% Get endogenous variables.
|
||||
|
@ -124,7 +128,11 @@ for i=1:length(varargin)
|
|||
fclose(fid);
|
||||
end
|
||||
elist = elist(1:enum,:);
|
||||
[~, idx] = unique(elist(:,1), 'stable');
|
||||
if isoctave && octave_ver_less_than('6')
|
||||
[~, idx] = unique_stable(elist(:,1));
|
||||
else
|
||||
[~, idx] = unique(elist(:,1), 'stable');
|
||||
end
|
||||
elist = elist(idx,:);
|
||||
|
||||
% Get exogenous variables.
|
||||
|
@ -152,7 +160,11 @@ for i=1:length(varargin)
|
|||
fclose(fid);
|
||||
end
|
||||
xlist = xlist(1:xnum,:);
|
||||
[~, idx] = unique(xlist(:,1), 'stable');
|
||||
if isoctave && octave_ver_less_than('6')
|
||||
[~, idx] = unique_stable(xlist(:,1));
|
||||
else
|
||||
[~, idx] = unique(xlist(:,1), 'stable');
|
||||
end
|
||||
xlist = xlist(idx,:);
|
||||
|
||||
% Get parameter values.
|
||||
|
@ -291,4 +303,4 @@ function blkname = getblockname(str, ROOT_FOLDER)
|
|||
str = strrep(str, '/', filesep());
|
||||
str = strrep(str, [ROOT_FOLDER filesep() 'blocks' filesep()], '');
|
||||
idx = strfind(str, filesep());
|
||||
blkname = str(1:idx(1)-1);
|
||||
blkname = str(1:idx(1)-1);
|
||||
|
|
|
@ -16,7 +16,7 @@ function dynareroot = dynare_config(path_to_dynare)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2001-2020 Dynare Team
|
||||
% Copyright (C) 2001-2021 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -90,9 +90,10 @@ if isoctave && octave_ver_less_than('5')
|
|||
p{end+1} = '/missing/ordeig';
|
||||
end
|
||||
|
||||
%% intersect(…, 'stable') doesn't exist in Octave < 6
|
||||
%% 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
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
% 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 = unique_stable(x)
|
||||
|
||||
if iscell(x)
|
||||
error('Cell arrays unsupported')
|
||||
end
|
||||
|
||||
r = [];
|
||||
for i = 1:numel(x)
|
||||
if ~ismember(x(i), r)
|
||||
r = [ r, x(i) ];
|
||||
end
|
||||
end
|
||||
if size(x, 2) == 1
|
||||
r = r';
|
||||
end
|
||||
|
||||
end
|
|
@ -17,7 +17,7 @@ function [ast] = getEquationsByTags(ast, tagname, tagvalue)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2017-2019 Dynare Team
|
||||
% Copyright (C) 2017-2021 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -72,5 +72,9 @@ for i = 1:length(tagvalue)
|
|||
end
|
||||
end
|
||||
assert(~isempty(idx2keep), 'getEquationsByTags: no equations selected');
|
||||
ast = ast(unique(idx2keep, 'stable'));
|
||||
if isoctave && octave_ver_less_than('6')
|
||||
ast = ast(unique_stable(idx2keep));
|
||||
else
|
||||
ast = ast(unique(idx2keep, 'stable'));
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue