Bump minimal required version of MATLAB to R2018b

Ref. #1907
dcontrib-log
Sébastien Villemot 2023-11-22 13:24:52 +01:00
parent 0efe0c9844
commit 7f58e819c6
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
44 changed files with 83 additions and 364 deletions

View File

@ -2,7 +2,7 @@ variables:
GIT_SUBMODULE_STRATEGY: recursive
TERM: linux
MATLAB_VERSION: R2023b
OLD_MATLAB_VERSION: R2014a
OLD_MATLAB_VERSION: R2018b
# The next stanza creates the version number used for the source tarball and the
# binary packages. Here are the following possible cases:

View File

@ -14,7 +14,7 @@ compilation steps are necessary in that case.
In order to run Dynare, you need one of the following:
* MATLAB, any version ranging from 8.3 (R2014a) to 23.2 (R2023b);
* MATLAB, any version ranging from 9.5 (R2018b) to 23.2 (R2023b);
* GNU Octave, any version ranging from 6.2.0 to 8.4.0, with the statistics package
from `Octave-Forge`_. Note however that the Dynare installer for Windows
requires a more specific version of Octave, as indicated on the download

View File

@ -37,8 +37,6 @@ else
# Remove /opt/homebrew/bin from PATH, so it does not intervene with the x86_64 compilations
path_remove PATH /opt/homebrew/bin
MATLAB_ARCH=maci64
# On x86_64 we need to differentiate between older and newer MATLAB versions
OLD_MATLAB_PATH=/Applications/"$PKG_ARCH"/MATLAB_R2016b.app
fi
MATLAB_PATH=/Applications/"$PKG_ARCH"/MATLAB_R2023b.app
@ -71,16 +69,10 @@ common_meson_opts=(-Dbuild_for=matlab -Dbuildtype=release -Dprefer_static=true -
-Dc_link_args="[ '-Wl,-ld_classic', '-L$QUADMATH_DIR' ]" -Dcpp_link_args="[ '-Wl,-ld_classic', '-L$QUADMATH_DIR' ]" -Dfortran_link_args="[ '-Wl,-ld_classic', '-L$QUADMATH_DIR' ]" \
--native-file scripts/homebrew-native-$PKG_ARCH.ini)
# Build for MATLAB ⩾ R2018a (x86_64) and MATLAB ⩾ R2023b (arm64)
# Build for MATLAB ⩾ R2018b (x86_64) and MATLAB ⩾ R2023b (arm64)
arch -"$PKG_ARCH" meson setup "${common_meson_opts[@]}" -Dmatlab_path="$MATLAB_PATH" build-matlab --wipe
arch -"$PKG_ARCH" meson compile -v -C build-matlab
if [[ "$PKG_ARCH" == x86_64 ]]; then
# Build for MATLAB < R2018a
arch -"$PKG_ARCH" meson setup "${common_meson_opts[@]}" -Dmatlab_path="$OLD_MATLAB_PATH" build-old-matlab --wipe
arch -"$PKG_ARCH" meson compile -v -C build-old-matlab
fi
# If not in CI, build the docs
if [[ -z $CI ]]; then
arch -"$PKG_ARCH" meson compile -v -C build-matlab doc
@ -125,8 +117,7 @@ mkdir -p \
"$PKGFILES"/scripts \
"$PKGFILES"/contrib/ms-sbvar/TZcode
if [[ "$PKG_ARCH" == x86_64 ]]; then
mkdir -p "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-8.3-9.3 \
"$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-9.4-23.2
mkdir -p "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-9.5-23.2
else
mkdir -p "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-23.2
fi
@ -147,8 +138,7 @@ mkdir -p "$PKGFILES"
ln -sf ../../preprocessor/dynare-preprocessor "$PKGFILES"/matlab/preprocessor64/dynare_m
if [[ "$PKG_ARCH" == x86_64 ]]; then
cp -L "$ROOTDIR"/build-matlab/*.mex"$MATLAB_ARCH" "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-9.4-23.2
cp -L "$ROOTDIR"/build-old-matlab/*.mex"$MATLAB_ARCH" "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-8.3-9.3
cp -L "$ROOTDIR"/build-matlab/*.mex"$MATLAB_ARCH" "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-9.5-23.2
else
cp -L "$ROOTDIR"/build-matlab/*.mex"$MATLAB_ARCH" "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-23.2
fi

View File

@ -60,11 +60,11 @@ for jm = 1:options_mom_.mom.mom_nbr
end
end
% We replace NaN (due to leads and lags and missing values) with the corresponding mean
if isoctave || matlab_ver_less_than('8.5')
if isoctave
dataMoments(jm,1) = nanmean(m_data_tmp);
else
dataMoments(jm,1) = mean(m_data_tmp,'omitnan');
end
m_data_tmp(isnan(m_data_tmp)) = dataMoments(jm,1);
m_data(:,jm) = m_data_tmp;
end
end

View File

@ -172,22 +172,6 @@ options_mom_ = mom.default_option_mom_values(options_mom_, options_, M_.dname, d
% -------------------------------------------------------------------------
% workarounds
% -------------------------------------------------------------------------
% The TeX option crashes MATLAB R2014a run with "-nodisplay" option
% (as is done from the testsuite).
% Since we cant directly test whether "-nodisplay" has been passed,
% we test for the "source_root" environment variable, which is set
% by the testsuite.
% Note that it was not tested whether the crash happens with more
% recent MATLAB versions, so when OLD_MATLAB_VERSION is increased,
% one should make a test before removing this workaround.
if options_.TeX && ~isoctave && matlab_ver_less_than('8.4') && ~isempty(getenv('source_root'))
warning('Disabling TeX option due to a bug in MATLAB R2014a with -nodisplay')
options_.TeX = false;
end
if isfield(options_mom_, 'TeX') && options_mom_.TeX && ~isoctave && matlab_ver_less_than('8.4') && ~isempty(getenv('source_root'))
warning('Disabling TeX option due to a bug in MATLAB R2014a with -nodisplay')
options_mom_.TeX = false;
end
if strcmp(options_mom_.mom.mom_method,'GMM') || strcmp(options_mom_.mom.mom_method,'SMM')
% temporary workaround for https://git.dynare.org/Dynare/dseries/-/issues/51
if options_mom_.xls_sheet~=1

View File

@ -98,11 +98,7 @@ if T_max > 0
% check if last binding regime was already stored
tmp = 0*binding_indicator;
tmp(1:end-T_max+1,:) = binding_indicator(T_max:end,:);
if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b
itmp = find(~any(bsxfun(@minus, dictionary.binding_indicator(1:length(tmp)*2,:), tmp(:))));
else
itmp = find(~any(dictionary.binding_indicator(1:length(tmp)*2,:)-tmp(:)));
end
itmp = find(~any(dictionary.binding_indicator(1:length(tmp)*2,:)-tmp(:)));
if ~isempty(itmp)
ireg(T_max) = itmp;
else
@ -134,11 +130,7 @@ if T_max > 0
for i = T_max-1:-1:1
tmp = 0*binding_indicator;
tmp(1:end-i+1,:) = binding_indicator(i:end,:);
if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b
itmp = find(~any(bsxfun(@minus, dictionary.binding_indicator(1:length(tmp)*2,:), tmp(:))));
else
itmp = find(~any(dictionary.binding_indicator(1:length(tmp)*2,:)-tmp(:)));
end
itmp = find(~any(dictionary.binding_indicator(1:length(tmp)*2,:)-tmp(:)));
if ~isempty(itmp)
ireg(i) = itmp;
else

View File

@ -89,11 +89,7 @@ if T_max > 0
tmp = 0*binding_indicator;
tmp(1:end-i+1) = binding_indicator(i:end);
if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b
itmp = find(~any(bsxfun(@minus, dictionary.binding_indicator, tmp)));
else
itmp = find(~any(dictionary.binding_indicator-tmp));
end
itmp = find(~any(dictionary.binding_indicator-tmp));
if ~isempty(itmp)
ireg(i) = itmp;
else

View File

@ -19,7 +19,7 @@ function [dr, out, ss] = solver(M_, options_, dr ,steady_state, exo_steady_state
% - R: [n_vars by n_exo by n_shock_period] array of shock response matrices
% - C: [n_vars by n_shock_period] array of constants
% Copyright © 2021 Dynare Team
% Copyright © 2021-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -90,15 +90,7 @@ end
% add back steady state
if ~options_.occbin.simul.piecewise_only
if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b
out.linear = bsxfun(@plus, out.linear, out.ys');
else
out.linear = out.linear + out.ys';
end
out.linear = out.linear + out.ys';
end
if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b
out.piecewise = bsxfun(@plus, out.piecewise, out.ys');
else
out.piecewise = out.piecewise + out.ys';
end
out.exo_pos = options_.occbin.simul.exo_pos;
out.piecewise = out.piecewise + out.ys';
out.exo_pos = options_.occbin.simul.exo_pos;

View File

@ -7,7 +7,7 @@ function write_regimes_to_xls(occbin_struct,M_,options_)
% - M_ [struct] Matlab's structure describing the model
% - options_ [struct] Matlab's structure describing the current options
% Copyright © 2021 Dynare Team
% Copyright © 2021-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -62,14 +62,7 @@ else
end
end
if ~ispc && ~isoctave && matlab_ver_less_than('9.0')
% On GNU/Linux and macOS, with MATLAB < R2016a, “writeable” cant write Excel files
% (and “xlswrite” cant either)
warning('This version of MATLAB is too old and cannot create Excel files. The Occbin regimes will rather be written to a CSV file.')
filename=[OutputDirectoryName filesep xls_filename '.csv'];
else
filename=[OutputDirectoryName filesep xls_filename '.xls'];
end
filename=[OutputDirectoryName filesep xls_filename '.xls'];
if isfile(filename)
delete(filename)
@ -81,10 +74,6 @@ if isoctave
error('The io package is required to write XLS files from Octave')
end
xlswrite(filename, vertcat(Header, xlsmat));
elseif ~ispc && matlab_ver_less_than('9.0')
% Use a CSV file. See the comment above about filename.
% We dont use xlswrite because its CSV fallback does not support cell-arrays.
writetable(array2table(xlsmat,'VariableNames',Header), filename);
else
writetable(array2table(xlsmat,'VariableNames',Header), filename, 'Sheet', 'Regimes');
end

View File

@ -87,9 +87,9 @@ if isoctave
skipline()
end
else
if matlab_ver_less_than('8.3') % Should match the test in meson.build
if matlab_ver_less_than('9.5') % Should match the test in meson.build
skipline()
warning('This version of Dynare has only been tested on MATLAB 8.3 (R2014a) and above. Since your MATLAB version is older than that, Dynare may fail to run, or give unexpected results. Consider upgrading your MATLAB installation, or switch to Octave.');
warning('This version of Dynare has only been tested on MATLAB 9.5 (R2018b) and above. Since your MATLAB version is older than that, Dynare may fail to run, or give unexpected results. Consider upgrading your MATLAB installation, or switch to Octave.');
skipline()
end
end

View File

@ -105,19 +105,14 @@ if ~exist('struct2array')
p{end+1} = '/missing/struct2array';
end
% isfile is missing in MATLAB < R2017b
if ~isoctave && matlab_ver_less_than('9.3')
p{end+1} = '/missing/isfile';
end
% contains and splitlines don't exist in Octave and in MATLAB < R2016b
if isoctave || matlab_ver_less_than('9.1')
% contains and splitlines don't exist in Octave
if isoctave
p{end+1} = '/missing/contains';
p{end+1} = '/missing/splitlines';
end
% datetime doesn't exist in Octave and in MATLAB < R2014b
if isoctave || matlab_ver_less_than('8.4')
% datetime doesn't exist in Octave
if isoctave
p{end+1} = '/missing/datetime';
end

View File

@ -43,19 +43,6 @@ if ~isempty(strmatch('dsge_prior_weight',M_.param_names))
options_.dsge_var = 1;
end
% The TeX option crashes MATLAB R2014a run with "-nodisplay" option
% (as is done from the testsuite).
% Since we cant directly test whether "-nodisplay" has been passed,
% we test for the "source_root" environment variable, which is set
% by the testsuite.
% Note that it was not tested whether the crash happens with more
% recent MATLAB versions, so when OLD_MATLAB_VERSION is increased,
% one should make a test before removing this workaround.
if options_.TeX && ~isoctave && matlab_ver_less_than('8.4') && ~isempty(getenv('source_root'))
warning('Disabling TeX option due to a bug in MATLAB R2014a with -nodisplay')
options_.TeX = false;
end
var_list = check_list_of_variables(options_, M_, var_list);
options_.varlist = var_list;

View File

@ -67,19 +67,6 @@ function [pdraws, STO_REDUCEDFORM, STO_MOMENTS, STO_DYNAMIC, STO_si_dDYNAMIC, ST
global M_ options_ oo_ bayestopt_ estim_params_
% The TeX option crashes MATLAB R2014a run with "-nodisplay" option
% (as is done from the testsuite).
% Since we cant directly test whether "-nodisplay" has been passed,
% we test for the "source_root" environment variable, which is set
% by the testsuite.
% Note that it was not tested whether the crash happens with more
% recent MATLAB versions, so when OLD_MATLAB_VERSION is increased,
% one should make a test before removing this workaround.
if options_.TeX && ~isoctave && matlab_ver_less_than('8.4') && ~isempty(getenv('source_root'))
warning('Disabling TeX option due to a bug in MATLAB R2014a with -nodisplay')
options_.TeX = false;
end
store_options_ = options_; % store options to restore them at the end
fname = M_.fname; %model name
dname = M_.dname; %model name

View File

@ -162,7 +162,7 @@ if options.solve_algo == 0
else
options4fsolve = optimoptions('fsolve');
end
if isoctave || matlab_ver_less_than('9.0') % Option names changed in MATLAB R2016a
if isoctave
options4fsolve.MaxFunEvals = 50000;
options4fsolve.MaxIter = maxit;
options4fsolve.TolFun = tolf;

View File

@ -27,11 +27,7 @@ nterms = size(z,2);
for k=1:size(y,1)
ytmp = squeeze(y(k,:,:));
yres = ytmp(end,:) - sum(ytmp(1:end-1,:));
if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b
w = bsxfun(@rdivide, abs(ytmp(1:end-1,:)), sum(abs(ytmp(1:end-1,:))))
else
w = abs(ytmp(1:end-1,:))./sum(abs(ytmp(1:end-1,:)));
end
w = abs(ytmp(1:end-1,:))./sum(abs(ytmp(1:end-1,:)));
% ytmp(1:end-1,:) = ytmp(1:end-1,:) + repmat(yres,[nterms-1 1])/(nterms-1);
ytmp(1:end-1,:) = ytmp(1:end-1,:) + repmat(yres,[nterms-1 1]).*w;
y(k,:,:) = ytmp;

View File

@ -47,30 +47,16 @@ else
end
% Add win64 specific paths for Dynare Windows package
if strcmp(computer, 'PCWIN64')
if matlab_ver_less_than('9.4')
tmp = [dynareroot '../mex/matlab/win64-8.3-9.3/'];
if exist(tmp, 'dir')
mexpath = tmp;
end
else
tmp = [dynareroot '../mex/matlab/win64-9.4-23.2/'];
if exist(tmp, 'dir')
mexpath = tmp;
end
tmp = [dynareroot '../mex/matlab/win64-9.5-23.2/'];
if exist(tmp, 'dir')
mexpath = tmp;
end
end
% Add macOS paths for Dynare Mac package
if strcmp(computer, 'MACI64')
if matlab_ver_less_than('9.4')
tmp = [dynareroot '../mex/matlab/maci64-8.3-9.3/'];
if exist(tmp, 'dir')
mexpath = tmp;
end
else
tmp = [dynareroot '../mex/matlab/maci64-9.4-23.2/'];
if exist(tmp, 'dir')
mexpath = tmp;
end
tmp = [dynareroot '../mex/matlab/maci64-9.5-23.2/'];
if exist(tmp, 'dir')
mexpath = tmp;
end
end
if strcmp(computer, 'MACA64')

View File

@ -190,8 +190,8 @@ for j=1:nvar
ineg=zz<0;
hax = subplot(nrow,ncol,i); set(gca,'box','on')
hbar = bar(x(2:end),(zz.*ipos)','stacked','FaceColor','flat');
if ~isoctave && ~matlab_ver_less_than('9.3.0')
% make bar obey colormap under MATLAB R2017b
if ~isoctave
% make bar obey colormap under MATLAB
for k = 1:2
hbar(k).CData = k;
end
@ -199,8 +199,8 @@ for j=1:nvar
set(hbar,'edgecolor','flat');
hold on,
hbar = bar(x(2:end),(zz.*ineg)','stacked','FaceColor','flat');
if ~isoctave && ~matlab_ver_less_than('9.3.0')
% make bar obey colormap under MATLAB R2017b
if ~isoctave
% make bar obey colormap under MATLAB
for k = 1:2
hbar(k).CData = k;
end

View File

@ -10,9 +10,8 @@ function o = loadjson_(jsonfilename)
%
% REMARKS
% jsondecode builtin was introduced in MATLAB R2016b and in Octave 7.
% Older MATLAB and Octave versions use jsonlab as fallback.
% Copyright © 2020-2022 Dynare Team
% Copyright © 2020-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -29,7 +28,7 @@ function o = loadjson_(jsonfilename)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if (isoctave && octave_ver_less_than('7')) || (~isoctave && matlab_ver_less_than('9.1'))
if isoctave && octave_ver_less_than('7')
o = loadjson(jsonfilename);
return
end

View File

@ -1,88 +0,0 @@
function a = isfile(b)
%@info:
%! @deftypefn {Function File} {@var{a} =} isfile (@var{b})
%! @anchor{isfile}
%! @sp 1
%! Test if @var{b} is a file.
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @var
%! @item b
%! A matlab/octave string.
%! @end table
%! @sp 2
%! @strong{Outputs}
%! @sp 1
%! @table @var
%! @item a
%! Integer scalar, equal to 1 if @var{b} is a file, zero otherwise.
%! @end table
%! @sp 2
%! @strong{This function is called by:}
%! @sp 2
%! @strong{This function calls:}
%! @sp 2
%! @end deftypefn
%@eod:
% Copyright © 2012-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 <https://www.gnu.org/licenses/>.
stringarrayflag = false;
cellofstringflag = false;
n = 1;
a = false;
if ~isoctave() && ~matlab_ver_less_than('9.1') && isstring(b) && length(b)>1 && isvector(b)
n = length(b);
stringarrayflag = true;
a = false(size(b));
end
if iscell(b) && length(b)>1 && isvector(b)
if all(cellfun(@ischar, b))
n = length(b);
cellofstringflag = true;
a = false(size(b));
else
error('Wrong input argument type!')
end
end
for i=1:n
if stringarrayflag
d = b(i);
elseif cellofstringflag
d = b{i};
elseif ischar(b) && size(b, 1)==1
d = b;
else
error('Wrong input argument type!')
end
[base, ext] = strtok(d, '.');
if isempty(ext)
% File has no extension.
[status, c] = fileattrib(d);
if status
a(i) = ~c.directory;
end
else
a(i) = isequal(exist(d, 'file'), 2);
end
end

View File

@ -9,7 +9,7 @@ function g = best_1978(a ,b)
% OUTPUTS
% - g [double] n*1 vector, gamma variates.
% Copyright © 2006-2020 Dynare Team
% Copyright © 2006-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -44,12 +44,7 @@ while mm
X(index) = bb(index)+Y(index); % x
id1 = index(X(index)<0); % Reject.
id2 = setdiff(index, id1);
if numel(id2) ~= 0 || isoctave || ~matlab_ver_less_than('9.1')
% If id2=[], LHS of the .* has size [0,0], while RHS is [0,1].
% Since there is no automatic broadcast in MATLAB < R2016b, skip the
% statement in that case.
Z(id2) = 64.0*(W(id2).^3).*(rand(length(id2),1).^2); % d
end
Z(id2) = 64.0*(W(id2).^3).*(rand(length(id2),1).^2); % d
id3 = id2(Z(id2)>1.0-2.0*Y(id2).*Y(id2)./X(id2)); % Reject.
id4 = id3(log(Z(id3))>2.0*(bb(id3).*log(X(id3)./bb(id3))-Y(id3))); % Reject.
index = [id1, id4];

View File

@ -9,7 +9,7 @@ function g = knuth(a, b)
% OUTPUTS
% - g [double] n*1 vector, gamma variates.
% Copyright © 2006-2020 Dynare Team
% Copyright © 2006-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -38,15 +38,7 @@ while mm
X(index) = Y(index).*bb(index) + a(index) - 1;
id1 = index(X(index)<=0); % Rejected draws.
id2 = setdiff(index, id1);
if numel(id2) == 0 && ~isoctave && matlab_ver_less_than('9.1')
% The LHS of the > comparison in the "else" branch has size = [0, 1]
% while the RHS has size = [0, 0].
% Automatic broadcasting was only introduced in MATLAB R2016b, so we
% must handle this case separately to avoid an error.
id3 = [];
else
id3 = id2(rand(length(id2), 1)>(1+Y(id2).*Y(id2)).*exp((a(id2)-1).*(log(X(id2))-log(a(id2)-1))-bb(id2).*Y(id2))); % Rejected draws.
end
id3 = id2(rand(length(id2), 1)>(1+Y(id2).*Y(id2)).*exp((a(id2)-1).*(log(X(id2))-log(a(id2)-1))-bb(id2).*Y(id2))); % Rejected draws.
index = [id1, id3];
mm = length(index);
end

@ -1 +1 @@
Subproject commit 3d7817fcd9b929d5e71b2669e59f2268558d136a
Subproject commit 99b6f167e71945a45249dbc6b5100d2ca6b1474f

View File

@ -26,7 +26,7 @@ function [opt_par_values,fval,exitflag,hessian_mat,options_,Scale,new_rat_hess_i
% none.
%
%
% Copyright © 2014-2021 Dynare Team
% Copyright © 2014-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -566,7 +566,7 @@ switch minimizer_algorithm
optim_options.Display='off';
end
if options_.analytic_derivation || (isfield(options_,'mom') && options_.mom.analytic_jacobian==1)
if isoctave || matlab_ver_less_than('9.0') % Option names changed in MATLAB R2016a
if isoctave
optim_options.Jacobian = 'on';
else
optim_options.SpecifyObjectiveGradient = true;

View File

@ -36,19 +36,6 @@ if isequal(options_.order,0)
error('stoch_simul:: The order of the Taylor approximation cannot be 0!')
end
% The TeX option crashes MATLAB R2014a run with "-nodisplay" option
% (as is done from the testsuite).
% Since we cant directly test whether "-nodisplay" has been passed,
% we test for the "source_root" environment variable, which is set
% by the testsuite.
% Note that it was not tested whether the crash happens with more
% recent MATLAB versions, so when OLD_MATLAB_VERSION is increased,
% one should make a test before removing this workaround.
if options_.TeX && ~isoctave && matlab_ver_less_than('8.4') && ~isempty(getenv('source_root'))
warning('Disabling TeX option due to a bug in MATLAB R2014a with -nodisplay')
options_.TeX = false;
end
if M_.exo_nbr==0
error('stoch_simul:: does not support having no varexo in the model. As a workaround you could define a dummy exogenous variable.')
end

View File

@ -217,8 +217,8 @@ end
% Plot
%
% The histogram() function is not implemented in Octave and in MATLAB < R2014b
if ~options_.nograph && ~isoctave && ~matlab_ver_less_than('8.4')
% The histogram() function is not implemented in Octave
if ~options_.nograph && ~isoctave
figure
nrows = 5;
ncols = floor(nparams/nrows);

View File

@ -36,7 +36,7 @@ function [x, errorflag, info] = trust_region(objfun, x, j1, j2, jacobianflag, gs
% 4 if iteration is not making good progress, as measured by the improvement from the last 15 iterations.
% 5 if no further improvement in the approximate solution x is possible (xtol is too small).
% Copyright © 2014-2022 Dynare Team
% Copyright © 2014-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -285,8 +285,8 @@ end
function x = dogleg (r, b, d, delta)
% Compute the Gauss-Newton direction.
if isoctave || matlab_ver_less_than('9.3')
% The decomposition() function does not exist in Octave and MATLAB < R2017b
if isoctave
% The decomposition() function does not exist in Octave
x = r \ b;
else
x = decomposition(r, 'CheckCondition', false) \ b;
@ -332,4 +332,4 @@ else
else %prevent zero weight on Inf evaluating to NaN
x = min(sgnorm, delta)*s;
end
end
end

View File

@ -97,7 +97,7 @@ if get_option('build_for') == 'matlab'
error('The “matlab_path” option must be provided when doing a MATLAB build')
endif
matlab_version = run_command('scripts/get-matlab-version', matlab_path, check : true).stdout().strip()
matlab_minimal_version = [ '8.3', 'R2014a' ]
matlab_minimal_version = [ '9.5', 'R2018b' ]
if matlab_version.version_compare('<' + matlab_minimal_version[0])
error('MATLAB is too old (version ' + matlab_version + '), please upgrade to version ' + matlab_minimal_version[0] + ' (' + matlab_minimal_version[1] + ') at least.')

View File

@ -1 +1 @@
#define MX_HAS_INTERLEAVED_COMPLEX (defined(MATLAB_MEX_FILE) && MATLAB_VERSION >= 0x0904)
#define MX_HAS_INTERLEAVED_COMPLEX (defined(MATLAB_MEX_FILE))

View File

@ -26,24 +26,4 @@
#include <mex.h>
#if defined(MATLAB_MEX_FILE) && MATLAB_VERSION < 0x0805
# define mxIsScalar(x) (mxGetM(x) == 1 && mxGetN(x) == 1)
#endif
/* The int64_T and uint64_T type are broken under MinGW for MATLAB < R2015b
(they actually alias long integer types, which are 32-bit) */
#if defined(MATLAB_MEX_FILE) && defined(__MINGW64__) && MATLAB_VERSION < 0x0806
# define int64_T long long
# define uint64_T unsigned long long
#endif
/* NB: the following #ifdef can be removed when we upgrade to C23, since the
latter has static_assert as a keyword */
#ifdef __cplusplus
static_assert(sizeof(int64_T) == 8, "The int64_T type is buggy");
static_assert(sizeof(uint64_T) == 8, "The uint64_T type is buggy");
#else
_Static_assert(sizeof(int64_T) == 8, "The int64_T type is buggy");
_Static_assert(sizeof(uint64_T) == 8, "The uint64_T type is buggy");
#endif
#endif

View File

@ -8,11 +8,11 @@
! Things to be aware of when adding new interfaces this file:
!
! — The tricky part is to deal with API versioning.
! • API_VER is for functions which were not versioned before 9.4 (R2018a)
! • API_VER2 is for functions which were versioned _730 before 9.4 (R2018a)
! when not using the MX_COMPAT_32 mode
! For MATLAB ⩾ R2018b, all versions share the same API (embodied in API_VER
! define), but in the past the API would differ across function, so there
! was an API_VER2 define for those.
! For each function, the information can be retrieved from either matrix.h or
! mex.h from R2014a
! mex.h.
! — C passes arguments by value, so the “value” keyword is often needed
! — Strings passed to C must be null terminated (hence a wrapper is needed to
! append c_null_char)
@ -49,17 +49,10 @@
! along with Dynare. If not, see <https://www.gnu.org/licenses/>.
#ifdef MATLAB_MEX_FILE
# if MATLAB_VERSION >= 0x0904
# define API_VER "_800"
# define API_VER2 "_800"
# else
# define API_VER ""
# define API_VER2 "_730"
# endif
# define API_VER "_800"
#else
! Octave
# define API_VER ""
# define API_VER2 ""
#endif
#include "defines.F08"
@ -116,7 +109,7 @@ module matlab_mat
!! Create, Query, and Access Data Types
! Numeric types
type(c_ptr) function mxCreateDoubleMatrix(m, n, ComplexFlag) bind(c, name="mxCreateDoubleMatrix"//API_VER2)
type(c_ptr) function mxCreateDoubleMatrix(m, n, ComplexFlag) bind(c, name="mxCreateDoubleMatrix"//API_VER)
use iso_c_binding
import :: mwSize, mxComplexity
integer(mwSize), intent(in), value :: m, n
@ -178,7 +171,7 @@ module matlab_mat
#endif
! Sparse
type(c_ptr) function mxCreateSparse(m, n, nzmax, ComplexFlag) bind(c, name="mxCreateSparse"//API_VER2)
type(c_ptr) function mxCreateSparse(m, n, nzmax, ComplexFlag) bind(c, name="mxCreateSparse"//API_VER)
use iso_c_binding
import :: mwSize, mxComplexity
integer(mwSize), intent(in), value :: m, n, nzmax
@ -190,12 +183,12 @@ module matlab_mat
type(c_ptr), intent(in), value :: pm
end function mxIsSparse
pure type(c_ptr) function mxGetIr(pm) bind(c, name="mxGetIr"//API_VER2)
pure type(c_ptr) function mxGetIr(pm) bind(c, name="mxGetIr"//API_VER)
use iso_c_binding
type(c_ptr), intent(in), value :: pm
end function mxGetIr
pure type(c_ptr) function mxGetJc(pm) bind(c, name="mxGetJc"//API_VER2)
pure type(c_ptr) function mxGetJc(pm) bind(c, name="mxGetJc"//API_VER)
use iso_c_binding
type(c_ptr), intent(in), value :: pm
end function mxGetJc
@ -242,7 +235,7 @@ module matlab_mat
end function mxIsClass_internal
! Structure
type(c_ptr) function mxCreateStructMatrix_internal(m, n, nfields, fieldnames) bind(c, name="mxCreateStructMatrix"//API_VER2)
type(c_ptr) function mxCreateStructMatrix_internal(m, n, nfields, fieldnames) bind(c, name="mxCreateStructMatrix"//API_VER)
use iso_c_binding
import :: mwSize
integer(mwSize), intent(in), value :: m, n
@ -255,7 +248,7 @@ module matlab_mat
type(c_ptr), intent(in), value :: pm
end function mxIsStruct
pure type(c_ptr) function mxGetField_internal(pm, index, fieldname) bind(c, name="mxGetField"//API_VER2)
pure type(c_ptr) function mxGetField_internal(pm, index, fieldname) bind(c, name="mxGetField"//API_VER)
use iso_c_binding
import :: mwIndex
type(c_ptr), intent(in), value :: pm
@ -263,7 +256,7 @@ module matlab_mat
character(c_char), dimension(*), intent(in) :: fieldname
end function mxGetField_internal
subroutine mxSetField_internal(pm, index, fieldname, pvalue) bind(c, name="mxSetField"//API_VER2)
subroutine mxSetField_internal(pm, index, fieldname, pvalue) bind(c, name="mxSetField"//API_VER)
use iso_c_binding
import :: mwIndex
type(c_ptr), intent(in), value :: pm
@ -283,7 +276,7 @@ module matlab_mat
type(c_ptr), intent(in), value :: pm
end function mxIsCell
pure type(c_ptr) function mxGetCell_internal(pm, index) bind(c, name="mxGetCell"//API_VER2)
pure type(c_ptr) function mxGetCell_internal(pm, index) bind(c, name="mxGetCell"//API_VER)
use iso_c_binding
import :: mwIndex
type(c_ptr), intent(in), value :: pm

@ -1 +1 @@
Subproject commit c4c14963a1d66009fcf04fbc63fdffff4384d9fd
Subproject commit 73be95423d3f8c1aa05a5edae2712ffbf646602a

View File

@ -7,7 +7,7 @@
*/
/*
* Copyright © 2019-2021 Dynare Team
* Copyright © 2019-2023 Dynare Team
*
* This file is part of Dynare.
*
@ -66,9 +66,6 @@ verbatim;
g = ones(M_.endo_nbr,1);% 1+(rand(M_.endo_nbr,1)-.5)*.1;
if isoctave
options = optimset('Display','iter','Algorithm','levenberg-marquardt','MaxFunEvals',1000000,'MaxIter',100000,'GradObj','on','TolFun',1e-6,'TolX',1e-6);
elseif matlab_ver_less_than('9.0')
% See https://fr.mathworks.com/help/optim/ug/current-and-legacy-option-name-tables.html
options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunEvals',1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-6,'TolX',1e-6);
else
options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-6,'StepTolerance',1e-6);
end

View File

@ -23,9 +23,6 @@ verbatim;
bgp.write(M_);
if isoctave
options = optimset('Display', 'iter', 'MaxFunEvals', 1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-8,'TolX',1e-8);
elseif matlab_ver_less_than('9.0')
% See https://fr.mathworks.com/help/optim/ug/current-and-legacy-option-name-tables.html
options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunEvals',1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-8,'TolX',1e-8);
else
options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-8,'StepTolerance',1e-8);
end

View File

@ -18,9 +18,6 @@ verbatim;
bgp.write(M_);
if isoctave
options = optimset('Display', 'iter', 'MaxFunEvals', 1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-7,'TolX',1e-7);
elseif matlab_ver_less_than('9.0')
% See https://fr.mathworks.com/help/optim/ug/current-and-legacy-option-name-tables.html
options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunEvals',1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-6,'TolX',1e-6);
else
options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-6,'StepTolerance',1e-6);
end

View File

@ -49,9 +49,6 @@ verbatim;
EG = NaN(MC,1);
if isoctave
options = optimset('Display', 'off', 'MaxFunEvals', 1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-8,'TolX',1e-8);
elseif matlab_ver_less_than('9.0')
% See https://fr.mathworks.com/help/optim/ug/current-and-legacy-option-name-tables.html
options = optimoptions('fsolve','Display','off','Algorithm','levenberg-marquardt','MaxFunEvals',1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-8,'TolX',1e-8);
else
options = optimoptions('fsolve','Display','off','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-8,'StepTolerance',1e-8);
end

View File

@ -2,7 +2,7 @@
% Andreasen, Fernandez-Villaverde, Rubio-Ramirez (2018), The Pruned State-Space System for Non-Linear DSGE Models: Theory and Empirical Applications, Review of Economic Studies, 85, p. 1-49
% Adapted for Dynare by Willi Mutschler (@wmutschl, willi@mutschler.eu), Jan 2021
% =========================================================================
% Copyright © 2021 Dynare Team
% Copyright © 2021-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -257,8 +257,7 @@ dev_datamoments = str2double(AndreasenEtAl.moments@{orderApp}(:,5)) - oo_.mom.d
dev_modelmoments = str2double(AndreasenEtAl.moments@{orderApp}(:,6)) - oo_.mom.model_moments;
% There is no table command in Octave
% The table command also crashes on MATLAB R2014a because it does not like variable names
if ~isoctave && ~matlab_ver_less_than('8.4')
if ~isoctave
table([AndreasenEtAl.Q@{orderApp} ; str2double(AndreasenEtAl.moments@{orderApp}(:,5)) ; str2double(AndreasenEtAl.moments@{orderApp}(:,6))],...
[oo_.mom.Q ; oo_.mom.data_moments ; oo_.mom.model_moments ],...
[dev_Q ; dev_datamoments ; dev_modelmoments ],...

View File

@ -2,7 +2,7 @@
% Andreasen, Fernandez-Villaverde, Rubio-Ramirez (2018), The Pruned State-Space System for Non-Linear DSGE Models: Theory and Empirical Applications, Review of Economic Studies, 85, p. 1-49
% Adapted for Dynare by Willi Mutschler (@wmutschl, willi@mutschler.eu), Jan 2021
% =========================================================================
% Copyright © 2021 Dynare Team
% Copyright © 2021-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -258,8 +258,7 @@ dev_datamoments = str2double(AndreasenEtAl.moments@{orderApp}(:,5)) - oo_.mom.d
dev_modelmoments = str2double(AndreasenEtAl.moments@{orderApp}(:,6)) - oo_.mom.model_moments;
% There is no table command in Octave
% The table command also crashes on MATLAB R2014a because it does not like variable names
if ~isoctave && ~matlab_ver_less_than('8.4')
if ~isoctave
table([AndreasenEtAl.Q@{orderApp} ; str2double(AndreasenEtAl.moments@{orderApp}(:,5)) ; str2double(AndreasenEtAl.moments@{orderApp}(:,6))],...
[oo_.mom.Q ; oo_.mom.data_moments ; oo_.mom.model_moments ],...
[dev_Q ; dev_datamoments ; dev_modelmoments ],...

View File

@ -2,7 +2,7 @@
% Andreasen, Fernandez-Villaverde, Rubio-Ramirez (2018), The Pruned State-Space System for Non-Linear DSGE Models: Theory and Empirical Applications, Review of Economic Studies, 85, p. 1-49
% Adapted for Dynare by Willi Mutschler (@wmutschl, willi@mutschler.eu), Jan 2021
% =========================================================================
% Copyright © 2021 Dynare Team
% Copyright © 2021-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -257,8 +257,7 @@ dev_datamoments = str2double(AndreasenEtAl.moments@{orderApp}(:,5)) - oo_.mom.d
dev_modelmoments = str2double(AndreasenEtAl.moments@{orderApp}(:,6)) - oo_.mom.model_moments;
% There is no table command in Octave
% The table command also crashes on MATLAB R2014a because it does not like variable names
if ~isoctave && ~matlab_ver_less_than('8.4')
if ~isoctave
table([AndreasenEtAl.Q@{orderApp} ; str2double(AndreasenEtAl.moments@{orderApp}(:,5)) ; str2double(AndreasenEtAl.moments@{orderApp}(:,6))],...
[oo_.mom.Q ; oo_.mom.data_moments ; oo_.mom.model_moments ],...
[dev_Q ; dev_datamoments ; dev_modelmoments ],...

View File

@ -177,7 +177,7 @@ end
fclose(fh);
% The table() function is not implemented in Octave
if ~isoctave && ((ispc && ~matlab_ver_less_than('8.2')) || (~ispc && ~matlab_ver_less_than('9.0')))
if ~isoctave
writetable(table(x,y), 'data.xlsx')
options = struct();
options.datafile = 'data.xlsx';
@ -190,7 +190,7 @@ end
% The table() function is not implemented in Octave
% The test also does not work under GNU/Linux + MATLAB R2020b (Unicode issue in xlsread)
if ~isoctave && (ispc && ~matlab_ver_less_than('8.2'))
if ~isoctave && ispc
writetable(table(x,y), 'data.xls')
options = struct();
options.datafile = 'data.xls';

View File

@ -17,11 +17,7 @@ ylabels = char(percent,percent,percent,level);
figtitle = 'Simulated variables';
legendlist = cellstr(char('Piecewise Linear','Linear'));
if isoctave || ~matlab_ver_less_than('8.4')
% For some unknown reason, MATLAB R2014a crashes with TeX labels
% when -nodisplay is passed (as in the testsuite)
options_.TeX=1;
end
options_.TeX=1;
occbin_graph;
occbin_graph c_hat b_hat y_hat;

View File

@ -21,7 +21,7 @@ Note: Dynare comes with an automated uninstaller, which you can run from the
Using Dynare with MATLAB®
─────────────────────────
Dynare works on top of MATLAB®, any version ranging from 8.3 (R2014a) to 23.2
Dynare works on top of MATLAB®, any version ranging from 9.5 (R2018b) to 23.2
(R2023b). Only 64-bit versions are supported.
To use Dynare, you just have to add the matlab subdirectory of your Dynare

View File

@ -31,7 +31,6 @@ ROOT_DIRECTORY=$(dirname "$(readlink -f "$0")")
# Check that build directories do not already exist
[[ -d /tmp/windeps ]] && { echo "Please remove the /tmp/windeps directory" 2>&1; exit 1; }
[[ -d "$ROOT_DIRECTORY"/../build-win-matlab ]] && { echo "Please remove the build-win-matlab directory" 2>&1; exit 1; }
[[ -d "$ROOT_DIRECTORY"/../build-win-old-matlab ]] && { echo "Please remove the build-win-old-matlab directory" 2>&1; exit 1; }
[[ -d "$ROOT_DIRECTORY"/../build-win-octave ]] && { echo "Please remove the build-win-octave directory" 2>&1; exit 1; }
# Create TMP folder and make sure it is deleted upon exit
@ -56,16 +55,11 @@ cd ..
common_meson_opts=(-Dbuildtype=release --cross-file scripts/windows-cross.ini)
# Create Windows 64-bit DLL binaries for MATLAB ≥ R2018a
meson setup --cross-file scripts/windows-cross-matlab.ini -Dmatlab_path=/tmp/windeps/matlab64/R2018a \
# Create Windows 64-bit DLL binaries for MATLAB ≥ R2018b
meson setup --cross-file scripts/windows-cross-matlab.ini -Dmatlab_path=/tmp/windeps/matlab64/R2018b \
"${common_meson_opts[@]}" build-win-matlab
meson compile -v -C build-win-matlab
# Create Windows 64-bit DLL binaries for MATLAB ≥ R2014a and ≤ R2017b
meson setup --cross-file scripts/windows-cross-matlab.ini -Dmatlab_path=/tmp/windeps/matlab64/R2014a \
"${common_meson_opts[@]}" build-win-old-matlab
meson compile -v -C build-win-old-matlab
# Create Windows DLL binaries for Octave/MinGW (64bit)
meson setup --cross-file scripts/windows-cross-octave.ini \
"${common_meson_opts[@]}" build-win-octave
@ -87,7 +81,6 @@ fi
# Strip binaries
x86_64-w64-mingw32-strip build-win-matlab/preprocessor/src/dynare-preprocessor.exe
x86_64-w64-mingw32-strip -- build-win-matlab/*.mexw64
x86_64-w64-mingw32-strip -- build-win-old-matlab/*.mexw64
x86_64-w64-mingw32-strip -- build-win-octave/*.mex
# Add a preprocessor copy for backward compatibility
@ -128,10 +121,8 @@ mkdir -p "$ZIPDIR"/contrib/ms-sbvar/TZcode
cp -pr contrib/ms-sbvar/TZcode/MatlabFiles "$ZIPDIR"/contrib/ms-sbvar/TZcode
mkdir -p "$ZIPDIR"/contrib/jsonlab
cp -pr contrib/jsonlab/* "$ZIPDIR"/contrib/jsonlab
mkdir -p "$ZIPDIR"/mex/matlab/win64-8.3-9.3
cp -p build-win-old-matlab/*.mexw64 "$ZIPDIR"/mex/matlab/win64-8.3-9.3
mkdir -p "$ZIPDIR"/mex/matlab/win64-9.4-23.2
cp -p build-win-matlab/*.mexw64 "$ZIPDIR"/mex/matlab/win64-9.4-23.2
mkdir -p "$ZIPDIR"/mex/matlab/win64-9.5-23.2
cp -p build-win-matlab/*.mexw64 "$ZIPDIR"/mex/matlab/win64-9.5-23.2
mkdir -p "$ZIPDIR"/mex/octave/win64
cp -p build-win-octave/*.mex "$ZIPDIR"/mex/octave/win64
mkdir "$ZIPDIR"/preprocessor

View File

@ -4,7 +4,7 @@ X13AS_VERSION = 1-1-b60
OCTAVE_VERSION = 8.4.0
OCTAVE_W64_BUILD =
MATLAB64_VERSION = 20200930
MATLAB64_VERSION = 20231122
### MSYS2 packages

View File

@ -90,13 +90,8 @@ Section "Dynare core (preprocessor and M-files)"
SectionEnd
Section "MEX files for MATLAB 64-bit, version 8.3 to 9.3 (R2014a to R2017b)"
SetOutPath $INSTDIR\mex\matlab\win64-8.3-9.3
File ..\build-win-old-matlab\*.mexw64
SectionEnd
Section "MEX files for MATLAB 64-bit, version 9.4 to 23.2 (R2018a to R2023b)"
SetOutPath $INSTDIR\mex\matlab\win64-9.4-23.2
Section "MEX files for MATLAB 64-bit, version 9.5 to 23.2 (R2018b to R2023b)"
SetOutPath $INSTDIR\mex\matlab\win64-9.5-23.2
File ..\build-win-matlab\*.mexw64
SectionEnd