From caac1502c35b4627015e1af777ac9ea92f4672b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemia=20=28Scylla=29?= Date: Thu, 25 Oct 2018 10:29:10 +0200 Subject: [PATCH 01/53] Updated preprocessor submodule (fixes issue #1610). --- preprocessor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preprocessor b/preprocessor index bef7c2a19..bfd93f4ac 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit bef7c2a1938f1201cffbddc8d597b2a486fd36c6 +Subproject commit bfd93f4ac0ff1eeece0883faba993052b9d2ea57 From 460dba40d74ac6f8e0f748c313cef4e806ff18c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemia=20=28Scylla=29?= Date: Thu, 25 Oct 2018 10:33:31 +0200 Subject: [PATCH 02/53] Added integration test (estimated_params_init). --- tests/Makefile.am | 1 + .../fs2000_estimated_params_init.mod | 105 ++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 tests/estimation/fs2000_estimated_params_init.mod diff --git a/tests/Makefile.am b/tests/Makefile.am index 046df274f..47695d7aa 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -32,6 +32,7 @@ MODFILES = \ ep/rbc.mod \ estimation/fs2000_with_weibull_prior.mod \ estimation/fs2000_initialize_from_calib.mod \ + estimation/fs2000_estimated_params_init.mod \ estimation/fs2000_calibrated_covariance.mod \ estimation/fs2000_model_comparison.mod \ estimation/fs2000_fast.mod \ diff --git a/tests/estimation/fs2000_estimated_params_init.mod b/tests/estimation/fs2000_estimated_params_init.mod new file mode 100644 index 000000000..1452c92ff --- /dev/null +++ b/tests/estimation/fs2000_estimated_params_init.mod @@ -0,0 +1,105 @@ +// Test that the presence of a non estimated parameter in the estimated_params_init block does not lead to a crash. + +/* + * Copyright (C) 2004-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 . + */ + +var m P c e W R k d n l gy_obs gp_obs y dA; +varexo e_a e_m; + +parameters alp bet gam mst rho psi del; + +alp = 0.33; +bet = 0.99; +gam = 0.003; +mst = 1.011; +rho = 0.7; +psi = 0.787; +del = 0.02; + +model; +dA = exp(gam+e_a); +log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m; +-P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0; +W = l/n; +-(psi/(1-psi))*(c*P/(1-n))+l/n = 0; +R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W; +1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0; +c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1); +P*c = m; +m-1+d = l; +e = exp(e_a); +y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); +gy_obs = dA*y/y(-1); +gp_obs = (P/P(-1))*m(-1)/dA; +end; + +shocks; +var e_a; stderr 0.014; +var e_m; stderr 0.005; +end; + +steady_state_model; + dA = exp(gam); + gst = 1/dA; + m = mst; + khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1)); + xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1); + nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp ); + n = xist/(nust+xist); + P = xist + nust; + k = khst*n; + + l = psi*mst*n/( (1-psi)*(1-n) ); + c = mst/P; + d = l - mst + 1; + y = k^alp*n^(1-alp)*gst^alp; + R = mst/bet; + W = l/n; + ist = y-c; + q = 1 - d; + + e = 1; + + gp_obs = m/dA; + gy_obs = dA; +end; + +steady; + +check; + +estimated_params; +alp, beta_pdf, 0.356, 0.02; +bet, beta_pdf, 0.993, 0.002; +gam, normal_pdf, 0.0085, 0.003; +mst, normal_pdf, 1.0002, 0.007; +rho, beta_pdf, 0.129, 0.100; +psi, beta_pdf, 0.65, 0.05; +% del, beta_pdf, 0.01, 0.005; +% stderr e_a, inv_gamma_pdf, 0.035449, inf; +stderr e_m, inv_gamma_pdf, 0.008862, inf; +end; + +estimated_params_init; +del,0.02; +stderr e_a, 0.01; +corr e_a,e_m, 0.5; +end; + +varobs gp_obs gy_obs; \ No newline at end of file From 8cb51e26e670ad604b9e1a1093d4672b55b5bd4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 25 Oct 2018 15:01:53 +0200 Subject: [PATCH 03/53] options_.instruments is now a cell array This fixes crashes under Octave (while MATLAB seems to accept array-indexing with cell arrays). --- matlab/default_option_values.m | 2 +- matlab/discretionary_policy_1.m | 2 +- matlab/dyn_ramsey_static.m | 4 ++-- matlab/evaluate_steady_state.m | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/matlab/default_option_values.m b/matlab/default_option_values.m index d1a46cb32..0c115e4fe 100644 --- a/matlab/default_option_values.m +++ b/matlab/default_option_values.m @@ -336,7 +336,7 @@ options_.conditional_variance_decomposition = []; % Ramsey policy options_.ramsey_policy = 0; -options_.instruments = []; +options_.instruments = {}; options_.timeless = 0; options_.ramsey.maxit = 500; diff --git a/matlab/discretionary_policy_1.m b/matlab/discretionary_policy_1.m index a88e2bbaa..f154912d4 100644 --- a/matlab/discretionary_policy_1.m +++ b/matlab/discretionary_policy_1.m @@ -115,7 +115,7 @@ end instr_id=nan(instr_nbr,1); for j=1:instr_nbr - vj=deblank(Instruments(j,:)); + vj=deblank(Instruments{j}); vj_id=strmatch(vj, endo_names, 'exact'); if ~isempty(vj_id) instr_id(j)=vj_id; diff --git a/matlab/dyn_ramsey_static.m b/matlab/dyn_ramsey_static.m index c1ef18e05..cf171e847 100644 --- a/matlab/dyn_ramsey_static.m +++ b/matlab/dyn_ramsey_static.m @@ -50,7 +50,7 @@ elseif options_.steadystate_flag k_inst = []; inst_nbr = size(options_.instruments,1); for i = 1:inst_nbr - k_inst = [k_inst; strmatch(options_.instruments(i,:), M.endo_names, 'exact')]; + k_inst = [k_inst; strmatch(options_.instruments{i}, M.endo_names, 'exact')]; end if inst_nbr == 1 %solve for instrument, using univariate solver, starting at initial value for instrument @@ -112,7 +112,7 @@ if options_.steadystate_flag k_inst = []; instruments = options_.instruments; for i = 1:size(instruments,1) - k_inst = [k_inst; strmatch(instruments(i,:), endo_names, 'exact')]; + k_inst = [k_inst; strmatch(instruments{i}, endo_names, 'exact')]; end ys_init=zeros(size(oo.steady_state)); %create starting vector for steady state computation as only instrument value is handed over ys_init(k_inst) = x; %set instrument, the only value required for steady state computation, to current value diff --git a/matlab/evaluate_steady_state.m b/matlab/evaluate_steady_state.m index 6247d88ff..993148fc1 100644 --- a/matlab/evaluate_steady_state.m +++ b/matlab/evaluate_steady_state.m @@ -66,7 +66,7 @@ if options.ramsey_policy fprintf('\nevaluate_steady_state: The steady state file computation for the Ramsey problem resulted in NaNs.\n') fprintf('evaluate_steady_state: The steady state was computed conditional on the following initial instrument values: \n') for ii = 1:size(options.instruments,1) - fprintf('\t %s \t %f \n',options.instruments(ii,:),ys_init(strmatch(options.instruments(ii,:),M.endo_names,'exact'))) + fprintf('\t %s \t %f \n',options.instruments{ii},ys_init(strmatch(options.instruments{ii},M.endo_names,'exact'))) end fprintf('evaluate_steady_state: The problem occured in the following equations: \n') fprintf('\t Equation(s): ') @@ -87,7 +87,7 @@ if options.ramsey_policy fprintf('\nevaluate_steady_state: The steady state file computation for the Ramsey problem resulted in complex numbers.\n') fprintf('evaluate_steady_state: The steady state was computed conditional on the following initial instrument values: \n') for ii = 1:size(options.instruments,1) - fprintf('\t %s \t %f \n',options.instruments(ii,:),ys_init(strmatch(options.instruments(ii,:),M.endo_names,'exact'))) + fprintf('\t %s \t %f \n',options.instruments{ii},ys_init(strmatch(options.instruments{ii},M.endo_names,'exact'))) end fprintf('evaluate_steady_state: If those initial values are not admissable, change them using an initval-block.\n') skipline(2) @@ -102,7 +102,7 @@ if options.ramsey_policy fprintf('\nevaluate_steady_state: The steady state file does not solve the steady state for the Ramsey problem.\n') fprintf('evaluate_steady_state: Conditional on the following instrument values: \n') for ii = 1:size(options.instruments,1) - fprintf('\t %s \t %f \n',options.instruments(ii,:),ys_init(strmatch(options.instruments(ii,:),M.endo_names,'exact'))) + fprintf('\t %s \t %f \n',options.instruments{ii},ys_init(strmatch(options.instruments{ii},M.endo_names,'exact'))) end fprintf('evaluate_steady_state: the following equations have non-zero residuals: \n') for ii=n_multipliers+1:M.endo_nbr @@ -150,7 +150,7 @@ if options.ramsey_policy fprintf('\nevaluate_steady_state: The steady state computation for the Ramsey problem resulted in NaNs.\n') fprintf('evaluate_steady_state: The steady state computation resulted in the following instrument values: \n') for i = 1:size(options.instruments,1) - fprintf('\t %s \t %f \n',options.instruments(i,:),ys(strmatch(options.instruments(i,:),M.endo_names,'exact'))) + fprintf('\t %s \t %f \n',options.instruments{i},ys(strmatch(options.instruments{i},M.endo_names,'exact'))) end fprintf('evaluate_steady_state: The problem occured in the following equations: \n') fprintf('\t Equation(s): ') @@ -168,7 +168,7 @@ if options.ramsey_policy fprintf('\nevaluate_steady_state: The steady state computation for the Ramsey problem resulted in NaNs in the auxiliary equations.\n') fprintf('evaluate_steady_state: The steady state computation resulted in the following instrument values: \n') for i = 1:size(options.instruments,1) - fprintf('\t %s \t %f \n',options.instruments(i,:),ys(strmatch(options.instruments(i,:),M.endo_names,'exact'))) + fprintf('\t %s \t %f \n',options.instruments{i},ys(strmatch(options.instruments{i},M.endo_names,'exact'))) end fprintf('evaluate_steady_state: The problem occured in the following equations: \n') fprintf('\t Auxiliary equation(s): ') @@ -186,7 +186,7 @@ if options.ramsey_policy fprintf('\nevaluate_steady_state: The steady state for the Ramsey problem could not be computed.\n') fprintf('evaluate_steady_state: The steady state computation stopped with the following instrument values:: \n') for i = 1:size(options.instruments,1) - fprintf('\t %s \t %f \n',options.instruments(i,:),ys(strmatch(options.instruments(i,:),M.endo_names,'exact'))) + fprintf('\t %s \t %f \n',options.instruments{i},ys(strmatch(options.instruments{i},M.endo_names,'exact'))) end fprintf('evaluate_steady_state: The following equations have non-zero residuals: \n') for ii=1:n_multipliers From 8cf2c9300ef34d41854e465fce31aa78c896ec91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Fri, 26 Oct 2018 11:13:22 +0200 Subject: [PATCH 04/53] Update preprocessor submodule --- preprocessor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preprocessor b/preprocessor index bfd93f4ac..1c33af484 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit bfd93f4ac0ff1eeece0883faba993052b9d2ea57 +Subproject commit 1c33af4844557f9a5ce95a1ab6f3e293006c0811 From cc4183d3a501fa48f21960c52644a06a4bf48f5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Fri, 26 Oct 2018 15:02:12 +0200 Subject: [PATCH 05/53] Fix for recent MATLABs under Windows --- matlab/add_path_to_mex_files.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/add_path_to_mex_files.m b/matlab/add_path_to_mex_files.m index 2f1fa058d..f40257cbf 100644 --- a/matlab/add_path_to_mex_files.m +++ b/matlab/add_path_to_mex_files.m @@ -60,7 +60,7 @@ else end end else - tmp = [dynareroot '../mex/matlab/win64-9.4/']; + tmp = [dynareroot '../mex/matlab/win64-9.4-9.5/']; if exist(tmp, 'dir') mexpath = tmp; if modifypath From bdc9794d0e98c573670240c4925453ea9d98b686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Mon, 29 Oct 2018 11:28:11 +0100 Subject: [PATCH 06/53] Use extends keyword (introduced in Gitlab 11.3) to simplify .gitlab-ci.yml --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d7045ecca..8a1a91352 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -52,7 +52,7 @@ testsuite_matlab: dependencies: - build_binaries -.testsuite_octave_template: &testsuite_octave_definition +.testsuite_octave_template: stage: test variables: OPENBLAS_NUM_THREADS: 1 @@ -74,13 +74,13 @@ testsuite_matlab: - build_binaries testsuite_octave_auto: - <<: *testsuite_octave_definition + extends: .testsuite_octave_template only: - tags - schedules testsuite_octave_manual: - <<: *testsuite_octave_definition + extends: .testsuite_octave_template except: - tags - schedules From 7d7409bee0cb67f486994b2d587c5b7b883e52f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Mon, 29 Oct 2018 14:40:01 +0100 Subject: [PATCH 07/53] Windows installer: do not forget to uninstall the VERSION file --- windows/dynare.nsi | 1 + 1 file changed, 1 insertion(+) diff --git a/windows/dynare.nsi b/windows/dynare.nsi index 2b7cf7601..1a77815d5 100644 --- a/windows/dynare.nsi +++ b/windows/dynare.nsi @@ -161,6 +161,7 @@ Section "Uninstall" Delete $INSTDIR\license.txt Delete $INSTDIR\mexopts-win32.bat Delete $INSTDIR\mexopts-win64.bat + Delete $INSTDIR\VERSION Rmdir /r $INSTDIR\matlab Rmdir /r $INSTDIR\contrib Rmdir /r $INSTDIR\mex From 096936be9c50a661dd0282b783487c8b34d63ce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Mon, 29 Oct 2018 14:41:34 +0100 Subject: [PATCH 08/53] The preprocessor now compiles the MEX when use_dll is specified Update documentation accordingly (except on macOS where the solution has not yet been implemented). Also include MinGW in the Windows installer. --- Makefile.am | 2 - doc/dynare.texi | 42 +++-------- matlab/dynare.m | 9 +++ matlab/utilities/general/dyn_mex.m | 116 ----------------------------- preprocessor | 2 +- windows/dynare.nsi | 20 ++++- windows/mexopts-win32.bat | 67 ----------------- windows/mexopts-win64.bat | 67 ----------------- 8 files changed, 36 insertions(+), 289 deletions(-) delete mode 100644 matlab/utilities/general/dyn_mex.m delete mode 100644 windows/mexopts-win32.bat delete mode 100644 windows/mexopts-win64.bat diff --git a/Makefile.am b/Makefile.am index 14561aaff..1bb82885a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,8 +27,6 @@ EXTRA_DIST = \ COPYING \ CONTRIBUTING.md \ windows/dynare.nsi \ - windows/mexopts-win32.bat \ - windows/mexopts-win64.bat \ windows/README.txt \ osx \ examples \ diff --git a/doc/dynare.texi b/doc/dynare.texi index 6e1186af0..434fddaaa 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -593,36 +593,29 @@ Octave comes with built-in functionality for compiling mex-files. @node Prerequisites on Windows @subsection Prerequisites on Windows -If you are using MATLAB under Windows, install a C++ compiler on your machine and configure it with -MATLAB. There are at least two free compilers you can use. First, there is Microsoft's Visual Studio -Community (@uref{https://www.visualstudio.com/}), which has the largest history of MATLAB support, but -requires much space on the hard-disk. Second, since MATLAB R2015b, MATLAB supports the MinGW-w64 C/C++ -Compiler from TDM-GCC. To install this compiler, use the Add-Ons menu of MATLAB. Search for MinGW or -select it from Features. - -For older version of MATLAB, in particular before R2014a, it may sometimes make sense to use the gcc compiler -provided by Cygwin. However, integrating it in MATLAB can be quite cumbersome and should be considered as a -legacy option. For details, see -@uref{http://www.dynare.org/DynareWiki/ConfigureMatlabWindowsForMexCompilation,instructions -on the Dynare wiki}. +There is no prerequisite on Windows. Dynare now ships a compilation environment +that can be used with the @code{use_dll} option. @node Prerequisites on Debian GNU/Linux and Ubuntu @subsection Prerequisites on Debian GNU/Linux and Ubuntu -Users of MATLAB under Linux need to have a working compilation environment installed. If not already present, -it can be installed via @code{apt-get install build-essential}. +Users of MATLAB under GNU/Linux need a working compilation environment +installed. If not already present, it can be installed via @code{apt install +build-essential}. -Users of Octave under Linux should install the package for MEX file compilation +Users of Octave under GNU/Linux should install the package for MEX file compilation (under Debian or Ubuntu, it is called @file{liboctave-dev}). @node Prerequisites on macOS @subsection Prerequisites on macOS + +[TO BE UPDATED] + If you are using MATLAB under macOS, you should install the latest version of XCode: see @uref{http://www.dynare.org/DynareWiki/InstallOnMacOSX,instructions on the Dynare wiki}. - @node Configuration @section Configuration @@ -917,23 +910,6 @@ command). Prevent Dynare from printing the output of the steps leading up to the preprocessor as well as the preprocessor output itself. -@item mingw -Tells Dynare that your MATLAB is configured for compiling MEX files with the -MinGW-compiler from TDM-GCC (@pxref{Compiler installation}). This option is -only available under Windows, and is used in conjunction with -@code{use_dll}. - -@item msvc -Tells Dynare that your MATLAB is configured for compiling MEX files with -Microsoft Visual C++ (@pxref{Compiler installation}). This option is -only available under Windows, and is used in conjunction with -@code{use_dll}. - -@item cygwin -Tells Dynare that your MATLAB is configured for compiling MEX files with -Cygwin (@pxref{Compiler installation}). This option is only available -under Windows, and is used in conjunction with @code{use_dll}. - @item parallel[=@var{CLUSTER_NAME}] Tells Dynare to perform computations in parallel. If @var{CLUSTER_NAME} is passed, Dynare will use the specified cluster to perform parallel diff --git a/matlab/dynare.m b/matlab/dynare.m index 369c43b9c..4e347f1a0 100644 --- a/matlab/dynare.m +++ b/matlab/dynare.m @@ -226,6 +226,7 @@ if regexp(firstline, '\s*\/\/', 'once') == 1 end command = ['"' dynareroot 'preprocessor' arch_ext filesep 'dynare_m" ' fname] ; +command = [ command ' mexext=' mexext ' "matlabroot=' matlabroot '"']; for i=1:length(varargin) command = [command ' ' varargin{i}]; end @@ -240,6 +241,14 @@ if preprocessoroutput end end +% Under Windows, make sure the MEX file is unloaded (in the use_dll case), +% otherwise the preprocessor can't recompile it +if isoctave + clear([fname(1:end-4) '.static'], [fname(1:end-4) '.dynamic']) +else + clear(['+' fname(1:end-4) '/static'], ['+' fname(1:end-4) '/dynamic']) +end + [status, result] = system(command); if status ~= 0 || preprocessoroutput disp(result) diff --git a/matlab/utilities/general/dyn_mex.m b/matlab/utilities/general/dyn_mex.m deleted file mode 100644 index 185e061f5..000000000 --- a/matlab/utilities/general/dyn_mex.m +++ /dev/null @@ -1,116 +0,0 @@ -function dyn_mex(win_compiler,basename,force) - -% Compile Dynare model dlls when model option use_dll is used -% if C file is fresher than mex file -% -% INPUTS -% o win_compiler str compiler used under Windows (unused under Linux or OSX): -% 'msvc' (MS Visual C) -% 'cygwin' -% o basename str filenames base -% o force bool recompile if 1 -% -% OUTPUTS -% none -% - - -% Copyright (C) 2015-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 . - -Dc = dir([basename '/mode/src/dynamic.c']); -Dmex = dir(['+' basename '/model/dynamic.' mexext]); - -% compile only if date of C file is greater than date of mex file -% and force is not True -if ~isempty(Dmex) - if (Dmex.datenum > Dc.datenum) && ~force - disp('Mex files are newer than the source: not recompiled') - return - end -end - -if ~isoctave - % Some mex commands are enclosed in an eval(), because otherwise it will make Octave fail - if ispc - if strcmp(win_compiler,'msvc') - % MATLAB/Windows + Microsoft Visual C++ - % Add /TP flag as fix for #1227 - eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Dynamic" COMPFLAGS="/TP" ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) - eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Static" COMPFLAGS="/TP" ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) - elseif strcmp(win_compiler,'mingw') - eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Dynamic" ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) - eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Static" ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) - elseif strcmp(win_compiler,'cygwin') %legacy support for Cygwin with mexopts.bat - % MATLAB/Windows + Cygwin g++ - eval(['mex -O PRELINK_CMDS1="echo EXPORTS > mex.def & echo ' ... - 'mexFunction >> mex.def & echo Dynamic >> mex.def" ' ... - basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) - eval(['mex -O PRELINK_CMDS1="echo EXPORTS > mex.def & echo ' ... - 'mexFunction >> mex.def & echo Dynamic >> mex.def" ' ... - basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) - else - error(['When using the USE_DLL option, you must give either ' ... - '''cygwin'', ''mingw'' or ''msvc'' option to the ''dynare'' command']) - end - elseif isunix && ~ismac - % MATLAB/Linux - if matlab_ver_less_than('8.3') - eval(['mex -O LDFLAGS=''-pthread -shared -Wl,--no-undefined'' ' ... - basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) - eval(['mex -O LDFLAGS=''-pthread -shared -Wl,--no-undefined'' ' ... - basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) - elseif matlab_ver_less_than('9.1') - eval(['mex -O LINKEXPORT='''' ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) - eval(['mex -O LINKEXPORT='''' ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) - else - eval(['mex -O LINKEXPORTVER='''' ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) - eval(['mex -O LINKEXPORTVER='''' ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) - end - elseif ismac - % MATLAB/MacOS - if matlab_ver_less_than('8.1') - eval(['mex -O LDFLAGS=''-Wl,-twolevel_namespace -undefined ' ... - 'error -arch $ARCHS -Wl,-syslibroot,$SDKROOT ' ... - '-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle'' ' ... - basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) - eval(['mex -O LDFLAGS=''-Wl,-twolevel_namespace -undefined ' ... - 'error -arch $ARCHS -Wl,-syslibroot,$SDKROOT ' ... - '-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle'' ' ... - basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) - elseif matlab_ver_less_than('8.3') - eval(['mex -O LDFLAGS=''-Wl,-twolevel_namespace -undefined ' ... - 'error -arch $ARCHS -Wl,-syslibroot,$MW_SDKROOT ' ... - '-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle'' ' ... - basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) - eval(['mex -O LDFLAGS=''-Wl,-twolevel_namespace -undefined ' ... - 'error -arch $ARCHS -Wl,-syslibroot,$MW_SDKROOT ' ... - '-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle'' ' ... - basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) - elseif matlab_ver_less_than('9.1') - eval(['mex -O LINKEXPORT='''' ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) - eval(['mex -O LINKEXPORT='''' ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) - else - eval(['mex -O LINKEXPORT='''' LINKEXPORTVER='''' ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) - eval(['mex -O LINKEXPORT='''' LINKEXPORTVER='''' ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) - end - end -else - % Octave - eval(['mex ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -o +' basename '/dynamic']) - eval(['mex ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -o +' basename '/static']) -end diff --git a/preprocessor b/preprocessor index 1c33af484..4a974bb42 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 1c33af4844557f9a5ce95a1ab6f3e293006c0811 +Subproject commit 4a974bb428d3960aface3e1760b33e169c7c733a diff --git a/windows/dynare.nsi b/windows/dynare.nsi index 1a77815d5..1ccf77929 100644 --- a/windows/dynare.nsi +++ b/windows/dynare.nsi @@ -54,7 +54,7 @@ Section "Dynare core (preprocessor and M-files)" SectionIn RO !insertmacro DETERMINE_CONTEXT SetOutPath $INSTDIR - File README.txt ..\NEWS mexopts-win32.bat mexopts-win64.bat ..\license.txt ..\VERSION + File README.txt ..\NEWS ..\license.txt ..\VERSION SetOutPath $INSTDIR\matlab File /r ..\matlab\*.m @@ -124,6 +124,20 @@ SectionEnd SectionGroupEnd +SectionGroup "MinGW compiler (needed for use_dll option under MATLAB)" + +Section "MinGW for 32-bit MATLAB" + SetOutPath $INSTDIR\mingw32 + File /r mingw32\* +SectionEnd + +Section "MinGW for 64-bit MATLAB" + SetOutPath $INSTDIR\mingw64 + File /r mingw64\* +SectionEnd + +SectionGroupEnd + Section "Dynare++ (standalone executable)" SetOutPath $INSTDIR\dynare++ File ..\dynare++\src\dynare++.exe ..\dynare++\extern\matlab\dynare_simul.m ..\dynare++\*.dll @@ -159,8 +173,6 @@ Section "Uninstall" Delete $INSTDIR\README.txt Delete $INSTDIR\NEWS Delete $INSTDIR\license.txt - Delete $INSTDIR\mexopts-win32.bat - Delete $INSTDIR\mexopts-win64.bat Delete $INSTDIR\VERSION Rmdir /r $INSTDIR\matlab Rmdir /r $INSTDIR\contrib @@ -169,6 +181,8 @@ Section "Uninstall" Rmdir /r $INSTDIR\doc Rmdir /r $INSTDIR\examples Rmdir /r $INSTDIR\scripts + Rmdir /r $INSTDIR\mingw32 + Rmdir /r $INSTDIR\mingw64 # We don't force deletion of installation directory (with /r), to avoid deleting important files Rmdir $INSTDIR diff --git a/windows/mexopts-win32.bat b/windows/mexopts-win32.bat deleted file mode 100644 index bb154ecf8..000000000 --- a/windows/mexopts-win32.bat +++ /dev/null @@ -1,67 +0,0 @@ -@echo off - -rem Compile and link options used for building MEX-files using Cygwin, -rem for the 32-bit version of MATLAB. -rem -rem It makes the assumption that you installed Cygwin in C:\CYGWIN, -rem and that you installed either the "mingw64-i686-gcc" package. -rem -rem This file should be renamed to "mexopts.bat" and copied to: -rem C:\Documents and Settings\\Application Data\MathWorks\MATLAB\\ -rem -rem This file only supports C code. It can easily be changed to compile C++ -rem code by replacing "gcc" by "g++" in COMPILER and LINKER, and by adding -rem "-static-libstdc++" to LINKFLAGS. -rem You will also need the "mingw64-i686-gcc-g++" package. -rem -rem Initial version by Michel Juillard, revised by Sebastien Villemot. - -rem Copyright (C) 2009-2013 Dynare Team -rem -rem This file is part of Dynare. -rem -rem Dynare is free software: you can redistribute it and/or modify -rem it under the terms of the GNU General Public License as published by -rem the Free Software Foundation, either version 3 of the License, or -rem (at your option) any later version. -rem -rem Dynare is distributed in the hope that it will be useful, -rem but WITHOUT ANY WARRANTY; without even the implied warranty of -rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -rem GNU General Public License for more details. -rem -rem You should have received a copy of the GNU General Public License -rem along with Dynare. If not, see . - -rem ******************************************************************** -rem General parameters -rem ******************************************************************** - -set MATLAB=%MATLAB% -set PATH=%PATH%;c:\cygwin\bin -set MW_TARGET_ARCH=win32 - -rem ******************************************************************** -rem Compiler parameters -rem ******************************************************************** -set COMPILER=i686-w64-mingw32-gcc -set COMPFLAGS=-c -fexceptions -set OPTIMFLAGS=-O3 -set DEBUGFLAGS=-g -Wall -set NAME_OBJECT=-o - -rem ******************************************************************** -rem Linker parameters -rem ******************************************************************** -set PRELINK_CMDS1=echo EXPORTS > mex.def & echo mexFunction >> mex.def -set LIBLOC=%MATLAB%\bin\win32\ -set LINKER=i686-w64-mingw32-gcc -set LINKFLAGS= -static-libgcc -shared mex.def "-L%LIBLOC%" -set LINKFLAGSPOST= -lmex -lmx -lmwlapack -lmwblas -set LINKOPTIMFLAGS=-O3 -set LINKDEBUGFLAGS= -g -Wall -set LINK_FILE= -set LINK_LIB= -set NAME_OUTPUT=-o "%OUTDIR%%MEX_NAME%%MEX_EXT%" -set RSP_FILE_INDICATOR=@ -set POSTLINK_CMDS1=del mex.def diff --git a/windows/mexopts-win64.bat b/windows/mexopts-win64.bat deleted file mode 100644 index 806bbd839..000000000 --- a/windows/mexopts-win64.bat +++ /dev/null @@ -1,67 +0,0 @@ -@echo off - -rem Compile and link options used for building MEX-files using Cygwin, -rem for the 64-bit version of MATLAB. -rem -rem It makes the assumption that you installed Cygwin in C:\CYGWIN, -rem and that you installed either the "mingw64-x86_64-gcc" package. -rem -rem This file should be renamed to "mexopts.bat" and copied to: -rem C:\Documents and Settings\\Application Data\MathWorks\MATLAB\\ -rem -rem This file only supports C code. It can easily be changed to compile C++ -rem code by replacing "gcc" by "g++" in COMPILER and LINKER, and by adding -rem "-static-libstdc++" to LINKFLAGS. -rem You will also need the "mingw64-x86_64-gcc-g++" package. -rem -rem Initial version by Michel Juillard, revised by Sebastien Villemot. - -rem Copyright (C) 2009-2013 Dynare Team -rem -rem This file is part of Dynare. -rem -rem Dynare is free software: you can redistribute it and/or modify -rem it under the terms of the GNU General Public License as published by -rem the Free Software Foundation, either version 3 of the License, or -rem (at your option) any later version. -rem -rem Dynare is distributed in the hope that it will be useful, -rem but WITHOUT ANY WARRANTY; without even the implied warranty of -rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -rem GNU General Public License for more details. -rem -rem You should have received a copy of the GNU General Public License -rem along with Dynare. If not, see . - -rem ******************************************************************** -rem General parameters -rem ******************************************************************** - -set MATLAB=%MATLAB% -set PATH=%PATH%;c:\cygwin\bin -set MW_TARGET_ARCH=win64 - -rem ******************************************************************** -rem Compiler parameters -rem ******************************************************************** -set COMPILER=x86_64-w64-mingw32-gcc -set COMPFLAGS=-c -fexceptions -set OPTIMFLAGS=-O3 -set DEBUGFLAGS=-g -Wall -set NAME_OBJECT=-o - -rem ******************************************************************** -rem Linker parameters -rem ******************************************************************** -set PRELINK_CMDS1=echo EXPORTS > mex.def & echo mexFunction >> mex.def -set LIBLOC=%MATLAB%\bin\win64\ -set LINKER=x86_64-w64-mingw32-gcc -set LINKFLAGS= -static-libgcc -shared mex.def "-L%LIBLOC%" -set LINKFLAGSPOST= -lmex -lmx -lmwlapack -lmwblas -set LINKOPTIMFLAGS=-O3 -set LINKDEBUGFLAGS= -g -Wall -set LINK_FILE= -set LINK_LIB= -set NAME_OUTPUT=-o "%OUTDIR%%MEX_NAME%%MEX_EXT%" -set RSP_FILE_INDICATOR=@ -set POSTLINK_CMDS1=del mex.def From 625d824bbee972a157eb9ebce6b77b85e0e2106b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 31 Oct 2018 15:57:34 +0100 Subject: [PATCH 09/53] MEX extension detection now robust to spaces in MATLAB path --- m4/ax_mexext.m4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/m4/ax_mexext.m4 b/m4/ax_mexext.m4 index 17a5c58ed..6e43b9ceb 100644 --- a/m4/ax_mexext.m4 +++ b/m4/ax_mexext.m4 @@ -41,13 +41,13 @@ else AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.1], [AC_MSG_ERROR([I can't determine the MEX file extension. Please explicitly indicate it to the configure script with the MEXEXT variable.])]) case $build_os in *cygwin*) - ax_cv_mexext=`$MATLAB/bin/mexext.bat | sed 's/\r//'` + ax_cv_mexext=$("$MATLAB"/bin/mexext.bat | sed 's/\r//') ;; *mingw*) - ax_cv_mexext=`cd $MATLAB/bin && cmd /c mexext.bat | sed 's/\r//'` + ax_cv_mexext=$(cd "$MATLAB"/bin && cmd /c mexext.bat | sed 's/\r//') ;; *) - ax_cv_mexext=`$MATLAB/bin/mexext` + ax_cv_mexext=$("$MATLAB"/bin/mexext) ;; esac fi]) From 4ab79c55f05772861e482639255be77080434507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 31 Oct 2018 16:19:47 +0100 Subject: [PATCH 10/53] More fixes related to spaces in paths --- m4/ax_mexopts.m4 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/m4/ax_mexopts.m4 b/m4/ax_mexopts.m4 index 0d9a93a8f..5d60bd06f 100644 --- a/m4/ax_mexopts.m4 +++ b/m4/ax_mexopts.m4 @@ -26,7 +26,7 @@ AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.5], [AC_MSG_ERROR([Your MATLAB is AC_MSG_CHECKING([for options to compile MEX for MATLAB]) -MATLAB_CPPFLAGS="-I$MATLAB/extern/include" +MATLAB_CPPFLAGS="-I\"$MATLAB\"/extern/include" case ${MATLAB_ARCH} in glnx86 | glnxa64) @@ -34,8 +34,8 @@ case ${MATLAB_ARCH} in MATLAB_CFLAGS="-fexceptions -fPIC -pthread -g -O2" MATLAB_CXXFLAGS="-fPIC -pthread -g -O2" MATLAB_FFLAGS="-fPIC -g -O2 -fexceptions" - MATLAB_LDFLAGS_NOMAP="-shared -Wl,--no-undefined -Wl,-rpath-link,$MATLAB/bin/${MATLAB_ARCH} -L$MATLAB/bin/${MATLAB_ARCH}" - MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,--version-script,$MATLAB/extern/lib/${MATLAB_ARCH}/mexFunction.map" + MATLAB_LDFLAGS_NOMAP="-shared -Wl,--no-undefined -Wl,-rpath-link,\"$MATLAB\"/bin/${MATLAB_ARCH} -L\"$MATLAB\"/bin/${MATLAB_ARCH}" + MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,--version-script,\"$MATLAB\"/extern/lib/${MATLAB_ARCH}/mexFunction.map" MATLAB_LIBS="-lmx -lmex -lmat -lm -lstdc++ -lmwlapack -lmwblas" if test "${MATLAB_ARCH}" = "glnx86"; then MATLAB_DEFS="$MATLAB_DEFS -D_FILE_OFFSET_BITS=64" @@ -53,8 +53,8 @@ case ${MATLAB_ARCH} in MATLAB_FFLAGS="-fexceptions -g -O2 -fno-underscoring" MATLAB_DEFS="$MATLAB_DEFS -DNDEBUG" # Note that static-libstdc++ is only supported since GCC 4.5 (but generates no error on older versions) - MATLAB_LDFLAGS_NOMAP="-static-libgcc -static-libstdc++ -shared -L$MATLAB/bin/${MATLAB_ARCH}" - MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP $(pwd)/$srcdir/mex.def" + MATLAB_LDFLAGS_NOMAP="-static-libgcc -static-libstdc++ -shared -L\"$MATLAB\"/bin/${MATLAB_ARCH}" + MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP \"$(pwd)\"/$srcdir/mex.def" MATLAB_LIBS="-lmex -lmx -lmat -lmwlapack -lmwblas" ax_mexopts_ok="yes" ;; @@ -69,8 +69,8 @@ case ${MATLAB_ARCH} in MATLAB_CFLAGS="-fno-common -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -fexceptions" MATLAB_CXXFLAGS="-fno-common -fexceptions -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET" MATLAB_FFLAGS="-fexceptions -fbackslash -arch $ARCHS" - MATLAB_LDFLAGS_NOMAP="-L$MATLAB/bin/${MATLAB_ARCH} -Wl,-twolevel_namespace -undefined error -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle" - MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,-exported_symbols_list,$(pwd)/$srcdir/mexFunction-MacOSX.map" + MATLAB_LDFLAGS_NOMAP="-L\"$MATLAB\"/bin/${MATLAB_ARCH} -Wl,-twolevel_namespace -undefined error -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle" + MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,-exported_symbols_list,\"$(pwd)\"/$srcdir/mexFunction-MacOSX.map" MATLAB_LIBS="-lmx -lmex -lmat -lstdc++ -lmwlapack -lmwblas" ax_mexopts_ok="yes" ;; @@ -86,9 +86,9 @@ fi # Converts the MATLAB version number into comparable integers with only major and minor version numbers # For example, 7.4.2 will become 0704 -ax_matlab_ver=`echo "$MATLAB_VERSION" | $SED -e 's/\([[0-9]]*\)\.\([[0-9]]*\).*/Z\1ZZ\2Z/' \ - -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ - -e 's/[[^0-9]]//g'` +ax_matlab_ver=$(echo "$MATLAB_VERSION" | $SED -e 's/\([[0-9]]*\)\.\([[0-9]]*\).*/Z\1ZZ\2Z/' \ + -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ + -e 's/[[^0-9]]//g') MATLAB_DEFS="$MATLAB_DEFS -DMATLAB_VERSION=0x${ax_matlab_ver}" From 40362789deed9388147ef60e9243d1952ac5cbdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 31 Oct 2018 18:00:31 +0100 Subject: [PATCH 11/53] Revert "More fixes related to spaces in paths" This commit was breaking the detection of slicot. My understanding is that autoconf is not able to deal with spaces in paths, hence Windows users have not choice but to use the 8.3 notation for MATLAB location. This reverts commit 4ab79c55f05772861e482639255be77080434507. --- m4/ax_mexopts.m4 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/m4/ax_mexopts.m4 b/m4/ax_mexopts.m4 index 5d60bd06f..0d9a93a8f 100644 --- a/m4/ax_mexopts.m4 +++ b/m4/ax_mexopts.m4 @@ -26,7 +26,7 @@ AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.5], [AC_MSG_ERROR([Your MATLAB is AC_MSG_CHECKING([for options to compile MEX for MATLAB]) -MATLAB_CPPFLAGS="-I\"$MATLAB\"/extern/include" +MATLAB_CPPFLAGS="-I$MATLAB/extern/include" case ${MATLAB_ARCH} in glnx86 | glnxa64) @@ -34,8 +34,8 @@ case ${MATLAB_ARCH} in MATLAB_CFLAGS="-fexceptions -fPIC -pthread -g -O2" MATLAB_CXXFLAGS="-fPIC -pthread -g -O2" MATLAB_FFLAGS="-fPIC -g -O2 -fexceptions" - MATLAB_LDFLAGS_NOMAP="-shared -Wl,--no-undefined -Wl,-rpath-link,\"$MATLAB\"/bin/${MATLAB_ARCH} -L\"$MATLAB\"/bin/${MATLAB_ARCH}" - MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,--version-script,\"$MATLAB\"/extern/lib/${MATLAB_ARCH}/mexFunction.map" + MATLAB_LDFLAGS_NOMAP="-shared -Wl,--no-undefined -Wl,-rpath-link,$MATLAB/bin/${MATLAB_ARCH} -L$MATLAB/bin/${MATLAB_ARCH}" + MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,--version-script,$MATLAB/extern/lib/${MATLAB_ARCH}/mexFunction.map" MATLAB_LIBS="-lmx -lmex -lmat -lm -lstdc++ -lmwlapack -lmwblas" if test "${MATLAB_ARCH}" = "glnx86"; then MATLAB_DEFS="$MATLAB_DEFS -D_FILE_OFFSET_BITS=64" @@ -53,8 +53,8 @@ case ${MATLAB_ARCH} in MATLAB_FFLAGS="-fexceptions -g -O2 -fno-underscoring" MATLAB_DEFS="$MATLAB_DEFS -DNDEBUG" # Note that static-libstdc++ is only supported since GCC 4.5 (but generates no error on older versions) - MATLAB_LDFLAGS_NOMAP="-static-libgcc -static-libstdc++ -shared -L\"$MATLAB\"/bin/${MATLAB_ARCH}" - MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP \"$(pwd)\"/$srcdir/mex.def" + MATLAB_LDFLAGS_NOMAP="-static-libgcc -static-libstdc++ -shared -L$MATLAB/bin/${MATLAB_ARCH}" + MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP $(pwd)/$srcdir/mex.def" MATLAB_LIBS="-lmex -lmx -lmat -lmwlapack -lmwblas" ax_mexopts_ok="yes" ;; @@ -69,8 +69,8 @@ case ${MATLAB_ARCH} in MATLAB_CFLAGS="-fno-common -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -fexceptions" MATLAB_CXXFLAGS="-fno-common -fexceptions -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET" MATLAB_FFLAGS="-fexceptions -fbackslash -arch $ARCHS" - MATLAB_LDFLAGS_NOMAP="-L\"$MATLAB\"/bin/${MATLAB_ARCH} -Wl,-twolevel_namespace -undefined error -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle" - MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,-exported_symbols_list,\"$(pwd)\"/$srcdir/mexFunction-MacOSX.map" + MATLAB_LDFLAGS_NOMAP="-L$MATLAB/bin/${MATLAB_ARCH} -Wl,-twolevel_namespace -undefined error -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle" + MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,-exported_symbols_list,$(pwd)/$srcdir/mexFunction-MacOSX.map" MATLAB_LIBS="-lmx -lmex -lmat -lstdc++ -lmwlapack -lmwblas" ax_mexopts_ok="yes" ;; @@ -86,9 +86,9 @@ fi # Converts the MATLAB version number into comparable integers with only major and minor version numbers # For example, 7.4.2 will become 0704 -ax_matlab_ver=$(echo "$MATLAB_VERSION" | $SED -e 's/\([[0-9]]*\)\.\([[0-9]]*\).*/Z\1ZZ\2Z/' \ - -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ - -e 's/[[^0-9]]//g') +ax_matlab_ver=`echo "$MATLAB_VERSION" | $SED -e 's/\([[0-9]]*\)\.\([[0-9]]*\).*/Z\1ZZ\2Z/' \ + -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ + -e 's/[[^0-9]]//g'` MATLAB_DEFS="$MATLAB_DEFS -DMATLAB_VERSION=0x${ax_matlab_ver}" From 6684cbd9a6e8ceb7ef8397cad5e4dc688e201301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Mon, 5 Nov 2018 11:30:05 +0100 Subject: [PATCH 12/53] Update preprocessor submodule --- preprocessor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preprocessor b/preprocessor index 4a974bb42..366701c09 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 4a974bb428d3960aface3e1760b33e169c7c733a +Subproject commit 366701c094c13b172f75740aaf1b97fcf754ddec From 47596aa3e0d82641a8f15250d981fcbf050f13d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Mon, 5 Nov 2018 12:32:02 +0100 Subject: [PATCH 13/53] Update preprocessor submodule --- preprocessor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preprocessor b/preprocessor index 366701c09..f223af91a 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 366701c094c13b172f75740aaf1b97fcf754ddec +Subproject commit f223af91afaaec5fdaa9224c2386d25d5428eee3 From 671fe4bcd425b785a4723d6b73955405afe5d84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 6 Nov 2018 12:17:56 +0100 Subject: [PATCH 14/53] Build system improvements on Windows (MinGW / MSYS2) - Use the -static flag when linking Dynare++, so that shipping libquadmath and libgcc DLL in the installer is no longer needed. - Use AM_CXXFLAGS and AM_LDFLAGS variables for changing flags, since CXXFLAGS and LDFLAGS are user variables. Also, this avoids passing these flags down to configure scripts in subdirectories. - Check for the SZIP library in the configure test for the MatIO, this is needed under MSYS2. - Statically link MatIO and GSL in MEX files for MATLAB, this is needed under MSYS2. --- configure.ac | 20 +++++--------------- dynare++/integ/cc/Makefile.am | 2 +- dynare++/integ/src/Makefile.am | 2 +- dynare++/integ/testing/Makefile.am | 4 ++-- dynare++/kord/Makefile.am | 6 +++--- dynare++/src/Makefile.am | 4 ++-- dynare++/tl/cc/Makefile.am | 2 +- dynare++/tl/testing/Makefile.am | 4 ++-- m4/ax_matio.m4 | 2 ++ mex/build/matlab/configure.ac | 12 ++++++++++-- preprocessor | 2 +- windows/dynare.nsi | 2 +- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/configure.ac b/configure.ac index c919d5c7d..87375750c 100644 --- a/configure.ac +++ b/configure.ac @@ -30,9 +30,9 @@ AC_PROG_CXX AC_CANONICAL_HOST case ${host_os} in *mingw32*) - # On mingw32, we don't want dynamic libgcc - # Note that static-libstdc++ is only supported since GCC 4.5 (but generates no error on older versions) - LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++ -static-libgfortran" + # On Windows, we want Dynare++ to be statically linked + AM_LDFLAGS="-static" + AC_SUBST([AM_LDFLAGS]) have_windows="yes" ;; *cygwin*) @@ -51,7 +51,8 @@ esac # Use C++ for testing headers AC_LANG([C++]) -CXXFLAGS="$CXXFLAGS -Wall -Wno-parentheses" +AM_CXXFLAGS="-Wall -Wno-parentheses" +AC_SUBST([AM_CXXFLAGS]) # If default 'ar' is not available, try to find one with a host prefix (see ticket #145) AC_CHECK_PROGS([AR], [ar ${host_alias}-ar]) @@ -125,11 +126,6 @@ AM_CONDITIONAL([HAVE_CWEAVE], [test "x$CWEAVE" != "x"]) AC_PROG_F77 AC_F77_LIBRARY_LDFLAGS case ${host_os} in - *mingw32*) - # Hack to get static linking of libgfortran on MinGW - # (-static-libgfortran doesn't act on gcc/g++) - FLIBS=`echo $FLIBS | sed 's/-lgfortran/-Wl,-Bstatic -lgfortran -Wl,-Bdynamic/'` - ;; *darwin*) # * OS X doesn't need to link against the Fortran libraries because # everything is contained within the vecLib framework. @@ -144,12 +140,6 @@ fi AM_CONDITIONAL([HAVE_BLAS], [test x"$ax_blas_ok" = "xyes"]) AM_CONDITIONAL([HAVE_LAPACK], [test x"$ax_lapack_ok" = "xyes"]) -case ${host_os} in - *mingw32*) - # Ensure that -lpthread is statically linked under MinGW - PTHREAD_LIBS="-Wl,-Bstatic -lpthread -Wl,-Bdynamic" - ;; -esac AX_PTHREAD AC_CONFIG_FILES([Makefile diff --git a/dynare++/integ/cc/Makefile.am b/dynare++/integ/cc/Makefile.am index 408e858aa..ef0102ef7 100644 --- a/dynare++/integ/cc/Makefile.am +++ b/dynare++/integ/cc/Makefile.am @@ -26,7 +26,7 @@ noinst_LIBRARIES = libinteg.a libinteg_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES) precalc_quadrature.dat libinteg_a_CPPFLAGS = -I../../sylv/cc -I../../tl/cc -I$(top_srcdir)/mex/sources -libinteg_a_CXXFLAGS = $(PTHREAD_CFLAGS) +libinteg_a_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS) BUILT_SOURCES = $(GENERATED_FILES) diff --git a/dynare++/integ/src/Makefile.am b/dynare++/integ/src/Makefile.am index 39b9dee39..d964d2eff 100644 --- a/dynare++/integ/src/Makefile.am +++ b/dynare++/integ/src/Makefile.am @@ -2,5 +2,5 @@ noinst_PROGRAMS = quadrature-points quadrature_points_SOURCES = quadrature-points.cpp quadrature_points_CPPFLAGS = -I../.. -I../../sylv/cc -I../../integ/cc -I../../tl/cc -quadrature_points_CXXFLAGS = $(PTHREAD_CFLAGS) +quadrature_points_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS) quadrature_points_LDADD = ../cc/libinteg.a ../../tl/cc/libtl.a ../../parser/cc/libparser.a ../../sylv/cc/libsylv.a ../../utils/cc/libutils.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) diff --git a/dynare++/integ/testing/Makefile.am b/dynare++/integ/testing/Makefile.am index 0814d69a6..c30ef377a 100644 --- a/dynare++/integ/testing/Makefile.am +++ b/dynare++/integ/testing/Makefile.am @@ -2,8 +2,8 @@ check_PROGRAMS = tests tests_SOURCES = tests.cpp tests_CPPFLAGS = -I../cc -I../../tl/cc -I../../sylv/cc -I$(top_srcdir)/mex/sources -tests_CXXFLAGS = $(PTHREAD_CFLAGS) -tests_LDFLAGS = $(LDFLAGS_MATIO) +tests_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS) +tests_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MATIO) tests_LDADD = ../../tl/cc/libtl.a ../../sylv/cc/libsylv.a ../cc/libinteg.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO) check-local: diff --git a/dynare++/kord/Makefile.am b/dynare++/kord/Makefile.am index 05119d7a4..4ac8d15c6 100644 --- a/dynare++/kord/Makefile.am +++ b/dynare++/kord/Makefile.am @@ -54,7 +54,7 @@ noinst_LIBRARIES = libkord.a libkord_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES) libkord_a_CPPFLAGS = -I../sylv/cc -I../tl/cc -I../integ/cc -I$(top_srcdir)/mex/sources $(CPPFLAGS_MATIO) -libkord_a_CXXFLAGS = $(PTHREAD_CFLAGS) +libkord_a_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS) BUILT_SOURCES = $(GENERATED_FILES) @@ -64,8 +64,8 @@ check_PROGRAMS = tests tests_SOURCES = tests.cpp tests_CPPFLAGS = -I../sylv/cc -I../tl/cc -I../integ/cc -I$(top_srcdir)/mex/sources -tests_CXXFLAGS = $(PTHREAD_CFLAGS) -tests_LDFLAGS = $(LDFLAGS_MATIO) +tests_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS) +tests_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MATIO) tests_LDADD = libkord.a ../tl/cc/libtl.a ../sylv/cc/libsylv.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO) check-local: diff --git a/dynare++/src/Makefile.am b/dynare++/src/Makefile.am index a95ecee71..126264c34 100644 --- a/dynare++/src/Makefile.am +++ b/dynare++/src/Makefile.am @@ -22,9 +22,9 @@ dynare___SOURCES = \ $(GENERATED_FILES) dynare___CPPFLAGS = -I../sylv/cc -I../tl/cc -I../kord -I../integ/cc -I.. -I$(top_srcdir)/mex/sources -DDYNVERSION=\"$(PACKAGE_VERSION)\" $(BOOST_CPPFLAGS) $(CPPFLAGS_MATIO) -dynare___LDFLAGS = $(LDFLAGS_MATIO) $(BOOST_LDFLAGS) +dynare___LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MATIO) $(BOOST_LDFLAGS) dynare___LDADD = ../kord/libkord.a ../integ/cc/libinteg.a ../tl/cc/libtl.a ../parser/cc/libparser.a ../utils/cc/libutils.a ../sylv/cc/libsylv.a $(LIBADD_MATIO) $(noinst_LIBRARIES) $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) -dynare___CXXFLAGS = $(PTHREAD_CFLAGS) +dynare___CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS) BUILT_SOURCES = $(GENERATED_FILES) EXTRA_DIST = dynglob.lex dynglob.y diff --git a/dynare++/tl/cc/Makefile.am b/dynare++/tl/cc/Makefile.am index dde28e45d..1ad9f87f2 100644 --- a/dynare++/tl/cc/Makefile.am +++ b/dynare++/tl/cc/Makefile.am @@ -92,7 +92,7 @@ noinst_LIBRARIES = libtl.a libtl_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES) libtl_a_CPPFLAGS = -I../../sylv/cc $(CPPFLAGS_MATIO) -libtl_a_CXXFLAGS = $(PTHREAD_CFLAGS) +libtl_a_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS) BUILT_SOURCES = $(GENERATED_FILES) diff --git a/dynare++/tl/testing/Makefile.am b/dynare++/tl/testing/Makefile.am index 70b2ff333..9c8b78753 100644 --- a/dynare++/tl/testing/Makefile.am +++ b/dynare++/tl/testing/Makefile.am @@ -2,8 +2,8 @@ check_PROGRAMS = tests tests_SOURCES = factory.cpp factory.h monoms.cpp monoms.h tests.cpp tests_CPPFLAGS = -I../cc -I../../sylv/cc -tests_CXXFLAGS = $(PTHREAD_CFLAGS) -tests_LDFLAGS = $(LDFLAGS_MATIO) +tests_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS) +tests_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MATIO) tests_LDADD = ../cc/libtl.a ../../sylv/cc/libsylv.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO) check-local: diff --git a/m4/ax_matio.m4 b/m4/ax_matio.m4 index 9a2235a80..fa940ecc1 100644 --- a/m4/ax_matio.m4 +++ b/m4/ax_matio.m4 @@ -44,6 +44,8 @@ AC_ARG_WITH(matio, AC_HELP_STRING([--with-matio=DIR], [prefix to MATIO installat dnl If detected, libz and libhdf5 are added to LIBS, used for matio test LIBS="" AC_CHECK_LIB([z], [compress]) + dnl szip is needed under MSYS2 + AC_CHECK_LIB([szip], [SZ_Compress]) AC_CHECK_LIB([hdf5], [H5Fcreate]) AC_CHECK_HEADER([matio.h], [], [has_matio=no]) diff --git a/mex/build/matlab/configure.ac b/mex/build/matlab/configure.ac index ef87b0fdb..2a3c9b5fd 100644 --- a/mex/build/matlab/configure.ac +++ b/mex/build/matlab/configure.ac @@ -66,8 +66,6 @@ AM_PROG_AR case ${host_os} in *mingw32*) - # Ensure that -lpthread is statically linked under MinGW - PTHREAD_LIBS="-Wl,-Bstatic -lpthread -Wl,-Bdynamic" # Kludge for bug in MinGW, that defines __STDC_UTF_16__ but not char16_t # This breaks the matrix.h of older MATLABs (e.g. R2009a) # Also see @@ -94,6 +92,16 @@ AM_CONDITIONAL([HAVE_MATIO], [test "x$has_matio" = "xyes"]) AX_SLICOT([matlab]) AM_CONDITIONAL([HAVE_SLICOT], [test "x$has_slicot" = "xyes"]) +# On Windows, we want static linking of the external libraries +case ${host_os} in + *mingw32*) + PTHREAD_LIBS="-Wl,-Bstatic $PTHREAD_LIBS -Wl,-Bdynamic" + GSL_LIBS="-Wl,-Bstatic $GSL_LIBS -Wl,-Bdynamic" + LIBADD_MATIO="-Wl,-Bstatic $LIBADD_MATIO -Wl,-Bdynamic" + LIBADD_SLICOT="-Wl,-Bstatic $LIBADD_SLICOT -Wl,-Bdynamic" + ;; +esac + AM_CONDITIONAL([DO_SOMETHING], [test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes"]) if test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes"; then diff --git a/preprocessor b/preprocessor index f223af91a..beb99d98c 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit f223af91afaaec5fdaa9224c2386d25d5428eee3 +Subproject commit beb99d98cdda587cc8341e0891e3be6ef6c98d4f diff --git a/windows/dynare.nsi b/windows/dynare.nsi index 1ccf77929..7ad7126b7 100644 --- a/windows/dynare.nsi +++ b/windows/dynare.nsi @@ -140,7 +140,7 @@ SectionGroupEnd Section "Dynare++ (standalone executable)" SetOutPath $INSTDIR\dynare++ - File ..\dynare++\src\dynare++.exe ..\dynare++\extern\matlab\dynare_simul.m ..\dynare++\*.dll + File ..\dynare++\src\dynare++.exe ..\dynare++\extern\matlab\dynare_simul.m SectionEnd Section "Documentation and examples (Dynare and Dynare++)" From e37549461b49aa792605afc418ccb8a994ecfb49 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Tue, 6 Nov 2018 16:41:35 +0100 Subject: [PATCH 15/53] doc: update mexext, matlabroot options --- doc/dynare.texi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/dynare.texi b/doc/dynare.texi index 434fddaaa..b8d7f308f 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -910,6 +910,15 @@ command). Prevent Dynare from printing the output of the steps leading up to the preprocessor as well as the preprocessor output itself. +@item mexext=mex|mexw32|mexw64|mexmaci64|mexa64 +The mex extension associated with your platform to be used when compiling +output associated with @code{use_dll}. NB: Dynare is able to set this +automatically, so you should not need to set it yourself. + +@item matlabroot=@var{<>} +The path to the Matlab installation for use with @code{use_dll}. NB: Dynare is +able to set this automatically, so you should not need to set it yourself. + @item parallel[=@var{CLUSTER_NAME}] Tells Dynare to perform computations in parallel. If @var{CLUSTER_NAME} is passed, Dynare will use the specified cluster to perform parallel From 9a7ded24e8b60fc58e8f2cfd140110318af6e045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 6 Nov 2018 16:48:20 +0100 Subject: [PATCH 16/53] Compilation instructions under Windows using MSYS2 --- README.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c647ea06..9aa0b425f 100644 --- a/README.md +++ b/README.md @@ -266,7 +266,62 @@ sudo apt install build-essential gfortran liboctave-dev libboost-graph-dev libbo ## Windows -We no longer support compilation on Windows. To use the unstable version of Dynare on a Windows system, please download it from the [Dynare website](http://www.dynare.org/download/dynare-unstable). +- Install [MSYS2](http://www.msys2.org) (pick the 64-bit version) +- Run a MSYS MinGW 64-bit shell +- Install all needed dependencies: +``` +pacman -S git autoconf automake-wrapper bison flex make tar texinfo mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-boost mingw-w64-x86_64-gsl mingw-w64-x86_64-matio mingw-w64-x86_64-openblas +``` +- *Optional:* compile install `ctangle`, needed for the k-order MEX file and for + Dynare++ (*i.e.* if you want to solve models at order ≥ 3) +``` +wget ftp://ftp.cs.stanford.edu/pub/cweb/cweb.tar.gz +mkdir cweb +cd cweb +tar xf ../cweb.tar.gz +make ctangle +mkdir -p /usr/local/bin +cp ctangle.exe /usr/local/bin/ +cd .. +``` +- *Optional:* compile and install SLICOT, needed for the `kalman_steady_state` + MEX file +``` +wget https://deb.debian.org/debian/pool/main/s/slicot/slicot_5.0+20101122.orig.tar.gz +tar xf slicot_5.0+20101122.orig.tar.gz +cd slicot-5.0+20101122 +make FORTRAN=gfortran OPTS="-O2 -fno-underscoring -fdefault-integer-8" LOADER=gfortran +mkdir -p /usr/local/lib +cp slicot.a /usr/local/lib/libslicot64_pic.a +cd .. +``` +- Clone and prepare the Dynare sources: +``` +git clone --recursive https://git.dynare.org/Dynare/dynare.git +cd dynare +autoreconf -si +``` +- Configure Dynare: +``` +./configure --with-boost-system=boost_system-mt --with-boost-filesystem=boost_filesystem-mt --with-slicot=/usr/local --with-matlab=<…> MATLAB_VERSION=<…> --disable-octave +``` +where the path and version of MATLAB are specified. Note that you should not +put spaces in the MATLAB path, so you probably want to use something like `C:\Progra~1\MATLAB\…`. +- Compile: +``` +make +``` + +*Note:* The above assumes that you have a 64-bit version of MATLAB. It can be +adapted to a 32-bit MATLAB with the following modifications: + +- run the MSYS MinGW 32-bit shell +- replace "x86_64" by "i686" in packages names on the `pacman` command-line +- for SLICOT, remove the `-fdefault-integer-8` option, and instead copy the + library into `/usr/local/lib/libslicot_pic.a` + +*Note:* Compiling the MEX files for Octave and the documentation under MSYS2 is +currently not supported. ## Windows Subsystem for Linux From abe8bee683ea38f5f5971b9d0cc3aea163f5039b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 6 Nov 2018 16:50:38 +0100 Subject: [PATCH 17/53] Bump required version for Bison --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9aa0b425f..89d853a57 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ A number of tools and libraries are needed in order to recompile everything. You - MATLAB (if you want to compile MEX for MATLAB) - [GNU Octave](http://www.octave.org), with the development headers (if you want to compile MEX for Octave) - [Boost libraries](http://www.boost.org), version 1.36 or later (with the filesystem library compiled) -- [Bison](http://www.gnu.org/software/bison/), version 2.5 or later (only if you get the source through Git) +- [Bison](http://www.gnu.org/software/bison/), version 3.0 or later (only if you get the source through Git) - [Flex](http://flex.sourceforge.net/), version 2.5.4 or later (only if you get the source through Git) - [Autoconf](http://www.gnu.org/software/autoconf/), version 2.62 or later (only if you get the source through Git) (see [Installing an updated version of Autoconf in your own directory, in GNU/Linux](http://www.dynare.org/DynareWiki/AutoMake)) - [Automake](http://www.gnu.org/software/automake/), version 1.11.2 or later (only if you get the source through Git) (see [Installing an updated version of AutoMake in your own directory, in GNU/Linux](http://www.dynare.org/DynareWiki/AutoMake)) From b9da355b1a618f2bf8a5824d444b3027ce98af7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 6 Nov 2018 17:05:05 +0100 Subject: [PATCH 18/53] Update build instructions for Debian/Ubuntu --- README.md | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 89d853a57..f80f02281 100644 --- a/README.md +++ b/README.md @@ -202,26 +202,13 @@ in the `tests` folder to delete files that were created by the run of the testsu ## Debian or Ubuntu -All the prerequisites are packaged. - -The easiest way to install the pre-requisites in Debian is to use Debian's dynare package and do -(requires that you have added the `deb-src` repositories to your `sources.list`): -``` -apt-get build-dep dynare -``` -followed by (only for building the master branch): -``` -apt-get install texlive-fonts-extra -``` -which is missing in Debian's list of pre-requisites. - -Alternatively, if you want to build everything, manually install the following packages: +All the prerequisites are packaged: - `build-essential` (for gcc, g++ and make) - `gfortran` -- `liboctave-dev` (or `octave3.2-headers` on older systems) +- `liboctave-dev` - `libboost-graph-dev` and `libboost-filesystem-dev` -- `libgsl-dev` (or `libgsl0-dev` on older systems) +- `libgsl-dev` - `libmatio-dev` - `libslicot-dev` and `libslicot-pic` - `libsuitesparse-dev` @@ -235,17 +222,16 @@ Alternatively, if you want to build everything, manually install the following p - `texlive-formats-extra` (for Eplain) - `texlive-latex-extra` (for fullpage.sty) - `texlive-fonts-extra` (for ccicons) -- `texlive-latex-recommended` (or `latex-beamer` on older systems) -- `texlive-science` (or `texlive-math-extra` on older systems) (for amstex) +- `texlive-latex-recommended` +- `texlive-science` (for amstex) - `texinfo` - `lmodern` (for macroprocessor PDF) - `latex2html` - `doxygen` -You can load all necessary packages at once with +You can install them all at once with: ``` -sudo apt install build-essential gfortran liboctave-dev libboost-graph-dev libboost-filesystem-dev libgsl-dev libmatio-dev libslicot-dev libslicot-pic libsuitesparse-dev flex bison autoconf automake texlive texlive-publishers texlive-extra-utils texlive-formats-extra texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texinfo lmodern latex2html doxygen - +apt install build-essential gfortran liboctave-dev libboost-graph-dev libboost-filesystem-dev libgsl-dev libmatio-dev libslicot-dev libslicot-pic libsuitesparse-dev flex bison autoconf automake texlive texlive-publishers texlive-extra-utils texlive-formats-extra texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texinfo lmodern latex2html doxygen ``` ## Fedora From b6f11063caed4ee416826ee24130253e17f835fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 6 Nov 2018 17:22:03 +0100 Subject: [PATCH 19/53] Remove unfinished instructions for Fedora --- README.md | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/README.md b/README.md index f80f02281..06bea9396 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,6 @@ at the MATLAB prompt: if it returns `PCWIN`, then you have a 32-bit MATLAB; if i 1. [**General Instructions**](#general-instructions) 1. [**Debian or Ubuntu**](#debian-or-ubuntu) -1. [**Fedora**](#fedora) 1. [**Windows**](#windows) 1. [**Windows Subsystem for Linux**](#windows-subsystem-for-linux) 1. [**macOS**](#macos) @@ -234,22 +233,6 @@ You can install them all at once with: apt install build-essential gfortran liboctave-dev libboost-graph-dev libboost-filesystem-dev libgsl-dev libmatio-dev libslicot-dev libslicot-pic libsuitesparse-dev flex bison autoconf automake texlive texlive-publishers texlive-extra-utils texlive-formats-extra texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texinfo lmodern latex2html doxygen ``` -## Fedora - -**NB**: Documentation still in progress… -- `octave-devel` -- `boost-devel` -- `gsl-devel` -- `matio-devel` -- `flex` -- `bison` -- `autoconf` -- `automake` -- `texlive` -- `texinfo` -- `latex2html` -- `doxygen` - ## Windows - Install [MSYS2](http://www.msys2.org) (pick the 64-bit version) From f630bc31be2b196a9cda2eaa1c3debbfaa33eb6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 6 Nov 2018 17:59:23 +0100 Subject: [PATCH 20/53] Add information about package upgrade under MSYS2 --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 06bea9396..c50b9f821 100644 --- a/README.md +++ b/README.md @@ -237,11 +237,18 @@ apt install build-essential gfortran liboctave-dev libboost-graph-dev libboost-f - Install [MSYS2](http://www.msys2.org) (pick the 64-bit version) - Run a MSYS MinGW 64-bit shell +- Update the system: +``` +pacman -Syu +``` + You may be asked to close the window at the end of the + first upgrade batch, in which case you should rerun the upgrade in a new + window to complete the upgrade. - Install all needed dependencies: ``` pacman -S git autoconf automake-wrapper bison flex make tar texinfo mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-boost mingw-w64-x86_64-gsl mingw-w64-x86_64-matio mingw-w64-x86_64-openblas ``` -- *Optional:* compile install `ctangle`, needed for the k-order MEX file and for +- *Optional:* compile and install `ctangle`, needed for the k-order MEX file and for Dynare++ (*i.e.* if you want to solve models at order ≥ 3) ``` wget ftp://ftp.cs.stanford.edu/pub/cweb/cweb.tar.gz From afc9f94854266c631bd5398c10a2cbc430fc94a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 7 Nov 2018 14:38:04 +0100 Subject: [PATCH 21/53] On Windows, statically link the pthread library Otherwise the DLL is dynamically linked against libwinpthread. This regression was introduced by commit 671fe4bcd. --- mex/build/matlab/configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mex/build/matlab/configure.ac b/mex/build/matlab/configure.ac index 2a3c9b5fd..55dd62003 100644 --- a/mex/build/matlab/configure.ac +++ b/mex/build/matlab/configure.ac @@ -95,7 +95,9 @@ AM_CONDITIONAL([HAVE_SLICOT], [test "x$has_slicot" = "xyes"]) # On Windows, we want static linking of the external libraries case ${host_os} in *mingw32*) - PTHREAD_LIBS="-Wl,-Bstatic $PTHREAD_LIBS -Wl,-Bdynamic" + # We hardcode -lpthread here, otherwise it is not detected by the + # AX_PTHREAD macro and therefore not statically linked + PTHREAD_LIBS="-Wl,-Bstatic -lpthread -Wl,-Bdynamic" GSL_LIBS="-Wl,-Bstatic $GSL_LIBS -Wl,-Bdynamic" LIBADD_MATIO="-Wl,-Bstatic $LIBADD_MATIO -Wl,-Bdynamic" LIBADD_SLICOT="-Wl,-Bstatic $LIBADD_SLICOT -Wl,-Bdynamic" From 2dcaff4f162dbadb1ca9dadb7fc0e61557af74e5 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Wed, 7 Nov 2018 15:57:15 +0100 Subject: [PATCH 22/53] preprocessor: submodule update --- doc/dynare.texi | 7 +++++++ preprocessor | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index b8d7f308f..356e4d280 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -835,6 +835,13 @@ line numbering directives. Passing this option removes all empty from the macro expanded mod file created when the @code{savemacro} option is used. +@item onlymodel +Instructs the preprocessor to print only information about the model in the +driver file; no Dynare commands (other than the shocks statement and parameter +initializations) are printed and hence no computational tasks performed. NB: +the same ancillary files are created as would otherwise be created (dynamic, +static files, etc.). + @item nolog Instructs Dynare to no create a logfile of this run in @file{@var{FILENAME}.log}. The default is to create the logfile. diff --git a/preprocessor b/preprocessor index beb99d98c..5f5fd569d 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit beb99d98cdda587cc8341e0891e3be6ef6c98d4f +Subproject commit 5f5fd569dd3127df457e8f17cb6c010c7fc52e30 From b4dd46e8ea62ea789ca86c4ed807e85796b8a46c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 8 Nov 2018 12:50:36 +0100 Subject: [PATCH 23/53] Misc fixes to README --- README.md | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index c50b9f821..efc6adaaf 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,6 @@ # Dynare -[![Join the chat at https://gitter.im/DynareTeam](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/DynareTeam?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - Described on the homepage: Most users should use the precompiled package available for your OS, also @@ -40,11 +38,13 @@ Note that if you obtain the source code via git, you will need to install more t The first section of this page gives general instructions, which apply to all platforms. Then some specific platforms are discussed. -**NB**: Here, when we refer to 32-bit or 64-bit, we refer to the type of MATLAB installation, not the type of Windows installation. It is perfectly possible to run a 32-bit MATLAB on a 64-bit Windows: in that case, instructions for Windows 32-bit should be followed. To determine the type of your MATLAB installation, type: +**Note:** Here, when we refer to 32-bit or 64-bit, we refer to the type of MATLAB installation, not the type of Windows installation. It is perfectly possible to run a 32-bit MATLAB on a 64-bit Windows: in that case, instructions for Windows 32-bit should be followed. To determine the type of your MATLAB installation, type: ```matlab >> computer ``` -at the MATLAB prompt: if it returns `PCWIN`, then you have a 32-bit MATLAB; if it returns `PCWIN64`, then you have a 64-bit MATLAB. +at the MATLAB prompt: if it returns `PCWIN64`, `GLNX64` or `MACI64`, then you +have a 64-bit MATLAB; if it returns `PCWIN`, `MACI` or `GLNX`, then you have a +32-bit MATLAB. **Contents** @@ -62,14 +62,16 @@ A number of tools and libraries are needed in order to recompile everything. You - A POSIX compliant shell and an implementation of Make (mandatory) - The [GNU Compiler Collection](http://gcc.gnu.org/), with gcc, g++ and gfortran (mandatory) -- MATLAB (if you want to compile MEX for MATLAB) -- [GNU Octave](http://www.octave.org), with the development headers (if you want to compile MEX for Octave) +- MATLAB (if you want to compile the MEX for MATLAB) +- [GNU Octave](http://www.octave.org), with the development headers (if you + want to compile the MEX for Octave) - [Boost libraries](http://www.boost.org), version 1.36 or later (with the filesystem library compiled) - [Bison](http://www.gnu.org/software/bison/), version 3.0 or later (only if you get the source through Git) - [Flex](http://flex.sourceforge.net/), version 2.5.4 or later (only if you get the source through Git) - [Autoconf](http://www.gnu.org/software/autoconf/), version 2.62 or later (only if you get the source through Git) (see [Installing an updated version of Autoconf in your own directory, in GNU/Linux](http://www.dynare.org/DynareWiki/AutoMake)) - [Automake](http://www.gnu.org/software/automake/), version 1.11.2 or later (only if you get the source through Git) (see [Installing an updated version of AutoMake in your own directory, in GNU/Linux](http://www.dynare.org/DynareWiki/AutoMake)) -- [CWEB](http://www-cs-faculty.stanford.edu/%7Eknuth/cweb.html), with its tools `ctangle` and `cweave` (only if you want to build Dynare++ and get the source through Git) +- [CWEB](http://www-cs-faculty.stanford.edu/%7Eknuth/cweb.html), with its tools + `ctangle` and `cweave` (only if you want to build the k-order DLL or Dynare++, and get the source through Git) - An implementation of BLAS and LAPACK: either [ATLAS](http://math-atlas.sourceforge.net/), [OpenBLAS](http://xianyi.github.com/OpenBLAS/), Netlib ([BLAS](http://www.netlib.org/blas/), [LAPACK](http://www.netlib.org/lapack/)) or [MKL](http://software.intel.com/en-us/intel-mkl/) (only if you want to build Dynare++) - An implementation of [POSIX Threads](http://en.wikipedia.org/wiki/POSIX_Threads) (optional, for taking advantage of multi-core) - [MAT File I/O library](http://sourceforge.net/projects/matio/) (if you want to compile Markov-Switching code, the estimation DLL, k-order DLL and Dynare++) @@ -108,8 +110,6 @@ If you have MATLAB, you need to indicate both the MATLAB location and version. F ``` Note that the MATLAB version can also be specified via the MATLAB family product release (R2009a, R2008b, ...). -**NB**: For MATLAB versions strictly older than 7.1, you need to explicitly give the MEX extension, via `MEXEXT` variable of the configure script (for example, `MEXEXT=dll` for Windows with MATLAB \< 7.1). - Alternatively, you can disable the compilation of MEX files for MATLAB with the `--disable-matlab` flag, and MEX files for Octave with `--disable-octave`. You may need to specify additional options to the configure script, see the platform specific instructions below. @@ -118,14 +118,14 @@ Note that if you don't want to compile the C/C++ programs with debugging informa ``` ./configure CFLAGS="-O3" CXXFLAGS="-O3" ``` -To remove debugging information for Matlab mex functions, the analagous call would be: +To remove debugging information for MATLAB MEX functions, the analagous call would be: ``` ./configure MATLAB_MEX_CFLAGS="-O3" MATLAB_MEX_CXXFLAGS="-O3" ``` If you want to give a try to the parallelized versions of some mex files (`A_times_B_kronecker_C` and `sparse_hessian_times_B_kronecker_C` used to get the reduced form of the second order approximation of the model) you can add the `--enable-openmp` flag, for instance: ``` -./configure --with-matlab=/usr/local/matlab78 MATLAB_VERSION=7.8 --enable-openmp +./configure --with-matlab=/usr/local/MATLAB/R2013a MATLAB_VERSION=8.1 --enable-openmp ``` If the configuration goes well, the script will tell you which components are correctly configured and will be built. @@ -150,12 +150,12 @@ Note that running the testsuite with Octave requires the additional packages ### Check -The Git source comes with unit tests (in the matlab functions) and integration tests (under the `tests` subfolder). All the tests can be run with: +The Git source comes with unit tests (in the MATLAB functions) and integration tests (under the `tests` subfolder). All the tests can be run with: ``` make check ``` -In the `tests` subfolder. If Dynare has been compiled against Matlab and Octave, the tests will be run with Matlab and Octave. Depending on -your PC, this can take several hours. It is possible to run the tests only with Matlab: +In the `tests` subfolder. If Dynare has been compiled against MATLAB and Octave, the tests will be run with MATLAB and Octave. Depending on +your PC, this can take several hours. It is possible to run the tests only with MATLAB: ``` make check-matlab ``` @@ -169,7 +169,7 @@ subset of the integration tests, with: ``` make deterministic_simulations ``` -This will run all the integration tests in `tests/deterministic_simulations` with Matlab and Octave. Again, it is possible to do this only with Matlab: +This will run all the integration tests in `tests/deterministic_simulations` with MATLAB and Octave. Again, it is possible to do this only with MATLAB: ``` make m/deterministic_simulations ``` @@ -177,7 +177,7 @@ or with Octave: ``` make o/deterministic_simulations ``` -Finally if you want to run a single integration test, e.g. `deterministic_simulations/lbj/rbc.mod` with Matlab: +Finally if you want to run a single integration test, e.g. `deterministic_simulations/lbj/rbc.mod` with MATLAB: ``` make deterministic_simulations/lbj/rbc.m.trs ``` @@ -248,7 +248,7 @@ pacman -Syu ``` pacman -S git autoconf automake-wrapper bison flex make tar texinfo mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-boost mingw-w64-x86_64-gsl mingw-w64-x86_64-matio mingw-w64-x86_64-openblas ``` -- *Optional:* compile and install `ctangle`, needed for the k-order MEX file and for +- **(Optional)** compile and install `ctangle`, needed for the k-order MEX file and for Dynare++ (*i.e.* if you want to solve models at order ≥ 3) ``` wget ftp://ftp.cs.stanford.edu/pub/cweb/cweb.tar.gz @@ -260,13 +260,13 @@ mkdir -p /usr/local/bin cp ctangle.exe /usr/local/bin/ cd .. ``` -- *Optional:* compile and install SLICOT, needed for the `kalman_steady_state` +- **(Optional)** compile and install SLICOT, needed for the `kalman_steady_state` MEX file ``` wget https://deb.debian.org/debian/pool/main/s/slicot/slicot_5.0+20101122.orig.tar.gz tar xf slicot_5.0+20101122.orig.tar.gz cd slicot-5.0+20101122 -make FORTRAN=gfortran OPTS="-O2 -fno-underscoring -fdefault-integer-8" LOADER=gfortran +make FORTRAN=gfortran OPTS="-O2 -fno-underscoring -fdefault-integer-8" LOADER=gfortran LAPACKLIB=-lopenblas mkdir -p /usr/local/lib cp slicot.a /usr/local/lib/libslicot64_pic.a cd .. @@ -288,15 +288,15 @@ put spaces in the MATLAB path, so you probably want to use something like `C:\Pr make ``` -*Note:* The above assumes that you have a 64-bit version of MATLAB. It can be +**Note:** The above assumes that you have a 64-bit version of MATLAB. It can be adapted to a 32-bit MATLAB with the following modifications: - run the MSYS MinGW 32-bit shell -- replace "x86_64" by "i686" in packages names on the `pacman` command-line +- replace `x86_64` by `i686` in packages names on the `pacman` command-line - for SLICOT, remove the `-fdefault-integer-8` option, and instead copy the library into `/usr/local/lib/libslicot_pic.a` -*Note:* Compiling the MEX files for Octave and the documentation under MSYS2 is +**Note:** Compiling the MEX files for Octave and the documentation under MSYS2 is currently not supported. ## Windows Subsystem for Linux @@ -324,7 +324,7 @@ After this, prepare the source and configure the build tree as described for Lin ## macOS -To simply use a snapshot of Dynare, you have two choices. On Matlab, you can +To simply use a snapshot of Dynare, you have two choices. On MATLAB, you can use the [snapshot build](http://www.dynare.org/snapshot/macosx/) provided by Dynare. On Octave, you can simply install [Homebrew](https://brew.sh/) and run ```brew install dynare --HEAD``` (See the Install Dynare (unstable) section of @@ -361,7 +361,7 @@ folder where you want Dynare installed. - `cd dynare` - `PATH="/usr/local/opt/bison/bin:/usr/local/opt/flex/bin:$PATH"` - `autoreconf -si` -- `./configure --disable-octave --with-matlab=/Applications/MATLAB_R2017b.app MATLAB_VERSION=R2017b`, adjusting the Matlab path and version to accord with your local installation. If you don't have Matlab, simply type `./configure --disable-octave` +- `./configure --disable-octave --with-matlab=/Applications/MATLAB_R2017b.app MATLAB_VERSION=R2017b`, adjusting the MATLAB path and version to accord with your local installation. If you don't have MATLAB, simply type `./configure --disable-octave` - `make -j` - **(Optional)** To then build mex files for Octave, run - `cd mex/build/octave` From 9dfbb787b36794ae6fc3526565d2f9638bf4a69d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 8 Nov 2018 12:56:17 +0100 Subject: [PATCH 24/53] Further fix on slicot building under Windows --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index efc6adaaf..c21f27157 100644 --- a/README.md +++ b/README.md @@ -266,7 +266,7 @@ cd .. wget https://deb.debian.org/debian/pool/main/s/slicot/slicot_5.0+20101122.orig.tar.gz tar xf slicot_5.0+20101122.orig.tar.gz cd slicot-5.0+20101122 -make FORTRAN=gfortran OPTS="-O2 -fno-underscoring -fdefault-integer-8" LOADER=gfortran LAPACKLIB=-lopenblas +make FORTRAN=gfortran OPTS="-O2 -fno-underscoring -fdefault-integer-8" LOADER=gfortran slicot.a mkdir -p /usr/local/lib cp slicot.a /usr/local/lib/libslicot64_pic.a cd .. From 7fd5f4bd6d7af3389df636b5353ab91838d6831f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 8 Nov 2018 13:00:43 +0100 Subject: [PATCH 25/53] Fix for MATLAB location in README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c21f27157..907fb0aa7 100644 --- a/README.md +++ b/README.md @@ -281,8 +281,9 @@ autoreconf -si ``` ./configure --with-boost-system=boost_system-mt --with-boost-filesystem=boost_filesystem-mt --with-slicot=/usr/local --with-matlab=<…> MATLAB_VERSION=<…> --disable-octave ``` -where the path and version of MATLAB are specified. Note that you should not -put spaces in the MATLAB path, so you probably want to use something like `C:\Progra~1\MATLAB\…`. +where the path and version of MATLAB are specified. Note that you should use +the MSYS2 notation and not put spaces in the MATLAB path, so you probably want +to use something like `/c/Progra~1/MATLAB/…`. - Compile: ``` make From 50a09a687eaa20817c3e7f6cb973e3ad53d6b936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 8 Nov 2018 16:25:50 +0100 Subject: [PATCH 26/53] C++11 modernization Incidentally, fix a memory leak related to DynamicModelAC instantiation, using a std::unique_ptr (see Dynare/dynare#1490). --- .../dynamic_abstract_class.hh | 3 +- .../k_order_perturbation/dynamic_dll.cc | 37 +++++++------- .../k_order_perturbation/dynamic_dll.hh | 17 ++++--- mex/sources/k_order_perturbation/dynamic_m.cc | 14 ++---- mex/sources/k_order_perturbation/dynamic_m.hh | 7 ++- .../k_order_perturbation/k_ord_dynare.cc | 48 +++++++++---------- .../k_order_perturbation/k_ord_dynare.hh | 22 ++++----- .../k_order_perturbation.cc | 14 +++--- 8 files changed, 80 insertions(+), 82 deletions(-) diff --git a/mex/sources/k_order_perturbation/dynamic_abstract_class.hh b/mex/sources/k_order_perturbation/dynamic_abstract_class.hh index 8c84dbe01..0c5f63af6 100644 --- a/mex/sources/k_order_perturbation/dynamic_abstract_class.hh +++ b/mex/sources/k_order_perturbation/dynamic_abstract_class.hh @@ -25,9 +25,10 @@ class DynamicModelAC { public: + virtual ~DynamicModelAC() = default; static double *unpackSparseMatrix(mxArray *sparseMatrix); static void copyDoubleIntoTwoDMatData(double *dm, TwoDMatrix *tdm, int rows, int cols); virtual void eval(const Vector &y, const Vector &x, const Vector ¶ms, const Vector &ySteady, - Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) throw (DynareException) = 0; + Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) noexcept(false) = 0; }; #endif diff --git a/mex/sources/k_order_perturbation/dynamic_dll.cc b/mex/sources/k_order_perturbation/dynamic_dll.cc index a352d5e03..762702e1b 100644 --- a/mex/sources/k_order_perturbation/dynamic_dll.cc +++ b/mex/sources/k_order_perturbation/dynamic_dll.cc @@ -21,7 +21,7 @@ #include -DynamicModelDLL::DynamicModelDLL(const string &modName) throw (DynareException) +DynamicModelDLL::DynamicModelDLL(const string &modName) noexcept(false) { string fName; #if !defined(__CYGWIN32__) && !defined(_WIN32) @@ -33,7 +33,7 @@ DynamicModelDLL::DynamicModelDLL(const string &modName) throw (DynareException) { #if defined(__CYGWIN32__) || defined(_WIN32) dynamicHinstance = LoadLibrary(fName.c_str()); - if (dynamicHinstance == NULL) + if (dynamicHinstance == nullptr) throw 1; ntt = (int *) GetProcAddress(dynamicHinstance, "ntt"); dynamic_resid_tt = (dynamic_tt_fct) GetProcAddress(dynamicHinstance, "dynamic_resid_tt"); @@ -44,18 +44,18 @@ DynamicModelDLL::DynamicModelDLL(const string &modName) throw (DynareException) dynamic_g2 = (dynamic_g2_fct) GetProcAddress(dynamicHinstance, "dynamic_g2"); dynamic_g3_tt = (dynamic_tt_fct) GetProcAddress(dynamicHinstance, "dynamic_g3_tt"); dynamic_g3 = (dynamic_g3_fct) GetProcAddress(dynamicHinstance, "dynamic_g3"); - if (ntt == NULL - || dynamic_resid_tt == NULL || dynamic_resid == NULL - || dynamic_g1_tt == NULL || dynamic_g1 == NULL - || dynamic_g2_tt == NULL || dynamic_g2 == NULL - || dynamic_g3_tt == NULL || dynamic_g3 == NULL) + if (ntt == nullptr + || dynamic_resid_tt == nullptr || dynamic_resid == nullptr + || dynamic_g1_tt == nullptr || dynamic_g1 == nullptr + || dynamic_g2_tt == nullptr || dynamic_g2 == nullptr + || dynamic_g3_tt == nullptr || dynamic_g3 == nullptr) { FreeLibrary(dynamicHinstance); // Free the library throw 2; } #else // Linux or Mac dynamicHinstance = dlopen(fName.c_str(), RTLD_NOW); - if (dynamicHinstance == NULL) + if (dynamicHinstance == nullptr) { cerr << dlerror() << endl; throw 1; @@ -69,11 +69,11 @@ DynamicModelDLL::DynamicModelDLL(const string &modName) throw (DynareException) dynamic_g2 = (dynamic_g2_fct) dlsym(dynamicHinstance, "dynamic_g2"); dynamic_g3_tt = (dynamic_tt_fct) dlsym(dynamicHinstance, "dynamic_g3_tt"); dynamic_g3 = (dynamic_g3_fct) dlsym(dynamicHinstance, "dynamic_g3"); - if (ntt == NULL - || dynamic_resid_tt == NULL || dynamic_resid == NULL - || dynamic_g1_tt == NULL || dynamic_g1 == NULL - || dynamic_g2_tt == NULL || dynamic_g2 == NULL - || dynamic_g3_tt == NULL || dynamic_g3 == NULL) + if (ntt == nullptr + || dynamic_resid_tt == nullptr || dynamic_resid == nullptr + || dynamic_g1_tt == nullptr || dynamic_g1 == nullptr + || dynamic_g2_tt == nullptr || dynamic_g2 == nullptr + || dynamic_g3_tt == nullptr || dynamic_g3 == nullptr) { dlclose(dynamicHinstance); // Free the library cerr << dlerror() << endl; @@ -95,16 +95,19 @@ DynamicModelDLL::DynamicModelDLL(const string &modName) throw (DynareException) } catch (...) { - throw DynareException(__FILE__, __LINE__, string("Can't find the relevant dynamic symbols in ") + fName); + throw DynareException(__FILE__, __LINE__, "Can't find the relevant dynamic symbols in " + fName); } } DynamicModelDLL::~DynamicModelDLL() { #if defined(__CYGWIN32__) || defined(_WIN32) - bool result = FreeLibrary(dynamicHinstance); + auto result = FreeLibrary(dynamicHinstance); if (result == 0) - throw DynareException(__FILE__, __LINE__, string("Can't free the *_dynamic DLL")); + { + cerr << "Can't free the *_dynamic DLL" << endl; + exit(EXIT_FAILURE); + } #else dlclose(dynamicHinstance); #endif @@ -112,7 +115,7 @@ DynamicModelDLL::~DynamicModelDLL() void DynamicModelDLL::eval(const Vector &y, const Vector &x, const Vector &modParams, const Vector &ySteady, - Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) throw (DynareException) + Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) noexcept(false) { double *T = (double *) malloc(sizeof(double) * (*ntt)); dynamic_resid_tt(y.base(), x.base(), 1, modParams.base(), ySteady.base(), 0, T); diff --git a/mex/sources/k_order_perturbation/dynamic_dll.hh b/mex/sources/k_order_perturbation/dynamic_dll.hh index de2696508..aef34c887 100644 --- a/mex/sources/k_order_perturbation/dynamic_dll.hh +++ b/mex/sources/k_order_perturbation/dynamic_dll.hh @@ -34,11 +34,11 @@ #include "dynamic_abstract_class.hh" #include "dynare_exception.h" -typedef void (*dynamic_tt_fct)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, double *T); -typedef void (*dynamic_resid_fct) (const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *residual); -typedef void (*dynamic_g1_fct)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *g1); -typedef void (*dynamic_g2_fct)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *v2); -typedef void (*dynamic_g3_fct)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *v3); +using dynamic_tt_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, double *T); +using dynamic_resid_fct = void (*) (const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *residual); +using dynamic_g1_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *g1); +using dynamic_g2_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *v2); +using dynamic_g3_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *v3); /** * creates pointer to Dynamic function inside _dynamic.dll @@ -61,11 +61,10 @@ private: public: // construct and load Dynamic model DLL - DynamicModelDLL(const string &fname) throw (DynareException); - virtual - ~DynamicModelDLL(); + explicit DynamicModelDLL(const string &fname) noexcept(false); + virtual ~DynamicModelDLL(); void eval(const Vector &y, const Vector &x, const Vector ¶ms, const Vector &ySteady, - Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) throw (DynareException); + Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) noexcept(false); }; #endif diff --git a/mex/sources/k_order_perturbation/dynamic_m.cc b/mex/sources/k_order_perturbation/dynamic_m.cc index 7fe252cfd..0904dd4ae 100644 --- a/mex/sources/k_order_perturbation/dynamic_m.cc +++ b/mex/sources/k_order_perturbation/dynamic_m.cc @@ -19,18 +19,14 @@ #include "dynamic_m.hh" -DynamicModelMFile::DynamicModelMFile(const string &modName) throw (DynareException) : - DynamicMFilename(modName + ".dynamic") -{ -} - -DynamicModelMFile::~DynamicModelMFile() +DynamicModelMFile::DynamicModelMFile(const string &modName) noexcept(false) : + DynamicMFilename{modName + ".dynamic"} { } void DynamicModelMFile::eval(const Vector &y, const Vector &x, const Vector &modParams, const Vector &ySteady, - Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) throw (DynareException) + Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) noexcept(false) { mxArray *prhs[nrhs_dynamic], *plhs[nlhs_dynamic]; @@ -51,9 +47,9 @@ DynamicModelMFile::eval(const Vector &y, const Vector &x, const Vector &modParam residual = Vector(mxGetPr(plhs[0]), residual.skip(), (int) mxGetM(plhs[0])); copyDoubleIntoTwoDMatData(mxGetPr(plhs[1]), g1, (int) mxGetM(plhs[1]), (int) mxGetN(plhs[1])); - if (g2 != NULL) + if (g2 != nullptr) copyDoubleIntoTwoDMatData(unpackSparseMatrix(plhs[2]), g2, (int) mxGetNzmax(plhs[2]), 3); - if (g3 != NULL) + if (g3 != nullptr) copyDoubleIntoTwoDMatData(unpackSparseMatrix(plhs[3]), g3, (int) mxGetNzmax(plhs[3]), 3); for (int i = 0; i < nrhs_dynamic; i++) diff --git a/mex/sources/k_order_perturbation/dynamic_m.hh b/mex/sources/k_order_perturbation/dynamic_m.hh index 260d07ef8..a0b890d12 100644 --- a/mex/sources/k_order_perturbation/dynamic_m.hh +++ b/mex/sources/k_order_perturbation/dynamic_m.hh @@ -36,10 +36,9 @@ private: const static int nlhs_dynamic = 4; const static int nrhs_dynamic = 5; public: - DynamicModelMFile(const string &modName) throw (DynareException); - virtual - ~DynamicModelMFile(); + explicit DynamicModelMFile(const string &modName) noexcept(false); + virtual ~DynamicModelMFile() = default; void eval(const Vector &y, const Vector &x, const Vector ¶ms, const Vector &ySteady, - Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) throw (DynareException); + Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) noexcept(false); }; #endif diff --git a/mex/sources/k_order_perturbation/k_ord_dynare.cc b/mex/sources/k_order_perturbation/k_ord_dynare.cc index 7602b550d..fe899c469 100644 --- a/mex/sources/k_order_perturbation/k_ord_dynare.cc +++ b/mex/sources/k_order_perturbation/k_ord_dynare.cc @@ -40,14 +40,14 @@ KordpDynare::KordpDynare(const vector &endo, int num_endo, Vector &ysteady, TwoDMatrix &vcov, Vector &inParams, int nstat, int npred, int nforw, int nboth, const int jcols, const Vector &nnzd, const int nsteps, int norder, - Journal &jr, DynamicModelAC *dynamicModelFile_arg, double sstol, - const vector &var_order, const TwoDMatrix &llincidence, double criterium) throw (TLException) : - nStat(nstat), nBoth(nboth), nPred(npred), nForw(nforw), nExog(nexog), nPar(npar), - nYs(npred + nboth), nYss(nboth + nforw), nY(num_endo), nJcols(jcols), NNZD(nnzd), nSteps(nsteps), - nOrder(norder), journal(jr), ySteady(ysteady), params(inParams), vCov(vcov), - md(1), dnl(*this, endo), denl(*this, exo), dsnl(*this, dnl, denl), ss_tol(sstol), varOrder(var_order), - ll_Incidence(llincidence), qz_criterium(criterium), g1p(NULL), - g2p(NULL), g3p(NULL), dynamicModelFile(dynamicModelFile_arg) + Journal &jr, unique_ptr dynamicModelFile_arg, double sstol, + const vector &var_order, const TwoDMatrix &llincidence, double criterium) noexcept(false) : + nStat{nstat}, nBoth{nboth}, nPred{npred}, nForw{nforw}, nExog{nexog}, nPar{npar}, + nYs{npred + nboth}, nYss{nboth + nforw}, nY{num_endo}, nJcols{jcols}, NNZD{nnzd}, nSteps{nsteps}, + nOrder{norder}, journal{jr}, ySteady{ysteady}, params{inParams}, vCov{vcov}, + md{1}, dnl{*this, endo}, denl{*this, exo}, dsnl{*this, dnl, denl}, ss_tol{sstol}, varOrder{var_order}, + ll_Incidence{llincidence}, qz_criterium{criterium}, g1p{nullptr}, + g2p{nullptr}, g3p{nullptr}, dynamicModelFile{move(dynamicModelFile_arg)} { ReorderDynareJacobianIndices(); @@ -61,15 +61,15 @@ KordpDynare::KordpDynare(const vector &endo, int num_endo, Vector &ysteady, TwoDMatrix &vcov, Vector &inParams, int nstat, int npred, int nforw, int nboth, const int jcols, const Vector &nnzd, const int nsteps, int norder, - Journal &jr, DynamicModelAC *dynamicModelFile_arg, double sstol, + Journal &jr, unique_ptr dynamicModelFile_arg, double sstol, const vector &var_order, const TwoDMatrix &llincidence, double criterium, - TwoDMatrix *g1_arg, TwoDMatrix *g2_arg, TwoDMatrix *g3_arg) throw (TLException) : - nStat(nstat), nBoth(nboth), nPred(npred), nForw(nforw), nExog(nexog), nPar(npar), - nYs(npred + nboth), nYss(nboth + nforw), nY(num_endo), nJcols(jcols), NNZD(nnzd), nSteps(nsteps), - nOrder(norder), journal(jr), ySteady(ysteady), params(inParams), vCov(vcov), - md(1), dnl(*this, endo), denl(*this, exo), dsnl(*this, dnl, denl), ss_tol(sstol), varOrder(var_order), - ll_Incidence(llincidence), qz_criterium(criterium), - g1p(g1_arg), g2p(g2_arg), g3p(g3_arg), dynamicModelFile(dynamicModelFile_arg) + TwoDMatrix *g1_arg, TwoDMatrix *g2_arg, TwoDMatrix *g3_arg) noexcept(false) : + nStat{nstat}, nBoth{nboth}, nPred{npred}, nForw{nforw}, nExog{nexog}, nPar{npar}, + nYs{npred + nboth}, nYss{nboth + nforw}, nY{num_endo}, nJcols{jcols}, NNZD{nnzd}, nSteps{nsteps}, + nOrder{norder}, journal{jr}, ySteady{ysteady}, params{inParams}, vCov{vcov}, + md{1}, dnl{*this, endo}, denl{*this, exo}, dsnl{*this, dnl, denl}, ss_tol{sstol}, varOrder{var_order}, + ll_Incidence{llincidence}, qz_criterium{criterium}, + g1p{g1_arg}, g2p{g2_arg}, g3p{g3_arg}, dynamicModelFile{move(dynamicModelFile_arg)} { ReorderDynareJacobianIndices(); @@ -91,7 +91,7 @@ KordpDynare::solveDeterministicSteady() } void -KordpDynare::evaluateSystem(Vector &out, const Vector &yy, const Vector &xx) throw (DynareException) +KordpDynare::evaluateSystem(Vector &out, const Vector &yy, const Vector &xx) noexcept(false) { // This method is only called when checking the residuals at steady state (Approximation::check), so return zero residuals out.zeros(); @@ -99,7 +99,7 @@ KordpDynare::evaluateSystem(Vector &out, const Vector &yy, const Vector &xx) thr void KordpDynare::evaluateSystem(Vector &out, const Vector &yym, const Vector &yy, - const Vector &yyp, const Vector &xx) throw (DynareException) + const Vector &yyp, const Vector &xx) noexcept(false) { // This method is only called when checking the residuals at steady state (Approximation::check), so return zero residuals out.zeros(); @@ -112,7 +112,7 @@ KordpDynare::evaluateSystem(Vector &out, const Vector &yym, const Vector &yy, void KordpDynare::calcDerivativesAtSteady() { - if (g1p == NULL) + if (g1p == nullptr) { g1p = new TwoDMatrix(nY, nJcols); g1p->zeros(); @@ -166,7 +166,7 @@ KordpDynare::populateDerivativesContainer(const TwoDMatrix &g, int ord, const ve // model derivatives FSSparseTensor instance FSSparseTensor *mdTi = (new FSSparseTensor(ord, nJcols, nY)); - IntSequence s(ord, 0); + IntSequence s{ord, 0}; if (ord == 1) { @@ -261,7 +261,7 @@ KordpDynare::populateDerivativesContainer(const TwoDMatrix &g, int ord, const ve * passing to _dynamic DLL *************************************************************/ void -KordpDynare::LLxSteady(const Vector &yS, Vector &llxSteady) throw (DynareException, TLException) +KordpDynare::LLxSteady(const Vector &yS, Vector &llxSteady) noexcept(false) { if ((nJcols-nExog) == yS.length()) throw DynareException(__FILE__, __LINE__, "ySteady already of right size"); @@ -308,7 +308,7 @@ KordpDynare::LLxSteady(const Vector &yS, Vector &llxSteady) throw (DynareExcepti ************************************/ void -KordpDynare::ReorderDynareJacobianIndices() throw (TLException) +KordpDynare::ReorderDynareJacobianIndices() noexcept(false) { // create temporary square 2D matrix size nEndo x nEndo (sparse) // for the lag, current and lead blocks of the jacobian @@ -351,7 +351,7 @@ DynareStateNameList::DynareStateNameList(const KordpDynare &dynare, const Dynare const DynareNameList &denl) { for (int i = 0; i < dynare.nys(); i++) - names.push_back(string(dnl.getName(i+dynare.nstat()))); + names.push_back(string{dnl.getName(i+dynare.nstat())}); for (int i = 0; i < dynare.nexog(); i++) - names.push_back(string(denl.getName(i))); + names.push_back(string{denl.getName(i)}); } diff --git a/mex/sources/k_order_perturbation/k_ord_dynare.hh b/mex/sources/k_order_perturbation/k_ord_dynare.hh index b5d942f6b..167b6a41d 100644 --- a/mex/sources/k_order_perturbation/k_ord_dynare.hh +++ b/mex/sources/k_order_perturbation/k_ord_dynare.hh @@ -20,6 +20,7 @@ #ifndef K_ORD_DYNARE3_H #define K_ORD_DYNARE3_H #include +#include #include "t_container.h" #include "sparse_tensor.h" #include "decision_rule.h" @@ -123,20 +124,19 @@ public: Vector &ySteady, TwoDMatrix &vCov, Vector ¶ms, int nstat, int nPred, int nforw, int nboth, const int nJcols, const Vector &NNZD, const int nSteps, const int ord, - Journal &jr, DynamicModelAC *dynamicModelFile_arg, double sstol, + Journal &jr, unique_ptr dynamicModelFile_arg, double sstol, const vector &varOrder, const TwoDMatrix &ll_Incidence, - double qz_criterium) throw (TLException); + double qz_criterium) noexcept(false); KordpDynare(const vector &endo, int num_endo, const vector &exo, int num_exo, int num_par, Vector &ySteady, TwoDMatrix &vCov, Vector ¶ms, int nstat, int nPred, int nforw, int nboth, const int nJcols, const Vector &NNZD, const int nSteps, const int ord, - Journal &jr, DynamicModelAC *dynamicModelFile_arg, double sstol, + Journal &jr, unique_ptr dynamicModelFile_arg, double sstol, const vector &varOrder, const TwoDMatrix &ll_Incidence, - double qz_criterium, TwoDMatrix *g1_arg, TwoDMatrix *g2_arg, TwoDMatrix *g3_arg) throw (TLException); + double qz_criterium, TwoDMatrix *g1_arg, TwoDMatrix *g2_arg, TwoDMatrix *g3_arg) noexcept(false); - virtual - ~KordpDynare(); + virtual ~KordpDynare(); int nstat() const { @@ -230,21 +230,21 @@ public: } void solveDeterministicSteady(); - void evaluateSystem(Vector &out, const Vector &yy, const Vector &xx) throw (DynareException); + void evaluateSystem(Vector &out, const Vector &yy, const Vector &xx) noexcept(false); void evaluateSystem(Vector &out, const Vector &yym, const Vector &yy, - const Vector &yyp, const Vector &xx) throw (DynareException); + const Vector &yyp, const Vector &xx) noexcept(false); void calcDerivativesAtSteady(); - DynamicModelAC *dynamicModelFile; + unique_ptr dynamicModelFile; DynamicModel * clone() const { std::cerr << "KordpDynare::clone() not implemented" << std::endl; exit(EXIT_FAILURE); } - void LLxSteady(const Vector &yS, Vector &llxSteady) throw (DynareException, TLException); // Given the steady state in yS, returns in llxSteady the steady state extended with leads and lags + void LLxSteady(const Vector &yS, Vector &llxSteady) noexcept(false); // Given the steady state in yS, returns in llxSteady the steady state extended with leads and lags private: - void ReorderDynareJacobianIndices() throw (TLException); + void ReorderDynareJacobianIndices() noexcept(false); void populateDerivativesContainer(const TwoDMatrix &g, int ord, const vector &vOrder); }; diff --git a/mex/sources/k_order_perturbation/k_order_perturbation.cc b/mex/sources/k_order_perturbation/k_order_perturbation.cc index 1e6a88cc0..79a921a67 100644 --- a/mex/sources/k_order_perturbation/k_order_perturbation.cc +++ b/mex/sources/k_order_perturbation/k_order_perturbation.cc @@ -198,9 +198,9 @@ extern "C" { if ((nEndo != nendo) || (nExog != nexo)) DYN_MEX_FUNC_ERR_MSG_TXT("Incorrect number of input parameters."); - TwoDMatrix *g1m = NULL; - TwoDMatrix *g2m = NULL; - TwoDMatrix *g3m = NULL; + TwoDMatrix *g1m = nullptr; + TwoDMatrix *g2m = nullptr; + TwoDMatrix *g3m = nullptr; // derivatives passed as arguments */ if (nrhs > 3) { @@ -236,11 +236,11 @@ extern "C" { jName += ".jnl"; Journal journal(jName.c_str()); - DynamicModelAC *dynamicModelFile; + unique_ptr dynamicModelFile; if (use_dll == 1) - dynamicModelFile = new DynamicModelDLL(fName); + dynamicModelFile = make_unique(fName); else - dynamicModelFile = new DynamicModelMFile(fName); + dynamicModelFile = make_unique(fName); // intiate tensor library tls.init(kOrder, nStat+2*nPred+3*nBoth+2*nForw+nExog); @@ -248,7 +248,7 @@ extern "C" { // make KordpDynare object KordpDynare dynare(endoNames, nEndo, exoNames, nExog, nPar, ySteady, vCov, modParams, nStat, nPred, nForw, nBoth, - jcols, NNZD, nSteps, kOrder, journal, dynamicModelFile, + jcols, NNZD, nSteps, kOrder, journal, move(dynamicModelFile), sstol, var_order_vp, llincidence, qz_criterium, g1m, g2m, g3m); From 331a27398a1885adfe5a7bb590aeb804c49ac90d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 8 Nov 2018 17:24:07 +0100 Subject: [PATCH 27/53] Fix another memory leak in k-order DLL Re Dynare/dynare#1490. --- .../dynamic_abstract_class.cc | 30 +++++++++---------- .../dynamic_abstract_class.hh | 2 +- mex/sources/k_order_perturbation/dynamic_m.cc | 4 +-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/mex/sources/k_order_perturbation/dynamic_abstract_class.cc b/mex/sources/k_order_perturbation/dynamic_abstract_class.cc index e0da81e88..d4fd0f72f 100644 --- a/mex/sources/k_order_perturbation/dynamic_abstract_class.cc +++ b/mex/sources/k_order_perturbation/dynamic_abstract_class.cc @@ -33,40 +33,40 @@ DynamicModelAC::copyDoubleIntoTwoDMatData(double *dm, TwoDMatrix *tdm, int rows, tdm->get(i, j) = dm[dmIdx++]; } -double * -DynamicModelAC::unpackSparseMatrix(mxArray *sparseMat) +void +DynamicModelAC::unpackSparseMatrixAndCopyIntoTwoDMatData(mxArray *sparseMat, TwoDMatrix *tdm) { int totalCols = mxGetN(sparseMat); mwIndex *rowIdxVector = mxGetIr(sparseMat); mwSize sizeRowIdxVector = mxGetNzmax(sparseMat); mwIndex *colIdxVector = mxGetJc(sparseMat); + assert(tdm->ncols() == 3); + assert(tdm->nrows() == sizeRowIdxVector); + double *ptr = mxGetPr(sparseMat); - double *newMat = (double *) malloc(sizeRowIdxVector*3*sizeof(double)); int rind = 0; - int retvalind0 = 0; - int retvalind1 = sizeRowIdxVector; - int retvalind2 = sizeRowIdxVector*2; + int output_row = 0; for (int i = 0; i < totalCols; i++) for (int j = 0; j < (int) (colIdxVector[i+1]-colIdxVector[i]); j++, rind++) { - newMat[retvalind0++] = rowIdxVector[rind] + 1; - newMat[retvalind1++] = i + 1; - newMat[retvalind2++] = ptr[rind]; + tdm->get(output_row, 0) = rowIdxVector[rind] + 1; + tdm->get(output_row, 1) = i + 1; + tdm->get(output_row, 2) = ptr[rind]; + output_row++; } /* If there are less elements than Nzmax (that might happen if some derivative is symbolically not zero but numerically zero at the evaluation point), then fill in the matrix with empty entries, that will be recognized as such by KordpDynare::populateDerivativesContainer() */ - while (retvalind0 < (int) sizeRowIdxVector) + while (output_row < (int) sizeRowIdxVector) { - newMat[retvalind0++] = 0; - newMat[retvalind1++] = 0; - newMat[retvalind2++] = 0; + tdm->get(output_row, 0) = 0; + tdm->get(output_row, 1) = 0; + tdm->get(output_row, 2) = 0; + output_row++; } - - return newMat; } diff --git a/mex/sources/k_order_perturbation/dynamic_abstract_class.hh b/mex/sources/k_order_perturbation/dynamic_abstract_class.hh index 0c5f63af6..e7f371d82 100644 --- a/mex/sources/k_order_perturbation/dynamic_abstract_class.hh +++ b/mex/sources/k_order_perturbation/dynamic_abstract_class.hh @@ -26,7 +26,7 @@ class DynamicModelAC { public: virtual ~DynamicModelAC() = default; - static double *unpackSparseMatrix(mxArray *sparseMatrix); + static void unpackSparseMatrixAndCopyIntoTwoDMatData(mxArray *sparseMat, TwoDMatrix *tdm); static void copyDoubleIntoTwoDMatData(double *dm, TwoDMatrix *tdm, int rows, int cols); virtual void eval(const Vector &y, const Vector &x, const Vector ¶ms, const Vector &ySteady, Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) noexcept(false) = 0; diff --git a/mex/sources/k_order_perturbation/dynamic_m.cc b/mex/sources/k_order_perturbation/dynamic_m.cc index 0904dd4ae..162e98374 100644 --- a/mex/sources/k_order_perturbation/dynamic_m.cc +++ b/mex/sources/k_order_perturbation/dynamic_m.cc @@ -48,9 +48,9 @@ DynamicModelMFile::eval(const Vector &y, const Vector &x, const Vector &modParam residual = Vector(mxGetPr(plhs[0]), residual.skip(), (int) mxGetM(plhs[0])); copyDoubleIntoTwoDMatData(mxGetPr(plhs[1]), g1, (int) mxGetM(plhs[1]), (int) mxGetN(plhs[1])); if (g2 != nullptr) - copyDoubleIntoTwoDMatData(unpackSparseMatrix(plhs[2]), g2, (int) mxGetNzmax(plhs[2]), 3); + unpackSparseMatrixAndCopyIntoTwoDMatData(plhs[2], g2); if (g3 != nullptr) - copyDoubleIntoTwoDMatData(unpackSparseMatrix(plhs[3]), g3, (int) mxGetNzmax(plhs[3]), 3); + unpackSparseMatrixAndCopyIntoTwoDMatData(plhs[3], g3); for (int i = 0; i < nrhs_dynamic; i++) mxDestroyArray(prhs[i]); From 91a455f2c74afd9c480f195173cb555b16fcef44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 8 Nov 2018 18:12:20 +0100 Subject: [PATCH 28/53] Update preprocessor submodule --- preprocessor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preprocessor b/preprocessor index 5f5fd569d..e22aa1c16 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 5f5fd569dd3127df457e8f17cb6c010c7fc52e30 +Subproject commit e22aa1c16258fc48bcfb53fde4a098899fce2d12 From 2c65f92c6ca35a1034c2b8eb20d1c2e22e8ebea5 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Fri, 9 Nov 2018 15:13:08 +0100 Subject: [PATCH 29/53] preprocessor: submodule update. closes #1210 --- preprocessor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preprocessor b/preprocessor index e22aa1c16..989532a6a 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit e22aa1c16258fc48bcfb53fde4a098899fce2d12 +Subproject commit 989532a6a289fd54b6b3f13759dc91f7138144d2 From c6f5c804d972d7894878acea91e4694da5ab1977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Mon, 12 Nov 2018 12:55:18 +0100 Subject: [PATCH 30/53] Gensylv MEX also needs MatIO (because Dynare++ code does) --- mex/build/matlab/Makefile.am | 7 +++---- mex/build/matlab/configure.ac | 6 +++--- mex/build/octave/Makefile.am | 6 +++--- mex/build/octave/configure.ac | 8 ++++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/mex/build/matlab/Makefile.am b/mex/build/matlab/Makefile.am index da02c56fc..0f7225082 100644 --- a/mex/build/matlab/Makefile.am +++ b/mex/build/matlab/Makefile.am @@ -1,12 +1,11 @@ ACLOCAL_AMFLAGS = -I ../../../m4 -# libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_ - if DO_SOMETHING -SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv block_kalman_filter sobol local_state_space_iterations +SUBDIRS = mjdgges kronecker bytecode block_kalman_filter sobol local_state_space_iterations +# libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_ if HAVE_MATIO -SUBDIRS += k_order_perturbation dynare_simul_ +SUBDIRS += libdynare++ gensylv k_order_perturbation dynare_simul_ endif if HAVE_GSL diff --git a/mex/build/matlab/configure.ac b/mex/build/matlab/configure.ac index 55dd62003..3999c6e8b 100644 --- a/mex/build/matlab/configure.ac +++ b/mex/build/matlab/configure.ac @@ -117,9 +117,9 @@ else fi if test "x$ax_enable_matlab" = "xyes" -a "x$has_matio" = "xyes"; then - BUILD_KORDER_DYNSIMUL_MEX_MATLAB="yes" + BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_MATLAB="yes" else - BUILD_KORDER_DYNSIMUL_MEX_MATLAB="no (missing MatIO library)" + BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_MATLAB="no (missing MatIO library)" fi if test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes" -a "x$has_slicot" = "xyes"; then @@ -158,7 +158,7 @@ Dynare is now configured for building the following components... Binaries (with "make"): MEX files for MATLAB (except those listed below): $BUILD_MEX_MATLAB - K-order and dynare_simul MEX files for MATLAB: $BUILD_KORDER_DYNSIMUL_MEX_MATLAB + Gensylv, k-order and dynare_simul MEX files for MATLAB: $BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_MATLAB MS-SBVAR MEX files for MATLAB: $BUILD_MS_SBVAR_MEX_MATLAB Kalman Steady State MEX file for MATLAB: $BUILD_KALMAN_STEADY_STATE_MATLAB M2HTML documentation: $BUILD_M2HTML diff --git a/mex/build/octave/Makefile.am b/mex/build/octave/Makefile.am index 64bb633ba..704a86bf0 100644 --- a/mex/build/octave/Makefile.am +++ b/mex/build/octave/Makefile.am @@ -1,11 +1,11 @@ ACLOCAL_AMFLAGS = -I ../../../m4 -# libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_ if DO_SOMETHING -SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv block_kalman_filter sobol local_state_space_iterations +SUBDIRS = mjdgges kronecker bytecode block_kalman_filter sobol local_state_space_iterations +# libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_ if HAVE_MATIO -SUBDIRS += k_order_perturbation dynare_simul_ +SUBDIRS += libdynare++ gensylv k_order_perturbation dynare_simul_ endif if HAVE_GSL diff --git a/mex/build/octave/configure.ac b/mex/build/octave/configure.ac index 17e074c2b..c12fc6f11 100644 --- a/mex/build/octave/configure.ac +++ b/mex/build/octave/configure.ac @@ -56,7 +56,7 @@ AC_SUBST([LIBADD_DLOPEN]) AX_GSL AM_CONDITIONAL([HAVE_GSL], [test "x$has_gsl" = "xyes"]) -# Check for libmatio, needed by k-order, dynare_simul, ms-sbvar (only under Octave, as an alternative to MATLAB's libmat) +# Check for libmatio, needed by MEX files using Dynare++ code, and by ms-sbvar (the latter only under Octave, as an alternative to MATLAB's libmat) AX_MATIO AM_CONDITIONAL([HAVE_MATIO], [test "x$has_matio" = "xyes"]) @@ -88,9 +88,9 @@ else fi if test "x$MKOCTFILE" != "x" -a "x$has_matio" = "xyes"; then - BUILD_KORDER_DYNSIMUL_MEX_OCTAVE="yes" + BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_OCTAVE="yes" else - BUILD_KORDER_DYNSIMUL_MEX_OCTAVE="no (missing MatIO library)" + BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_OCTAVE="no (missing MatIO library)" fi if test "x$MKOCTFILE" != "x" -a "x$has_slicot" = "xyes"; then @@ -119,9 +119,9 @@ Dynare is now configured for building the following components... Binaries (with "make"): MEX files for Octave (except those listed below): $BUILD_MEX_OCTAVE + Gensylv, k-order and dynare_simul MEX for Octave: $BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_OCTAVE MS-SBVAR MEX files for Octave: $BUILD_MS_SBVAR_MEX_OCTAVE Kalman Steady State MEX file for Octave: $BUILD_KALMAN_STEADY_STATE_OCTAVE - K-order and dynare_simul MEX for Octave: $BUILD_KORDER_DYNSIMUL_MEX_OCTAVE ]) From abc8431698dbb16d02b9c5e296138f6594e7f6c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Mon, 12 Nov 2018 15:36:31 +0100 Subject: [PATCH 31/53] Remove instructions about builing under Windows Subsystem for Linux See the discussion in http://eris.dynare.org/pipermail/dev/2018-November/005062.html --- README.md | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/README.md b/README.md index 907fb0aa7..f75faafe4 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,6 @@ have a 64-bit MATLAB; if it returns `PCWIN`, `MACI` or `GLNX`, then you have a 1. [**General Instructions**](#general-instructions) 1. [**Debian or Ubuntu**](#debian-or-ubuntu) 1. [**Windows**](#windows) -1. [**Windows Subsystem for Linux**](#windows-subsystem-for-linux) 1. [**macOS**](#macos) ## General Instructions @@ -300,29 +299,6 @@ adapted to a 32-bit MATLAB with the following modifications: **Note:** Compiling the MEX files for Octave and the documentation under MSYS2 is currently not supported. -## Windows Subsystem for Linux - -Dynare can also be compiled from source for the Windows Subsystem for Linux (WSL). The WSL offers Windows 10 Anniversary Update users easy access to a Linux environment. To install the WSL, see https://msdn.microsoft.com/en-us/commandline/wsl/install_guide -To install most of the build dependencies, make sure that the local `rootfs/etc/apt/sources.list` contains -``` -deb-src http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse -deb-src http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse -deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted universe multiverse -``` -in addition to the regular ```deb``` entries. -NB: you cannot edit this file from Windows as this will make the file unreadable for the WSL (rendering WSL unable to detect any package). Therefore, use any Linux editor of your choice. - -After that, run -``` -apt update -apt-get build-dep dynare -``` -If you are building the unstable version, you might also need to install other packages required, e.g -```apt-get install texlive-fonts-extra``` -NB: it might be necessary to preface your calls by ```sudo``` in case you do not have root access with the current user - -After this, prepare the source and configure the build tree as described for Linux above. - ## macOS To simply use a snapshot of Dynare, you have two choices. On MATLAB, you can From 736d43c4e6e64515713cdc95b460e361e5854d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 13 Nov 2018 15:59:16 +0100 Subject: [PATCH 32/53] Bump minimal MATLAB version requirement to 7.9 (R2009b) --- doc/dynare.texi | 2 +- matlab/add_path_to_mex_files.m | 14 +++----------- matlab/dynare.m | 4 ++-- mex/build/matlab/configure.ac | 2 +- windows/dynare.nsi | 17 ++++++----------- 5 files changed, 13 insertions(+), 26 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index 356e4d280..3e308a907 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -466,7 +466,7 @@ In order to run Dynare, you need one of the following: @itemize @item -MATLAB version 7.5 (R2007b) or above (MATLAB R2009b 64-bit for macOS); +MATLAB version 7.9 (R2009b) or above; @item GNU Octave version 4.2.1 or above. diff --git a/matlab/add_path_to_mex_files.m b/matlab/add_path_to_mex_files.m index f40257cbf..b83166d1a 100644 --- a/matlab/add_path_to_mex_files.m +++ b/matlab/add_path_to_mex_files.m @@ -33,7 +33,7 @@ if isoctave else % Add win32 specific paths for Dynare Windows package if strcmp(computer, 'PCWIN') - tmp = [dynareroot '../mex/matlab/win32-7.5-8.6/']; + tmp = [dynareroot '../mex/matlab/win32-7.9-8.6/']; if exist(tmp, 'dir') mexpath = tmp; if modifypath @@ -43,16 +43,8 @@ else end % Add win64 specific paths for Dynare Windows package if strcmp(computer, 'PCWIN64') - if matlab_ver_less_than('7.8') - tmp = [dynareroot '../mex/matlab/win64-7.5-7.7/']; - if exist(tmp, 'dir') - mexpath = tmp; - if modifypath - addpath(mexpath); - end - end - elseif matlab_ver_less_than('9.4') - tmp = [dynareroot '../mex/matlab/win64-7.8-9.3/']; + if matlab_ver_less_than('9.4') + tmp = [dynareroot '../mex/matlab/win64-7.9-9.3/']; if exist(tmp, 'dir') mexpath = tmp; if modifypath diff --git a/matlab/dynare.m b/matlab/dynare.m index 4e347f1a0..fa3808803 100644 --- a/matlab/dynare.m +++ b/matlab/dynare.m @@ -87,9 +87,9 @@ if isoctave skipline() end else - if matlab_ver_less_than('7.5') % Should match the test in mex/build/matlab/configure.ac + if matlab_ver_less_than('7.9') % Should match the test in mex/build/matlab/configure.ac skipline() - warning('This version of Dynare has only been tested on MATLAB 7.5 (R2007b) 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 7.9 (R2009b) 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 diff --git a/mex/build/matlab/configure.ac b/mex/build/matlab/configure.ac index 3999c6e8b..b95039d75 100644 --- a/mex/build/matlab/configure.ac +++ b/mex/build/matlab/configure.ac @@ -34,7 +34,7 @@ if test "x$ax_enable_matlab" = "xyes"; then if test "x$ax_matlab_version_ok" = "xyes"; then AX_MEXOPTS - AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.5], [AC_MSG_ERROR([Your MATLAB is too old, please upgrade to version 7.5 (R2007b) at least.])]) + AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.9], [AC_MSG_ERROR([Your MATLAB is too old, please upgrade to version 7.9 (R2009b) at least.])]) fi CFLAGS="$MATLAB_CFLAGS" diff --git a/windows/dynare.nsi b/windows/dynare.nsi index 7ad7126b7..aee97f89f 100644 --- a/windows/dynare.nsi +++ b/windows/dynare.nsi @@ -88,19 +88,14 @@ SectionEnd SectionGroup "MEX files for MATLAB" -Section "MEX files for MATLAB 32-bit, version 7.5 to 8.6 (R2007b to R2015b)" - SetOutPath $INSTDIR\mex\matlab\win32-7.5-8.6 - File ..\mex\matlab\win32-7.5-8.6\*.mexw32 +Section "MEX files for MATLAB 32-bit, version 7.9 to 8.6 (R2009b to R2015b)" + SetOutPath $INSTDIR\mex\matlab\win32-7.9-8.6 + File ..\mex\matlab\win32-7.9-8.6\*.mexw32 SectionEnd -Section "MEX files for MATLAB 64-bit, version 7.5 to 7.7 (R2007b to R2008b)" - SetOutPath $INSTDIR\mex\matlab\win64-7.5-7.7 - File ..\mex\matlab\win64-7.5-7.7\*.mexw64 -SectionEnd - -Section "MEX files for MATLAB 64-bit, version 7.8 to 9.3 (R2009a to R2017b)" - SetOutPath $INSTDIR\mex\matlab\win64-7.8-9.3 - File ..\mex\matlab\win64-7.8-9.3\*.mexw64 +Section "MEX files for MATLAB 64-bit, version 7.9 to 9.3 (R2009b to R2017b)" + SetOutPath $INSTDIR\mex\matlab\win64-7.9-9.3 + File ..\mex\matlab\win64-7.9-9.3\*.mexw64 SectionEnd Section "MEX files for MATLAB 64-bit, version 9.4 to 9.5 (R2018a to R2018b)" From ce49cd95df4b4f1d825b4c9d8a01ccf5945547c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 13 Nov 2018 16:59:27 +0100 Subject: [PATCH 33/53] Add missing iscolumn and ismatrix for MATLAB < R2010b Also fix a bug in isrow (it was not checking the rank of the array). --- matlab/dynare_config.m | 4 ++-- .../missing/is-row-column-matrix/iscolumn.m | 20 +++++++++++++++++++ .../missing/is-row-column-matrix/ismatrix.m | 19 ++++++++++++++++++ .../{isrow => is-row-column-matrix}/isrow.m | 4 ++-- 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 matlab/missing/is-row-column-matrix/iscolumn.m create mode 100644 matlab/missing/is-row-column-matrix/ismatrix.m rename matlab/missing/{isrow => is-row-column-matrix}/isrow.m (93%) diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m index acdf95456..f8ae33163 100644 --- a/matlab/dynare_config.m +++ b/matlab/dynare_config.m @@ -126,9 +126,9 @@ if ~isoctave && matlab_ver_less_than('8.1') p{end+1} = '/missing/strsplit'; end -% isrow is missing in Matlab. + +sz = size(V); +r = (length(sz) == 2) && (sz(2) == 1); diff --git a/matlab/missing/is-row-column-matrix/ismatrix.m b/matlab/missing/is-row-column-matrix/ismatrix.m new file mode 100644 index 000000000..e9ed4ef2d --- /dev/null +++ b/matlab/missing/is-row-column-matrix/ismatrix.m @@ -0,0 +1,19 @@ +function r = ismatrix(V) +% Copyright (C) 2018 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 . + +r = (ndims(V) == 2); diff --git a/matlab/missing/isrow/isrow.m b/matlab/missing/is-row-column-matrix/isrow.m similarity index 93% rename from matlab/missing/isrow/isrow.m rename to matlab/missing/is-row-column-matrix/isrow.m index 31eabdbe6..ef53534ed 100644 --- a/matlab/missing/isrow/isrow.m +++ b/matlab/missing/is-row-column-matrix/isrow.m @@ -16,5 +16,5 @@ function r = isrow(V) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -[m, n] = size(V); -r = (m == 1); +sz = size(V); +r = (length(sz) == 2) && (sz(1) == 1); From 7a75872f72e2dc0359346dc32fca89669cdca961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 13 Nov 2018 17:58:42 +0100 Subject: [PATCH 34/53] Modernization: use tilde (~) syntax for ignored output arguments --- matlab/PosteriorIRF_core1.m | 2 +- matlab/WriteShockDecomp2Excel.m | 2 +- matlab/annualized_shock_decomposition.m | 4 ++-- matlab/bksupk.m | 6 ++--- matlab/check_list_of_variables.m | 2 +- matlab/check_posterior_sampler_options.m | 4 ++-- matlab/discretionary_policy_1.m | 4 ++-- matlab/dr_block.m | 4 ++-- matlab/draw_prior_density.m | 2 +- matlab/dyn_first_order_solver.m | 4 ++-- matlab/dyn_ramsey_static.m | 8 +++---- matlab/dyn_risky_steadystate_solver.m | 2 +- matlab/dyn_second_order_solver.m | 4 ++-- matlab/dynare.m | 2 +- matlab/dynare_estimation_1.m | 9 ++++--- matlab/dynare_estimation_init.m | 22 ++++++++--------- matlab/dynare_gradient.m | 4 ++-- matlab/evaluate_steady_state.m | 2 +- matlab/execute_prior_posterior_function.m | 2 +- matlab/getH.m | 4 ++-- matlab/get_name_of_the_last_mh_file.m | 2 +- matlab/global_initialization.m | 4 ++-- matlab/graph_decomp.m | 2 +- matlab/graph_decomp_detail.m | 2 +- matlab/gsa/prior_draw_gsa.m | 2 +- matlab/gsa/stab_map_.m | 2 +- matlab/identification_analysis.m | 2 +- matlab/initial_condition_decomposition.m | 2 +- matlab/initial_estimation_checks.m | 4 ++-- matlab/kalman/likelihood/kalman_filter_ss.m | 4 ++-- .../likelihood/univariate_kalman_filter_ss.m | 2 +- matlab/lmmcp/lmmcp.m | 2 +- matlab/load_m_file_data_legacy.m | 4 ++-- matlab/model_diagnostics.m | 18 +++++++------- matlab/occbin/get_coef.m | 10 ++++---- matlab/optimization/csminwel1.m | 8 +++---- matlab/optimization/numgrad3_.m | 4 ++-- matlab/optimization/numgrad5_.m | 8 +++---- .../simplex_optimization_routine.m | 6 ++--- matlab/partial_information/dr1_PI.m | 6 ++--- .../det_cond_forecast.m | 10 ++++---- .../perfect_foresight_solver.m | 4 ++-- .../perfect_foresight_solver_core.m | 6 ++--- .../private/initialize_stacked_problem.m | 4 ++-- .../private/simulation_core.m | 6 ++--- matlab/prior_posterior_statistics_core.m | 2 +- matlab/realtime_shock_decomposition.m | 9 ++++--- matlab/shock_decomposition.m | 2 +- matlab/simulated_moments_estimation.m | 2 +- matlab/stochastic_solvers.m | 24 +++++++++---------- matlab/store_smoother_results.m | 2 +- matlab/user_has_matlab_license.m | 2 +- .../utilities/general/clean_current_folder.m | 2 +- matlab/varlist_indices.m | 2 +- 54 files changed, 131 insertions(+), 133 deletions(-) diff --git a/matlab/PosteriorIRF_core1.m b/matlab/PosteriorIRF_core1.m index fb909f889..7fa1716f6 100644 --- a/matlab/PosteriorIRF_core1.m +++ b/matlab/PosteriorIRF_core1.m @@ -194,7 +194,7 @@ while fpar. % Get uniques -[junk1, junk2, index_uniques] = varlist_indices(varlist, M_.endo_names); +[~, ~, index_uniques] = varlist_indices(varlist, M_.endo_names); varlist = varlist(index_uniques); msg = false; diff --git a/matlab/check_posterior_sampler_options.m b/matlab/check_posterior_sampler_options.m index 4683639f3..0cb507586 100644 --- a/matlab/check_posterior_sampler_options.m +++ b/matlab/check_posterior_sampler_options.m @@ -387,7 +387,7 @@ if ~strcmp(posterior_sampler_options.posterior_sampling_method,'slice') end if options_.load_mh_file && posterior_sampler_options.use_mh_covariance_matrix - [junk, invhess] = compute_mh_covariance_matrix; + [~, invhess] = compute_mh_covariance_matrix; posterior_sampler_options.invhess = invhess; end @@ -409,7 +409,7 @@ if strcmp(posterior_sampler_options.posterior_sampling_method,'slice') error('check_posterior_sampler_options:: This error should not occur, please contact developers.') end % % % if options_.load_mh_file && options_.use_mh_covariance_matrix, - % % % [junk, invhess] = compute_mh_covariance_matrix; + % % % [~, invhess] = compute_mh_covariance_matrix; % % % posterior_sampler_options.invhess = invhess; % % % end [V1, D]=eig(invhess); diff --git a/matlab/discretionary_policy_1.m b/matlab/discretionary_policy_1.m index f154912d4..91586970b 100644 --- a/matlab/discretionary_policy_1.m +++ b/matlab/discretionary_policy_1.m @@ -63,7 +63,7 @@ end %call steady_state_file if present to update parameters if options_.steadystate_flag % explicit steady state file - [junk,M_.params,info] = evaluate_steady_state_file(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_, ... + [~,M_.params,info] = evaluate_steady_state_file(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_, ... options_,0); end [U,Uy,W] = feval([M_.fname,'.objective.static'],zeros(endo_nbr,1),[], M_.params); @@ -129,7 +129,7 @@ iter=1; for j=1:numel(Indices) eval(['A',Indices{j},'=zeros(eq_nbr,endo_nbr);']) if strcmp(Indices{j},'0')||(strcmp(Indices{j},'lag') && MaxLag)||(strcmp(Indices{j},'lead') && MaxLead) - [junk,row,col]=find(lead_lag_incidence(iter,:)); + [~,row,col]=find(lead_lag_incidence(iter,:)); eval(['A',Indices{j},'(:,row)=jacobia_(:,col);']) iter=iter+1; end diff --git a/matlab/dr_block.m b/matlab/dr_block.m index 0b4d676ee..c0209d527 100644 --- a/matlab/dr_block.m +++ b/matlab/dr_block.m @@ -409,7 +409,7 @@ for i = 1:Size index_c = lead_lag_incidence(2,:); % Index of all endogenous variables present at time=t index_s = lead_lag_incidence(2,1:n_static); % Index of all static endogenous variables present at time=t if n_static > 0 - [Q, junk] = qr(jacob(:,index_s)); + [Q, ~] = qr(jacob(:,index_s)); aa = Q'*jacob; else aa = jacob; @@ -476,7 +476,7 @@ for i = 1:Size if isfield(options_,'indeterminacy_continuity') if options_.indeterminacy_msv == 1 [ss,tt,w,q] = qz(E',D'); - [ss,tt,w,junk] = reorder(ss,tt,w,q); + [ss,tt,w,~] = reorder(ss,tt,w,q); ss = ss'; tt = tt'; w = w'; diff --git a/matlab/draw_prior_density.m b/matlab/draw_prior_density.m index 8e9ff93c6..b5d993e85 100644 --- a/matlab/draw_prior_density.m +++ b/matlab/draw_prior_density.m @@ -111,7 +111,7 @@ switch pshape(indx) end if pshape(indx) ~= 5 - [junk,k1] = max(dens); + [~,k1] = max(dens); if k1 == 1 || k1 == length(dens) k = find(dens > 10); dens(k) = NaN; diff --git a/matlab/dyn_first_order_solver.m b/matlab/dyn_first_order_solver.m index 698197167..c7f97e9b5 100644 --- a/matlab/dyn_first_order_solver.m +++ b/matlab/dyn_first_order_solver.m @@ -124,7 +124,7 @@ if isempty(reorder_jacobian_columns) nsfwrd)))]; index_e2 = npred+nboth+(1:nboth); - [junk,cols_b] = find(lead_lag_incidence(maximum_lag+1, order_var)); + [~,cols_b] = find(lead_lag_incidence(maximum_lag+1, order_var)); reorder_jacobian_columns = [nonzeros(lead_lag_incidence(:,order_var)'); ... nz+(1:exo_nbr)']; @@ -138,7 +138,7 @@ dr.state_var = state_var; jacobia = jacobia(:,reorder_jacobian_columns); if nstatic > 0 - [Q, junk] = qr(jacobia(:,index_s)); + [Q, ~] = qr(jacobia(:,index_s)); aa = Q'*jacobia; else aa = jacobia; diff --git a/matlab/dyn_ramsey_static.m b/matlab/dyn_ramsey_static.m index cf171e847..ccbad5e7b 100644 --- a/matlab/dyn_ramsey_static.m +++ b/matlab/dyn_ramsey_static.m @@ -75,7 +75,7 @@ elseif options_.steadystate_flag ys_init(k_inst) = inst_val; exo_ss = [oo.exo_steady_state oo.exo_det_steady_state]; [xx,params] = evaluate_steady_state_file(ys_init,exo_ss,M,options_,~options_.steadystate.nocheck); %run steady state file again to update parameters - [junk,junk,steady_state] = nl_func(inst_val); %compute and return steady state + [~,~,steady_state] = nl_func(inst_val); %compute and return steady state else n_var = M.orig_endo_nbr; xx = oo.steady_state(1:n_var); @@ -85,7 +85,7 @@ else if info1~=0 check=81; end - [junk,junk,steady_state] = nl_func(xx); + [~,~,steady_state] = nl_func(xx); end @@ -194,8 +194,8 @@ end function result = check_static_model(ys,M,options_,oo) result = false; if (options_.bytecode) - [chck, res, junk] = bytecode('static',ys,[oo.exo_steady_state oo.exo_det_steady_state], ... - M.params, 'evaluate'); + [chck, res, ~] = bytecode('static',ys,[oo.exo_steady_state oo.exo_det_steady_state], ... + M.params, 'evaluate'); else res = feval([M.fname '.static'],ys,[oo.exo_steady_state oo.exo_det_steady_state], ... M.params); diff --git a/matlab/dyn_risky_steadystate_solver.m b/matlab/dyn_risky_steadystate_solver.m index a17e21326..04c50b84b 100644 --- a/matlab/dyn_risky_steadystate_solver.m +++ b/matlab/dyn_risky_steadystate_solver.m @@ -88,7 +88,7 @@ exo_nbr = M.exo_nbr; M.var_order_endo_names = M.endo_names(dr.order_var); -[junk,dr.i_fwrd_g,i_fwrd_f] = find(lead_lag_incidence(3,order_var)); +[~,dr.i_fwrd_g,i_fwrd_f] = find(lead_lag_incidence(3,order_var)); dr.i_fwrd_f = i_fwrd_f; nd = nnz(lead_lag_incidence) + M.exo_nbr; dr.nd = nd; diff --git a/matlab/dyn_second_order_solver.m b/matlab/dyn_second_order_solver.m index df6ba7693..5040d1493 100644 --- a/matlab/dyn_second_order_solver.m +++ b/matlab/dyn_second_order_solver.m @@ -105,7 +105,7 @@ k1 = find(kstate(:,2) == M_.maximum_endo_lag+2); % Jacobian with respect to the variables with the highest lead fyp = jacobia(:,kstate(k1,3)+nnz(M_.lead_lag_incidence(M_.maximum_endo_lag+1,:))); B(:,nstatic+M_.npred+1:end) = fyp; -[junk,k1,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+M_.maximum_endo_lead+1,order_var)); +[~,k1,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+M_.maximum_endo_lead+1,order_var)); A(1:M_.endo_nbr,nstatic+1:nstatic+nspred)=... A(1:M_.endo_nbr,nstatic+[1:nspred])+fyp*gx1(k1,1:nspred); C = Gy; @@ -162,7 +162,7 @@ kp = sum(kstate(:,2) <= M_.maximum_endo_lag+1); E1 = [eye(nspred); zeros(kp-nspred,nspred)]; H = E1; hxx = dr.ghxx(nstatic+[1:nspred],:); -[junk,k2a,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+2,order_var)); +[~,k2a,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+2,order_var)); k3 = nnz(M_.lead_lag_incidence(1:M_.maximum_endo_lag+1,:))+(1:M_.nsfwrd)'; [B1, err] = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kh(k3,k3)),gu(k2a,:),threads_BC); mexErrCheck('sparse_hessian_times_B_kronecker_C', err); diff --git a/matlab/dynare.m b/matlab/dynare.m index fa3808803..00f18c377 100644 --- a/matlab/dynare.m +++ b/matlab/dynare.m @@ -191,7 +191,7 @@ end if ispc arch = getenv('PROCESSOR_ARCHITECTURE'); else - [junk, arch] = system('uname -m'); + [~, arch] = system('uname -m'); end if isempty(strfind(arch, '64')) diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m index a0eb52924..776adbaa0 100644 --- a/matlab/dynare_estimation_1.m +++ b/matlab/dynare_estimation_1.m @@ -235,8 +235,8 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation if options_.analytic_derivation && strcmp(func2str(objective_function),'dsge_likelihood') ana_deriv_old = options_.analytic_derivation; options_.analytic_derivation = 2; - [junk1, junk2,junk3, junk4, hh] = feval(objective_function,xparam1, ... - dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_); + [~,~,~,~,hh] = feval(objective_function,xparam1, ... + dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_); options_.analytic_derivation = ana_deriv_old; elseif ~isnumeric(options_.mode_compute) || ~(isequal(options_.mode_compute,5) && newratflag~=1 && strcmp(func2str(objective_function),'dsge_likelihood')) % with flag==0, we force to use the hessian from outer product gradient of optimizer 5 @@ -373,9 +373,8 @@ if any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation skipline() end if options_.dsge_var - [junk1,junk2,junk3,junk4,junk5,junk6,junk7,oo_.dsge_var.posterior_mode.PHI_tilde,oo_.dsge_var.posterior_mode.SIGMA_u_tilde,oo_.dsge_var.posterior_mode.iXX,oo_.dsge_var.posterior_mode.prior] =... + [~,~,~,~,~,~,~,oo_.dsge_var.posterior_mode.PHI_tilde,oo_.dsge_var.posterior_mode.SIGMA_u_tilde,oo_.dsge_var.posterior_mode.iXX,oo_.dsge_var.posterior_mode.prior] =... feval(objective_function,xparam1,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_); - clear('junk1','junk2','junk3','junk4','junk5','junk6','junk7'); end elseif ~any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation @@ -519,7 +518,7 @@ if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ... oo_.posterior.metropolis=oo_load_mh.oo_.posterior.metropolis; end end - [error_flag,junk,options_]= metropolis_draw(1,options_,estim_params_,M_); + [error_flag,~,options_]= metropolis_draw(1,options_,estim_params_,M_); if options_.bayesian_irf if error_flag error('Estimation::mcmc: I cannot compute the posterior IRFs!') diff --git a/matlab/dynare_estimation_init.m b/matlab/dynare_estimation_init.m index fb4575209..7676c6445 100644 --- a/matlab/dynare_estimation_init.m +++ b/matlab/dynare_estimation_init.m @@ -454,38 +454,38 @@ if options_.block == 1 % Set restrict_state to postion of observed + state variables in expanded state vector. oo_.dr.restrict_var_list = [k1(i_posA) M_.state_var(sort(i_posB))]; % set mf0 to positions of state variables in restricted state vector for likelihood computation. - [junk,bayestopt_.mf0] = ismember(M_.state_var',oo_.dr.restrict_var_list); + [~,bayestopt_.mf0] = ismember(M_.state_var',oo_.dr.restrict_var_list); % Set mf1 to positions of observed variables in restricted state vector for likelihood computation. - [junk,bayestopt_.mf1] = ismember(k1,oo_.dr.restrict_var_list); + [~,bayestopt_.mf1] = ismember(k1,oo_.dr.restrict_var_list); % Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing. bayestopt_.mf2 = var_obs_index_dr; bayestopt_.mfys = k1; oo_.dr.restrict_columns = [size(i_posA,1)+(1:size(M_.state_var,2))]; [k2, i_posA, i_posB] = union(k3p, M_.state_var', 'rows'); bayestopt_.smoother_var_list = [k3p(i_posA); M_.state_var(sort(i_posB))']; - [junk,junk,bayestopt_.smoother_saved_var_list] = intersect(k3p,bayestopt_.smoother_var_list(:)); - [junk,ic] = intersect(bayestopt_.smoother_var_list,M_.state_var); + [~,~,bayestopt_.smoother_saved_var_list] = intersect(k3p,bayestopt_.smoother_var_list(:)); + [~,ic] = intersect(bayestopt_.smoother_var_list,M_.state_var); bayestopt_.smoother_restrict_columns = ic; - [junk,bayestopt_.smoother_mf] = ismember(k1, bayestopt_.smoother_var_list); + [~,bayestopt_.smoother_mf] = ismember(k1, bayestopt_.smoother_var_list); else % Define union of observed and state variables k2 = union(var_obs_index_dr,[M_.nstatic+1:M_.nstatic+M_.nspred]', 'rows'); % Set restrict_state to postion of observed + state variables in expanded state vector. oo_.dr.restrict_var_list = k2; % set mf0 to positions of state variables in restricted state vector for likelihood computation. - [junk,bayestopt_.mf0] = ismember([M_.nstatic+1:M_.nstatic+M_.nspred]',k2); + [~,bayestopt_.mf0] = ismember([M_.nstatic+1:M_.nstatic+M_.nspred]',k2); % Set mf1 to positions of observed variables in restricted state vector for likelihood computation. - [junk,bayestopt_.mf1] = ismember(var_obs_index_dr,k2); + [~,bayestopt_.mf1] = ismember(var_obs_index_dr,k2); % Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing. bayestopt_.mf2 = var_obs_index_dr; bayestopt_.mfys = k1; - [junk,ic] = intersect(k2,nstatic+(1:npred)'); + [~,ic] = intersect(k2,nstatic+(1:npred)'); oo_.dr.restrict_columns = [ic; length(k2)+(1:nspred-npred)']; bayestopt_.smoother_var_list = union(k2,k3); - [junk,junk,bayestopt_.smoother_saved_var_list] = intersect(k3,bayestopt_.smoother_var_list(:)); - [junk,ic] = intersect(bayestopt_.smoother_var_list,nstatic+(1:npred)'); + [~,~,bayestopt_.smoother_saved_var_list] = intersect(k3,bayestopt_.smoother_var_list(:)); + [~,ic] = intersect(bayestopt_.smoother_var_list,nstatic+(1:npred)'); bayestopt_.smoother_restrict_columns = ic; - [junk,bayestopt_.smoother_mf] = ismember(var_obs_index_dr, bayestopt_.smoother_var_list); + [~,bayestopt_.smoother_mf] = ismember(var_obs_index_dr, bayestopt_.smoother_var_list); end if options_.analytic_derivation diff --git a/matlab/dynare_gradient.m b/matlab/dynare_gradient.m index 2f4dfc9d4..71e9da33e 100644 --- a/matlab/dynare_gradient.m +++ b/matlab/dynare_gradient.m @@ -52,11 +52,11 @@ for i=1:m else h = H(:,i); end - [Fh,junk1,junk2,flag] = feval(fcn, x+transpose(h), varargin{:}); + [Fh,~,~,flag] = feval(fcn, x+transpose(h), varargin{:}); if flag G(:,i) = (Fh-F)/epsilon; else - [Fh,junk1,junk2,flag] = feval(fcn, x-transpose(h), varargin{:}); + [Fh,~,~,flag] = feval(fcn, x-transpose(h), varargin{:}); if flag G(:,i) = (F-Fh)/epsilon; else diff --git a/matlab/evaluate_steady_state.m b/matlab/evaluate_steady_state.m index 993148fc1..9293d53ac 100644 --- a/matlab/evaluate_steady_state.m +++ b/matlab/evaluate_steady_state.m @@ -307,7 +307,7 @@ if M.static_and_dynamic_models_differ z = repmat(ys,1,M.maximum_lead + M.maximum_lag + 1); zx = repmat([exo_ss'], M.maximum_lead + M.maximum_lag + 1, 1); if options.bytecode - [chck, r, junk]= bytecode('dynamic','evaluate', z, zx, M.params, ys, 1); + [chck, r, ~]= bytecode('dynamic','evaluate', z, zx, M.params, ys, 1); mexErrCheck('bytecode', chck); elseif options.block [r, oo.dr] = feval([M.fname '.dynamic'], z', zx, M.params, ys, M.maximum_lag+1, oo.dr); diff --git a/matlab/execute_prior_posterior_function.m b/matlab/execute_prior_posterior_function.m index cb7884e83..e998dd19b 100644 --- a/matlab/execute_prior_posterior_function.m +++ b/matlab/execute_prior_posterior_function.m @@ -55,7 +55,7 @@ if strcmpi(type,'posterior') CutSample(M_, options_, estim_params_); %% initialize metropolis draws options_.sub_draws=n_draws; %set draws for sampling; changed value is not returned to base workspace - [error_flag,junk,options_]= metropolis_draw(1,options_,estim_params_,M_); + [error_flag,~,options_]= metropolis_draw(1,options_,estim_params_,M_); if error_flag error('EXECUTE_POSTERIOR_FUNCTION: The draws could not be initialized') end diff --git a/matlab/getH.m b/matlab/getH.m index a7de28bc0..efd53d9d6 100644 --- a/matlab/getH.m +++ b/matlab/getH.m @@ -319,8 +319,8 @@ if nargout > 5 end end -[junk,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ... - oo_.dr.order_var)); +[~,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ... + oo_.dr.order_var)); GAM0 = zeros(M_.endo_nbr,M_.endo_nbr); Dg0 = zeros(M_.endo_nbr,M_.endo_nbr,param_nbr); GAM0(:,cols_b) = g1(:,cols_j); diff --git a/matlab/get_name_of_the_last_mh_file.m b/matlab/get_name_of_the_last_mh_file.m index e6732a2ef..2741f7b52 100644 --- a/matlab/get_name_of_the_last_mh_file.m +++ b/matlab/get_name_of_the_last_mh_file.m @@ -43,7 +43,7 @@ bk_number = record.Nblck ; predicted_mhname = [ BaseName '_mh' int2str(mh_number) '_blck' int2str(bk_number) '.mat' ] ; all_mh_files = dir([BaseName '_mh*_blck*' ]); -[junk,idx] = sort([all_mh_files.datenum]); +[~,idx] = sort([all_mh_files.datenum]); mhname = all_mh_files(idx(end)).name; if ~strcmpi(mhname,predicted_mhname) diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m index 6a1acadc9..93c1e8ad6 100644 --- a/matlab/global_initialization.m +++ b/matlab/global_initialization.m @@ -130,8 +130,8 @@ set_dynare_seed('default'); % Create directories -[junk,junk]=mkdir(M_.fname); -[junk,junk]=mkdir([M_.fname filesep 'Output']); +[~,~]=mkdir(M_.fname); +[~,~]=mkdir([M_.fname filesep 'Output']); % Load user configuration file. if isfield(options_, 'global_init_file') diff --git a/matlab/graph_decomp.m b/matlab/graph_decomp.m index 7b150a5da..eda542009 100644 --- a/matlab/graph_decomp.m +++ b/matlab/graph_decomp.m @@ -108,7 +108,7 @@ comp_nbr0=comp_nbr; for j=1:nvar z1 = squeeze(z(i_var(j),:,:)); if screen_shocks - [junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend'); + [~, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend'); labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values'); zres = sum(z1(isort(17:end),:),1); z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)]; diff --git a/matlab/graph_decomp_detail.m b/matlab/graph_decomp_detail.m index 2605dbac3..9b920770b 100644 --- a/matlab/graph_decomp_detail.m +++ b/matlab/graph_decomp_detail.m @@ -135,7 +135,7 @@ comp_nbr0=comp_nbr; for j=1:nvar z1 = squeeze(z(i_var(j),:,:)); if screen_shocks, - [junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend'); + [~, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend'); labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values'); zres = sum(z1(isort(17:end),:),1); z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)]; diff --git a/matlab/gsa/prior_draw_gsa.m b/matlab/gsa/prior_draw_gsa.m index c3c92d40d..d772ae22a 100644 --- a/matlab/gsa/prior_draw_gsa.m +++ b/matlab/gsa/prior_draw_gsa.m @@ -49,7 +49,7 @@ if init pdraw = zeros(npar,1); lbcum = zeros(npar,1); ubcum = ones(npar,1); - [junk1,junk2,junk3,lb,ub,junk4] = set_prior(estim_params_,M_,options_); %Prepare bounds + [~,~,~,lb,ub,~] = set_prior(estim_params_,M_,options_); %Prepare bounds if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0) % Set prior bounds bounds = prior_bounds(bayestopt_, options_.prior_trunc); diff --git a/matlab/gsa/stab_map_.m b/matlab/gsa/stab_map_.m index f4f73188c..15c6f22a5 100644 --- a/matlab/gsa/stab_map_.m +++ b/matlab/gsa/stab_map_.m @@ -92,7 +92,7 @@ p2 = bayestopt_.p2(nshock+1:end); p3 = bayestopt_.p3(nshock+1:end); p4 = bayestopt_.p4(nshock+1:end); -[junk1,junk2,junk3,lb,ub,junk4] = set_prior(estim_params_,M_,options_); %Prepare bounds +[~,~,~,lb,ub,~] = set_prior(estim_params_,M_,options_); %Prepare bounds if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0) % Set prior bounds bounds = prior_bounds(bayestopt_, options_.prior_trunc); diff --git a/matlab/identification_analysis.m b/matlab/identification_analysis.m index bc4d8ad86..69b10efad 100644 --- a/matlab/identification_analysis.m +++ b/matlab/identification_analysis.m @@ -198,7 +198,7 @@ if info(1)==0 if isoctave || matlab_ver_less_than('8.3') [V,D]=eig(cc); %fix for older Matlab versions that do not support computing left eigenvalues, see http://mathworks.com/help/releases/R2012b/matlab/ref/eig.html - [W,junk] = eig(cc.'); + [W,~] = eig(cc.'); W = conj(W); else [V,D,W]=eig(cc); diff --git a/matlab/initial_condition_decomposition.m b/matlab/initial_condition_decomposition.m index 52e468a9f..0c846b1ff 100644 --- a/matlab/initial_condition_decomposition.m +++ b/matlab/initial_condition_decomposition.m @@ -74,7 +74,7 @@ end if ~isfield(oo_,'initval_decomposition') options_.selected_variables_only = 0; %make sure all variables are stored options_.plot_priors=0; - [oo,M,junk1,junk2,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_); + [oo,M,~,~,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_); % reduced form dr = oo.dr; diff --git a/matlab/initial_estimation_checks.m b/matlab/initial_estimation_checks.m index bc7d9fb20..05972ef30 100644 --- a/matlab/initial_estimation_checks.m +++ b/matlab/initial_estimation_checks.m @@ -66,7 +66,7 @@ if isfield(EstimatedParameters,'param_vals') && ~isempty(EstimatedParameters.par %check whether steady state file changes estimated parameters Model_par_varied=Model; %store Model structure Model_par_varied.params(EstimatedParameters.param_vals(:,1))=Model_par_varied.params(EstimatedParameters.param_vals(:,1))*1.01; %vary parameters - [junk, new_steady_params_2] = evaluate_steady_state(DynareResults.steady_state,Model_par_varied,DynareOptions,DynareResults,DynareOptions.diffuse_filter==0); + [~, new_steady_params_2] = evaluate_steady_state(DynareResults.steady_state,Model_par_varied,DynareOptions,DynareResults,DynareOptions.diffuse_filter==0); changed_par_indices=find((old_steady_params(EstimatedParameters.param_vals(:,1))-new_steady_params(EstimatedParameters.param_vals(:,1))) ... | (Model_par_varied.params(EstimatedParameters.param_vals(:,1))-new_steady_params_2(EstimatedParameters.param_vals(:,1)))); @@ -105,7 +105,7 @@ end % display warning if some parameters are still NaN test_for_deep_parameters_calibration(Model); -[lnprior, junk1,junk2,info]= priordens(xparam1,BayesInfo.pshape,BayesInfo.p6,BayesInfo.p7,BayesInfo.p3,BayesInfo.p4); +[lnprior,~,~,info]= priordens(xparam1,BayesInfo.pshape,BayesInfo.p6,BayesInfo.p7,BayesInfo.p3,BayesInfo.p4); if info fprintf('The prior density evaluated at the initial values is Inf for the following parameters: %s\n',BayesInfo.name{info,1}) error('The initial value of the prior is -Inf') diff --git a/matlab/kalman/likelihood/kalman_filter_ss.m b/matlab/kalman/likelihood/kalman_filter_ss.m index 5510de9f3..d8dc80468 100644 --- a/matlab/kalman/likelihood/kalman_filter_ss.m +++ b/matlab/kalman/likelihood/kalman_filter_ss.m @@ -114,9 +114,9 @@ while t <= last tmp = (a+K*v); if analytic_derivation if analytic_derivation==2 - [Da,junk,DLIKt,D2a,junk2, Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady,D2a,D2Yss,D2T,[],[]); + [Da,~,DLIKt,D2a,~, Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady,D2a,D2Yss,D2T,[],[]); else - [Da,junk,DLIKt,Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady); + [Da,~,DLIKt,Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady); end DLIK = DLIK + DLIKt; if analytic_derivation==2 || asy_hess diff --git a/matlab/kalman/likelihood/univariate_kalman_filter_ss.m b/matlab/kalman/likelihood/univariate_kalman_filter_ss.m index 9d8cbff06..e67a87f18 100644 --- a/matlab/kalman/likelihood/univariate_kalman_filter_ss.m +++ b/matlab/kalman/likelihood/univariate_kalman_filter_ss.m @@ -153,7 +153,7 @@ while t<=last end if analytic_derivation if analytic_derivation==2 - [Da,junk,D2a] = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0,D2a,D2P,D2T); + [Da,~,D2a] = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0,D2a,D2P,D2T); else Da = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0); end diff --git a/matlab/lmmcp/lmmcp.m b/matlab/lmmcp/lmmcp.m index 50404ac7c..e5911a474 100644 --- a/matlab/lmmcp/lmmcp.m +++ b/matlab/lmmcp/lmmcp.m @@ -392,7 +392,7 @@ while (k < kmax) && (Psix > eps2) Fx = Fxnew; Phix = Phixnew; Psix = Psixnew; - [junk,DFx] = feval(FUN,x,varargin{:}); + [~,DFx] = feval(FUN,x,varargin{:}); DPhix = DPhi(x,Fx,DFx,lb,ub,lambda1,lambda2,n,Indexset); DPsix = DPhix'*Phix; normDPsix = norm(DPsix); diff --git a/matlab/load_m_file_data_legacy.m b/matlab/load_m_file_data_legacy.m index a78563796..2709fe503 100644 --- a/matlab/load_m_file_data_legacy.m +++ b/matlab/load_m_file_data_legacy.m @@ -18,7 +18,7 @@ function o2WysrOISH = load_m_file_data_legacy(datafile, U7ORsJ0vy3) % --*-- Uni % along with Dynare. If not, see . cXDHdrXnqo5KwwVpTRuc6OprAW = datafile(1:end-2); -[pathtocXDHdrXnqo5KwwVpTRuc6OprAW,cXDHdrXnqo5KwwVpTRuc6OprAW,junk] = fileparts(cXDHdrXnqo5KwwVpTRuc6OprAW); +[pathtocXDHdrXnqo5KwwVpTRuc6OprAW,cXDHdrXnqo5KwwVpTRuc6OprAW,~] = fileparts(cXDHdrXnqo5KwwVpTRuc6OprAW); if ~isempty(pathtocXDHdrXnqo5KwwVpTRuc6OprAW) % We need to change directory, first we keep the current directory in memory... @@ -38,7 +38,7 @@ if ~isempty(pathtocXDHdrXnqo5KwwVpTRuc6OprAW) end % Clear all the variables except the ones defined in the script. -clear('pathtocXDHdrXnqo5KwwVpTRuc6OprAW', 'cXDHdrXnqo5KwwVpTRuc6OprAW', 'junk'); +clear('pathtocXDHdrXnqo5KwwVpTRuc6OprAW', 'cXDHdrXnqo5KwwVpTRuc6OprAW'); % Get the list of variables in the script. mj6F4eU1BN = whos(); diff --git a/matlab/model_diagnostics.m b/matlab/model_diagnostics.m index e8f5ff81c..5696f7726 100644 --- a/matlab/model_diagnostics.m +++ b/matlab/model_diagnostics.m @@ -204,22 +204,22 @@ z = repmat(dr.ys,1,klen); if ~options.block if options.order == 1 if (options.bytecode) - [chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ... - M.params, dr.ys, 1); + [chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ... + M.params, dr.ys, 1); jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd]; else - [junk,jacobia_] = feval([M.fname '.dynamic'],z(iyr0),exo_simul, ... - M.params, dr.ys, it_); + [~,jacobia_] = feval([M.fname '.dynamic'],z(iyr0),exo_simul, ... + M.params, dr.ys, it_); end elseif options.order >= 2 if (options.bytecode) - [chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ... - M.params, dr.ys, 1); + [chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ... + M.params, dr.ys, 1); jacobia_ = [loc_dr.g1 loc_dr.g1_x]; else - [junk,jacobia_,hessian1] = feval([M.fname '.dynamic'],z(iyr0),... - exo_simul, ... - M.params, dr.ys, it_); + [~,jacobia_,hessian1] = feval([M.fname '.dynamic'],z(iyr0),... + exo_simul, ... + M.params, dr.ys, it_); end if options.use_dll % In USE_DLL mode, the hessian is in the 3-column sparse representation diff --git a/matlab/occbin/get_coef.m b/matlab/occbin/get_coef.m index f2dbde5a6..924be1b1c 100644 --- a/matlab/occbin/get_coef.m +++ b/matlab/occbin/get_coef.m @@ -6,19 +6,19 @@ coef_y = zeros(endo_nbr,3*endo_nbr); coef_u = zeros(endo_nbr,M.exo_nbr); if M.maximum_lag > 0 - [junk,c1,c2] = find(ll(1,:)); + [~,c1,c2] = find(ll(1,:)); coef_y(:,c1) = jacobian(:,c2); - [junk,c1,c2] = find(ll(2,:)); + [~,c1,c2] = find(ll(2,:)); coef_y(:,c1+endo_nbr) = jacobian(:,c2); if M.maximum_lead > 0 - [junk,c1,c2] = find(ll(3,:)); + [~,c1,c2] = find(ll(3,:)); coef_y(:,c1+2*endo_nbr) = jacobian(:,c2); end else - [junk,c1,c2] = find(ll(1,:)); + [~,c1,c2] = find(ll(1,:)); coef_y(:,c1+endo_nbr) = jacobian(:,c2); if M.maximum_lead > 0 - [junk,c1,c2] = find(ll(2,:)); + [~,c1,c2] = find(ll(2,:)); coef_y(:,c1+2*endo_nbr) = jacobian(:,c2); end end diff --git a/matlab/optimization/csminwel1.m b/matlab/optimization/csminwel1.m index cfa869932..902806596 100644 --- a/matlab/optimization/csminwel1.m +++ b/matlab/optimization/csminwel1.m @@ -142,7 +142,7 @@ while ~done elseif ischar(grad) [g1, badg1] = grad(x1,varargin{:}); else - [junk1,cost_flag,g1] = penalty_objective_function(x1,fcn,penalty,varargin{:}); + [~,cost_flag,g1] = penalty_objective_function(x1,fcn,penalty,varargin{:}); badg1 = ~cost_flag; end wall1=badg1; @@ -169,7 +169,7 @@ while ~done elseif ischar(grad) [g2, badg2] = grad(x2,varargin{:}); else - [junk2,cost_flag,g2] = penalty_objective_function(x1,fcn,penalty,varargin{:}); + [~,cost_flag,g2] = penalty_objective_function(x1,fcn,penalty,varargin{:}); badg2 = ~cost_flag; end wall2=badg2; @@ -201,7 +201,7 @@ while ~done elseif ischar(grad) [g3, badg3] = grad(x3,varargin{:}); else - [junk3,cost_flag,g3] = penalty_objective_function(x1,fcn,penalty,varargin{:}); + [~,cost_flag,g3] = penalty_objective_function(x1,fcn,penalty,varargin{:}); badg3 = ~cost_flag; end wall3=badg3; @@ -261,7 +261,7 @@ while ~done elseif ischar(grad) [gh, badgh] = grad(xh,varargin{:}); else - [junkh,cost_flag,gh] = penalty_objective_function(x1,fcn,penalty,varargin{:}); + [~,cost_flag,gh] = penalty_objective_function(x1,fcn,penalty,varargin{:}); badgh = ~cost_flag; end end diff --git a/matlab/optimization/numgrad3_.m b/matlab/optimization/numgrad3_.m index 635813833..a59fa6ae6 100644 --- a/matlab/optimization/numgrad3_.m +++ b/matlab/optimization/numgrad3_.m @@ -46,12 +46,12 @@ for i=1:n xiold = x(i); h = step_length_correction(xiold,scale,i)*delta; x(i) = xiold + h; - [f1,junk1,cost_flag1] = penalty_objective_function(x, fcn, penalty, varargin{:}); + [f1,~,cost_flag1] = penalty_objective_function(x, fcn, penalty, varargin{:}); if ~cost_flag1 fprintf('Gradient w.r.t. parameter number %3d (x=%16.8f,+h=%16.8f,f0=%16.8f,f1=%16.8f,f2=%16.8f,g0=%16.8f): penalty on the right!\n',i,xiold,h,f0,f1,f2,(f1 - f2) / (2*h)) end x(i) = xiold - h; - [f2,junk2,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:}); + [f2,~,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:}); if ~cost_flag2 fprintf('Gradient w.r.t. parameter number %3d (x=%16.8f,+h=%16.8f,f0=%16.8f,f1=%16.8f,f2=%16.8f,g0=%16.8f): penalty on the left!\n',i,xiold,h,f0,f1,f2,(f1 - f2) / (2*h)) end diff --git a/matlab/optimization/numgrad5_.m b/matlab/optimization/numgrad5_.m index bbce6fd0e..9fbdc9b8e 100644 --- a/matlab/optimization/numgrad5_.m +++ b/matlab/optimization/numgrad5_.m @@ -48,13 +48,13 @@ for i=1:n xiold = x(i); h = step_length_correction(xiold,scale,i)*delta; x(i) = xiold+h; - [f1,junk1,cost_flag1,] = penalty_objective_function(x, fcn, penalty, varargin{:}); + [f1,~,cost_flag1,] = penalty_objective_function(x, fcn, penalty, varargin{:}); x(i) = xiold-h; - [f2,junk1,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:}); + [f2,~,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:}); x(i) = xiold+2*h; - [f3,junk1,cost_flag3] = penalty_objective_function(x, fcn, penalty, varargin{:}); + [f3,~,cost_flag3] = penalty_objective_function(x, fcn, penalty, varargin{:}); x(i) = xiold-2*h; - [f4,junk1,cost_flag4] = penalty_objective_function(x, fcn, penalty, varargin{:}); + [f4,~,cost_flag4] = penalty_objective_function(x, fcn, penalty, varargin{:}); if f00 || length(tct_ruleids)>0 ) diff --git a/matlab/perfect-foresight-models/det_cond_forecast.m b/matlab/perfect-foresight-models/det_cond_forecast.m index 1e4fe53ad..0819820f9 100644 --- a/matlab/perfect-foresight-models/det_cond_forecast.m +++ b/matlab/perfect-foresight-models/det_cond_forecast.m @@ -368,7 +368,7 @@ end save_options_initval_file = options_.initval_file; options_.initval_file = '__'; -[pos_constrained_pf, junk] = find(constrained_perfect_foresight); +[pos_constrained_pf, ~] = find(constrained_perfect_foresight); indx_endo_solve_pf = constrained_vars(pos_constrained_pf); if isempty(indx_endo_solve_pf) pf = 0; @@ -572,7 +572,7 @@ else for t = 1:constrained_periods if direct_mode && ~isempty(is_constraint) - [pos_constrained_pf, junk] = find(constrained_perfect_foresight .* is_constraint(t, :)'); + [pos_constrained_pf, ~] = find(constrained_perfect_foresight .* is_constraint(t, :)'); indx_endo_solve_pf = constrained_vars(pos_constrained_pf); if isempty(indx_endo_solve_pf) pf = 0; @@ -580,7 +580,7 @@ else pf = length(indx_endo_solve_pf); end - [pos_constrained_surprise, junk] = find((1-constrained_perfect_foresight) .* is_constraint(t, :)'); + [pos_constrained_surprise, ~] = find((1-constrained_perfect_foresight) .* is_constraint(t, :)'); indx_endo_solve_surprise = constrained_vars(pos_constrained_surprise); if isempty(indx_endo_solve_surprise) @@ -591,7 +591,7 @@ else end if direct_mode && ~isempty(is_shock) - [pos_shock_pf, junk] = find(shock_perfect_foresight .* is_shock(t, :)'); + [pos_shock_pf, ~] = find(shock_perfect_foresight .* is_shock(t, :)'); indx_endo_solve_pf = shock_vars(pos_shock_pf); if isempty(indx_endo_solve_pf) b_pf = 0; @@ -599,7 +599,7 @@ else b_pf = length(indx_endo_solve_pf); end - [pos_shock_surprise, junk] = find((1-shock_perfect_foresight) .* is_shock(t, :)'); + [pos_shock_surprise, ~] = find((1-shock_perfect_foresight) .* is_shock(t, :)'); indx_endo_solve_surprise = shock_vars(pos_shock_surprise); if isempty(indx_endo_solve_surprise) diff --git a/matlab/perfect-foresight-models/perfect_foresight_solver.m b/matlab/perfect-foresight-models/perfect_foresight_solver.m index c770a630a..17f607ca0 100644 --- a/matlab/perfect-foresight-models/perfect_foresight_solver.m +++ b/matlab/perfect-foresight-models/perfect_foresight_solver.m @@ -179,9 +179,9 @@ if ~isreal(oo_.endo_simul(:)) %can only happen without bytecode yT = real(oo_.endo_simul(:,options_.periods+2)); yy = real(oo_.endo_simul(:,2:options_.periods+1)); illi = M_.lead_lag_incidence'; - [i_cols,junk,i_cols_j] = find(illi(:)); + [i_cols,~,i_cols_j] = find(illi(:)); illi = illi(:,2:3); - [i_cols_J1,junk,i_cols_1] = find(illi(:)); + [i_cols_J1,~,i_cols_1] = find(illi(:)); i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)'); residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ... oo_.exo_simul,M_.params,oo_.steady_state, ... diff --git a/matlab/perfect-foresight-models/perfect_foresight_solver_core.m b/matlab/perfect-foresight-models/perfect_foresight_solver_core.m index e20c9faf6..1f55a2de4 100644 --- a/matlab/perfect-foresight-models/perfect_foresight_solver_core.m +++ b/matlab/perfect-foresight-models/perfect_foresight_solver_core.m @@ -123,16 +123,16 @@ if nargout>1 yy = oo_.endo_simul(:,2:options_.periods+1); if ~exist('illi') illi = M_.lead_lag_incidence'; - [i_cols,junk,i_cols_j] = find(illi(:)); + [i_cols,~,i_cols_j] = find(illi(:)); illi = illi(:,2:3); - [i_cols_J1,junk,i_cols_1] = find(illi(:)); + [i_cols_J1,~,i_cols_1] = find(illi(:)); i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)'); end if options_.block && ~options_.bytecode maxerror = oo_.deterministic_simulation.error; else if options_.bytecode - [chck, residuals, junk]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1); + [chck, residuals, ~]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1); else residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ... oo_.exo_simul,M_.params,oo_.steady_state, ... diff --git a/matlab/perfect-foresight-models/private/initialize_stacked_problem.m b/matlab/perfect-foresight-models/private/initialize_stacked_problem.m index 1a8f61838..f019805dc 100644 --- a/matlab/perfect-foresight-models/private/initialize_stacked_problem.m +++ b/matlab/perfect-foresight-models/private/initialize_stacked_problem.m @@ -71,8 +71,8 @@ y0 = endogenousvariables(:,M.maximum_lag); yT = endogenousvariables(:,M.maximum_lag+periods+1); z = endogenousvariables(:,M.maximum_lag+(1:periods)); illi = M.lead_lag_incidence'; -[i_cols, junk,i_cols_j] = find(illi(:)); +[i_cols,~,i_cols_j] = find(illi(:)); illi = illi(:,2:3); -[i_cols_J1, junk,i_cols_1] = find(illi(:)); +[i_cols_J1,~,i_cols_1] = find(illi(:)); i_cols_T = nonzeros(M.lead_lag_incidence(1:2,:)'); dynamicmodel = str2func([M.fname,'.dynamic']); \ No newline at end of file diff --git a/matlab/perfect-foresight-models/private/simulation_core.m b/matlab/perfect-foresight-models/private/simulation_core.m index 61f6693a4..aa66ef2de 100644 --- a/matlab/perfect-foresight-models/private/simulation_core.m +++ b/matlab/perfect-foresight-models/private/simulation_core.m @@ -99,16 +99,16 @@ if nargout>1 yy = oo_.endo_simul(:,2:options_.periods+1); if ~exist('illi') illi = M_.lead_lag_incidence'; - [i_cols,junk,i_cols_j] = find(illi(:)); + [i_cols,~,i_cols_j] = find(illi(:)); illi = illi(:,2:3); - [i_cols_J1,junk,i_cols_1] = find(illi(:)); + [i_cols_J1,~,i_cols_1] = find(illi(:)); i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)'); end if options_.block && ~options_.bytecode maxerror = oo_.deterministic_simulation.error; else if options_.bytecode - [chck, residuals, junk]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1); + [chck, residuals, ~]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1); else residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ... oo_.exo_simul,M_.params,oo_.steady_state, ... diff --git a/matlab/prior_posterior_statistics_core.m b/matlab/prior_posterior_statistics_core.m index 7fa6832d2..320fb272f 100644 --- a/matlab/prior_posterior_statistics_core.m +++ b/matlab/prior_posterior_statistics_core.m @@ -204,7 +204,7 @@ for b=fpar:B if run_smoother [dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_); - [alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,junk1,junk2,P,junk4,junk5,trend_addition,state_uncertainty,M_,oo_,options_,bayestopt_] = ... + [alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,~,~,P,~,~,trend_addition,state_uncertainty,M_,oo_,options_,bayestopt_] = ... DsgeSmoother(deep,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_); stock_trend_coeff(options_.varobs_id,irun(9))=trend_coeff; diff --git a/matlab/realtime_shock_decomposition.m b/matlab/realtime_shock_decomposition.m index d955b8cb6..02064a7b0 100644 --- a/matlab/realtime_shock_decomposition.m +++ b/matlab/realtime_shock_decomposition.m @@ -98,8 +98,7 @@ nobs = options_.nobs; if forecast_ && any(forecast_params) M1=M_; M1.params = forecast_params; - [junk1,junk2,junk3,junk4,junk5,junk6,oo1] = dynare_resolve(M1,options_,oo_); - clear junk1 junk2 junk3 junk4 junk5 junk6 + [~,~,~,~,~,~,oo1] = dynare_resolve(M1,options_,oo_); end if fast_realtime @@ -109,7 +108,7 @@ if fast_realtime newString=sprintf(running_text); fprintf(['%s'],newString); options_.nobs=fast_realtime; - [oo0,M_,junk1,junk2,Smoothed_Variables_deviation_from_mean0] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_); + [oo0,M_,~,~,Smoothed_Variables_deviation_from_mean0] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_); gend0 = size(oo0.SmoothedShocks.(M_.exo_names{1}),1); prctdone=0.5; if isoctave @@ -120,7 +119,7 @@ if fast_realtime fprintf([s0,'%s'],newString); end options_.nobs=nobs; - [oo2,M_,junk1,junk2,Smoothed_Variables_deviation_from_mean2] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_); + [oo2,M_,~,~,Smoothed_Variables_deviation_from_mean2] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_); gend2 = size(oo2.SmoothedShocks.(M_.exo_names{1}),1); prctdone=1; if isoctave @@ -142,7 +141,7 @@ for j=presample+1:nobs % evalin('base',['options_.nobs=' int2str(j) ';']) options_.nobs=j; if ~fast_realtime - [oo,M_,junk1,junk2,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_); + [oo,M_,~,~,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_); gend = size(oo.SmoothedShocks.(M_.exo_names{1}),1); else gend = gend0+j-fast_realtime; diff --git a/matlab/shock_decomposition.m b/matlab/shock_decomposition.m index c35bf5e59..02c18a186 100644 --- a/matlab/shock_decomposition.m +++ b/matlab/shock_decomposition.m @@ -72,7 +72,7 @@ end options_.selected_variables_only = 0; %make sure all variables are stored options_.plot_priors=0; -[oo_, M_, junk1, junk2, Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set, varlist, M_, oo_, options_, bayestopt_, estim_params_); +[oo_, M_, ~, ~, Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set, varlist, M_, oo_, options_, bayestopt_, estim_params_); % reduced form dr = oo_.dr; diff --git a/matlab/simulated_moments_estimation.m b/matlab/simulated_moments_estimation.m index 2d90a9aaa..4a99ec77e 100644 --- a/matlab/simulated_moments_estimation.m +++ b/matlab/simulated_moments_estimation.m @@ -97,7 +97,7 @@ if nargin>2 if ~isunix error('The parallel version of SMM estimation is not implemented for non unix platforms!') end - [junk,hostname] = unix('hostname --fqdn'); + [~,hostname] = unix('hostname --fqdn'); hostname = deblank(hostname); master_is_running_a_job = 0; for i=1:length(parallel) diff --git a/matlab/stochastic_solvers.m b/matlab/stochastic_solvers.m index a3004899a..9f08b1601 100644 --- a/matlab/stochastic_solvers.m +++ b/matlab/stochastic_solvers.m @@ -111,22 +111,22 @@ it_ = M_.maximum_lag + 1; z = repmat(dr.ys,1,klen); if local_order == 1 if (options_.bytecode) - [chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ... - M_.params, dr.ys, 1); + [chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ... + M_.params, dr.ys, 1); jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd]; else - [junk,jacobia_] = feval([M_.fname '.dynamic'],z(iyr0),exo_simul, ... - M_.params, dr.ys, it_); + [~,jacobia_] = feval([M_.fname '.dynamic'],z(iyr0),exo_simul, ... + M_.params, dr.ys, it_); end elseif local_order == 2 if (options_.bytecode) - [chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ... - M_.params, dr.ys, 1); + [chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ... + M_.params, dr.ys, 1); jacobia_ = [loc_dr.g1 loc_dr.g1_x]; else - [junk,jacobia_,hessian1] = feval([M_.fname '.dynamic'],z(iyr0),... - exo_simul, ... - M_.params, dr.ys, it_); + [~,jacobia_,hessian1] = feval([M_.fname '.dynamic'],z(iyr0),... + exo_simul, ... + M_.params, dr.ys, it_); end if options_.use_dll % In USE_DLL mode, the hessian is in the 3-column sparse representation @@ -217,15 +217,15 @@ nz = nnz(M_.lead_lag_incidence); sdyn = M_.endo_nbr - nstatic; -[junk,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ... - order_var)); +[~,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ... + order_var)); b = zeros(M_.endo_nbr,M_.endo_nbr); b(:,cols_b) = jacobia_(:,cols_j); if M_.maximum_endo_lead == 0 % backward models: simplified code exist only at order == 1 if local_order == 1 - [k1,junk,k2] = find(kstate(:,4)); + [k1,~,k2] = find(kstate(:,4)); dr.ghx(:,k1) = -b\jacobia_(:,k2); if M_.exo_nbr dr.ghu = -b\jacobia_(:,nz+1:end); diff --git a/matlab/store_smoother_results.m b/matlab/store_smoother_results.m index 3688dd13f..bad4fe723 100644 --- a/matlab/store_smoother_results.m +++ b/matlab/store_smoother_results.m @@ -204,7 +204,7 @@ if ~isempty(options_.nk) && options_.nk ~= 0 end else positions_in_declaration_order=oo_.dr.order_var(bayestopt_.smoother_var_list(bayestopt_.smoother_saved_var_list)); - [junk,sorted_index_declaration_order]=sort(positions_in_declaration_order); + [~,sorted_index_declaration_order]=sort(positions_in_declaration_order); oo_.FilteredVariablesKStepAhead(:,sorted_index_declaration_order,:)=oo_.FilteredVariablesKStepAhead; if ~isempty(PK) && options_.filter_covariance %get K-step ahead variances oo_.FilteredVariablesKStepAheadVariances(:,sorted_index_declaration_order,sorted_index_declaration_order,:)=oo_.FilteredVariablesKStepAheadVariances; diff --git a/matlab/user_has_matlab_license.m b/matlab/user_has_matlab_license.m index c8c681283..6f8b3c226 100644 --- a/matlab/user_has_matlab_license.m +++ b/matlab/user_has_matlab_license.m @@ -31,7 +31,7 @@ function [hasLicense] = user_has_matlab_license(toolbox) if matlab_ver_less_than('7.12') hasLicense = license('test', toolbox); else - [hasLicense, junk] = license('checkout',toolbox); + [hasLicense, ~] = license('checkout',toolbox); end if ~hasLicense return diff --git a/matlab/utilities/general/clean_current_folder.m b/matlab/utilities/general/clean_current_folder.m index 6c302927e..df7e7bf79 100644 --- a/matlab/utilities/general/clean_current_folder.m +++ b/matlab/utilities/general/clean_current_folder.m @@ -21,7 +21,7 @@ a = dir('*.mod'); for i = 1:length(a) - [junk,basename,extension] = fileparts(a(i).name); + [~,basename,extension] = fileparts(a(i).name); if exist([basename '.m']) delete([basename '.m']); end diff --git a/matlab/varlist_indices.m b/matlab/varlist_indices.m index 91b2f6e69..a166f28b6 100644 --- a/matlab/varlist_indices.m +++ b/matlab/varlist_indices.m @@ -48,7 +48,7 @@ if ~all(check) end nvar = length(i_var); -[i_var_unique, index_uniques, junk] = unique(i_var, 'first'); +[i_var_unique, index_uniques, ~] = unique(i_var, 'first'); index_uniques = sort(index_uniques); i_var_unique = i_var(index_uniques); From 18faa9733c8131e93634cb746ad6f592f7551100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 13 Nov 2018 18:29:20 +0100 Subject: [PATCH 35/53] Further updates related to minimal MATLAB version bump --- m4/ax_mexopts.m4 | 2 +- matlab/dynare.m | 1 + matlab/get_dynare_random_generator_state.m | 2 +- matlab/set_dynare_random_generator_state.m | 2 +- matlab/set_dynare_seed.m | 2 +- windows/README.txt | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/m4/ax_mexopts.m4 b/m4/ax_mexopts.m4 index 0d9a93a8f..514e3283c 100644 --- a/m4/ax_mexopts.m4 +++ b/m4/ax_mexopts.m4 @@ -22,7 +22,7 @@ AC_REQUIRE([AX_MATLAB_ARCH]) AC_REQUIRE([AX_MATLAB_VERSION]) AC_REQUIRE([AC_PROG_SED]) -AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.5], [AC_MSG_ERROR([Your MATLAB is too old, please upgrade to 7.5 (R2007b) at least.])]) +AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.9], [AC_MSG_ERROR([Your MATLAB is too old, please upgrade to 7.9 (R2009b) at least.])]) AC_MSG_CHECKING([for options to compile MEX for MATLAB]) diff --git a/matlab/dynare.m b/matlab/dynare.m index 00f18c377..85c9a50a1 100644 --- a/matlab/dynare.m +++ b/matlab/dynare.m @@ -82,6 +82,7 @@ if isoctave 'of models approximated at third order, will not be available.'], supported_octave_version()) skipline() elseif octave_ver_less_than('4.2') % Should match the test in mex/build/octave/configure.ac + % and in m4/ax_mexopts.m4 skipline() warning(['This version of Dynare has only been tested on Octave 4.2 and above. Dynare may fail to run or give unexpected result. Consider upgrading your version of Octave.']) skipline() diff --git a/matlab/get_dynare_random_generator_state.m b/matlab/get_dynare_random_generator_state.m index b2789b054..bf01db4a5 100644 --- a/matlab/get_dynare_random_generator_state.m +++ b/matlab/get_dynare_random_generator_state.m @@ -23,7 +23,7 @@ function [state_u,state_n] = get_dynare_random_generator_state() % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -matlab_random_streams = ~(isoctave || matlab_ver_less_than('7.7')); +matlab_random_streams = ~isoctave; if matlab_random_streams% Use new matlab interface. if matlab_ver_less_than('7.12') diff --git a/matlab/set_dynare_random_generator_state.m b/matlab/set_dynare_random_generator_state.m index a06fdff5d..8854576d9 100644 --- a/matlab/set_dynare_random_generator_state.m +++ b/matlab/set_dynare_random_generator_state.m @@ -23,7 +23,7 @@ function [state_u,state_n] = set_dynare_random_generator_state(state_u,state_n) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -matlab_random_streams = ~(isoctave || matlab_ver_less_than('7.7')); +matlab_random_streams = ~isoctave; if matlab_random_streams% Use new matlab interface. if matlab_ver_less_than('7.12') diff --git a/matlab/set_dynare_seed.m b/matlab/set_dynare_seed.m index 65c5e0587..89feb1961 100644 --- a/matlab/set_dynare_seed.m +++ b/matlab/set_dynare_seed.m @@ -24,7 +24,7 @@ if ~nargin error('set_dynare_seed:: I need at least one input argument!') end -matlab_random_streams = ~(isoctave || matlab_ver_less_than('7.7') || options_.parallel_info.isHybridMatlabOctave); +matlab_random_streams = ~(isoctave || options_.parallel_info.isHybridMatlabOctave); if matlab_random_streams% Use new matlab interface. if nargin==1 diff --git a/windows/README.txt b/windows/README.txt index 094b88ecb..67f1d5681 100644 --- a/windows/README.txt +++ b/windows/README.txt @@ -25,7 +25,7 @@ NOTE: Dynare comes with an automated uninstaller, which you can run from the Using Dynare with MATLAB (R) ---------------------------- -Dynare requires MATLAB (R) version 7.5 (R2007b) or above. With older versions +Dynare requires MATLAB (R) version 7.9 (R2009b) or above. With older versions of MATLAB (R), it may fail or give unexpected results. To use Dynare, you just have to add the 'matlab' subdirectory of your Dynare From bb1642b5b8705b988239e6fe9a3bd6ead1835d48 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Wed, 14 Nov 2018 12:15:59 +0100 Subject: [PATCH 36/53] Cosmetic fixes to reference in manual --- doc/dynare.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index 356e4d280..c1eabc2ed 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -14810,7 +14810,7 @@ Cycles: The Cycle is the Trend,'' @i{NBER Working Paper}, 10734 Amisano, Gianni and Tristani, Oreste (2010): ``Euro area inflation persistence in an estimated nonlinear DSGE model'', @i{Journal of Economic Dynamics and Control}, 34(10), 1837--1858 @item -Andreasen, Martin M., Jesús Fernández-Villaverde, and Juan Rubio-Ramírez (2013): ``The Pruned State-Space System for Non-Linear DSGE Models: Theory and Empirical Applications,'' @i{NBER Working Paper}, 18983 +Andreasen, Martin M., Jesús Fernández-Villaverde, and Juan Rubio-Ramírez (2018): ``The Pruned State-Space System for Non-Linear DSGE Models: Theory and Empirical Applications,'' @i{Review of Economic Studies}, 85(1), 1--49 @item Andrews, Donald W.K (1991): ``Heteroskedasticity and autocorrelation consistent covariance matrix estimation'', @@ -14834,10 +14834,10 @@ and Control}, 19, 711--734 @item Brooks, Stephen P., and Andrew Gelman (1998): ``General methods for monitoring convergence of iterative simulations,'' @i{Journal of -computational and graphical statistics}, 7, pp. 434--455 +Computational and Graphical Statistics}, 7, pp. 434--455 @item -Cardoso, Margarida F., R. L. Salcedo and S. Feyo de Azevedo (1996): ``The simplex simulated annealing approach to continuous non-linear optimization,'' @i{Computers chem. Engng}, 20(9), 1065-1080 +Cardoso, Margarida F., R. L. Salcedo and S. Feyo de Azevedo (1996): ``The simplex simulated annealing approach to continuous non-linear optimization,'' @i{Computers & Chemical Engineering}, 20(9), 1065-1080 @item Chib, Siddhartha and Srikanth Ramamurthy (2010): From c1b0bb5ee3d5d641b4cca39d18a488e760114268 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Wed, 14 Nov 2018 15:02:15 +0100 Subject: [PATCH 37/53] initial_estimation_checks.m: Turn vector info into scalar Related to https://git.dynare.org/Dynare/dynare/commit/a5b97a28a0e26fb2448d6dcf37bdcd125e175b40 that needs to be reverted --- matlab/initial_estimation_checks.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/initial_estimation_checks.m b/matlab/initial_estimation_checks.m index 05972ef30..1ef5b7a22 100644 --- a/matlab/initial_estimation_checks.m +++ b/matlab/initial_estimation_checks.m @@ -106,7 +106,7 @@ end test_for_deep_parameters_calibration(Model); [lnprior,~,~,info]= priordens(xparam1,BayesInfo.pshape,BayesInfo.p6,BayesInfo.p7,BayesInfo.p3,BayesInfo.p4); -if info +if any(info) fprintf('The prior density evaluated at the initial values is Inf for the following parameters: %s\n',BayesInfo.name{info,1}) error('The initial value of the prior is -Inf') end From 09a166f4e7533d50b4e1d3c978907491960c23c7 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Wed, 14 Nov 2018 15:04:27 +0100 Subject: [PATCH 38/53] Revert "adding missing any()" This reverts commit a5b97a28a0e26fb2448d6dcf37bdcd125e175b40. --- matlab/priordens.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/priordens.m b/matlab/priordens.m index 632b86d83..b988e7ea1 100644 --- a/matlab/priordens.m +++ b/matlab/priordens.m @@ -144,7 +144,7 @@ if tt5 if any(x(id5)-p3(id5)<0) || any(x(id5)-p4(id5)>0) logged_prior_density = -Inf ; if nargout ==4 - info=id5(any(x(id5)-p3(id5)<0) || any(x(id5)-p4(id5)>0)); + info=id5((x(id5)-p3(id5)<0) || (x(id5)-p4(id5)>0)); end return end From c16c2fb894d39b1be4b840172a1fe6064b506395 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Wed, 14 Nov 2018 16:01:55 +0100 Subject: [PATCH 39/53] evaluate_steady_state.m: consistently use params Prevents erroneously relying on stale parameters from M.params (thanks to Tom Holden); closes #1627 --- matlab/evaluate_steady_state.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/matlab/evaluate_steady_state.m b/matlab/evaluate_steady_state.m index 9293d53ac..d8120d661 100644 --- a/matlab/evaluate_steady_state.m +++ b/matlab/evaluate_steady_state.m @@ -48,7 +48,7 @@ exo_ss = [oo.exo_steady_state; oo.exo_det_steady_state]; if length(M.aux_vars) > 0 && ~steadystate_flag && M.set_auxiliary_variables h_set_auxiliary_variables = str2func([M.fname '.set_auxiliary_variables']); - ys_init = h_set_auxiliary_variables(ys_init,exo_ss,M.params); + ys_init = h_set_auxiliary_variables(ys_init,exo_ss,params); end if options.ramsey_policy @@ -289,7 +289,7 @@ if check %make sure ys contains auxiliary variables in case of problem with dynare_solve if length(M.aux_vars) > 0 && ~steadystate_flag if M.set_auxiliary_variables - ys = h_set_auxiliary_variables(ys,exo_ss,M.params); + ys = h_set_auxiliary_variables(ys,exo_ss,params); end end resid = evaluate_static_model(ys,exo_ss,params,M,options); @@ -307,15 +307,15 @@ if M.static_and_dynamic_models_differ z = repmat(ys,1,M.maximum_lead + M.maximum_lag + 1); zx = repmat([exo_ss'], M.maximum_lead + M.maximum_lag + 1, 1); if options.bytecode - [chck, r, ~]= bytecode('dynamic','evaluate', z, zx, M.params, ys, 1); + [chck, r, ~]= bytecode('dynamic','evaluate', z, zx, params, ys, 1); mexErrCheck('bytecode', chck); elseif options.block - [r, oo.dr] = feval([M.fname '.dynamic'], z', zx, M.params, ys, M.maximum_lag+1, oo.dr); + [r, oo.dr] = feval([M.fname '.dynamic'], z', zx, params, ys, M.maximum_lag+1, oo.dr); else iyv = M.lead_lag_incidence'; iyr0 = find(iyv(:)); xys = z(iyr0); - r = feval([M.fname '.dynamic'], z(iyr0), zx, M.params, ys, M.maximum_lag + 1); + r = feval([M.fname '.dynamic'], z(iyr0), zx, params, ys, M.maximum_lag + 1); end % Fail if residual greater than tolerance if max(abs(r)) > options.solve_tolf From 022913579a5fdae34cf243726a05eb6348606207 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Wed, 14 Nov 2018 18:37:05 +0100 Subject: [PATCH 40/53] map_calibration.m: Fix bug that prevented display of restrictions --- matlab/gsa/map_calibration.m | 1 - 1 file changed, 1 deletion(-) diff --git a/matlab/gsa/map_calibration.m b/matlab/gsa/map_calibration.m index 7f319610e..8ee08ceba 100644 --- a/matlab/gsa/map_calibration.m +++ b/matlab/gsa/map_calibration.m @@ -42,7 +42,6 @@ end pvalue_ks = DynareOptions.opt_gsa.pvalue_ks; indx_irf = []; indx_moment = []; -DynareOptions.nodisplay = 1; init = ~DynareOptions.opt_gsa.load_stab; options_mcf.pvalue_ks = DynareOptions.opt_gsa.pvalue_ks; From 30361ccb49a65febf8ee608563ca9f1764ffc85d Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Wed, 14 Nov 2018 18:37:54 +0100 Subject: [PATCH 41/53] GSA scatter plots: Correctly pass LaTeX-names to figure --- matlab/gsa/mcf_analysis.m | 4 +++- matlab/gsa/scatter_mcf.m | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/matlab/gsa/mcf_analysis.m b/matlab/gsa/mcf_analysis.m index cec1054cd..023985923 100644 --- a/matlab/gsa/mcf_analysis.m +++ b/matlab/gsa/mcf_analysis.m @@ -34,6 +34,8 @@ if DynareOptions.TeX else param_names_tex = options_mcf.param_names_tex; end +else + param_names_tex = strrep(options_mcf.param_names,'_','\_'); end amcf_name = options_mcf.amcf_name; amcf_title = options_mcf.amcf_title; @@ -78,7 +80,7 @@ if ~isempty(indmcf) && ~DynareOptions.nograph skipline() xx=[]; if ~ isempty(xparam1), xx=xparam1(indmcf); end - scatter_mcf(lpmat(ibeha,indmcf),lpmat(inobeha,indmcf), param_names(indmcf), ... + scatter_mcf(lpmat(ibeha,indmcf),lpmat(inobeha,indmcf), param_names_tex(indmcf), ... '.', [fname_,'_',amcf_name], OutputDirectoryName, amcf_title,xx, DynareOptions, ... beha_title, nobeha_title) end diff --git a/matlab/gsa/scatter_mcf.m b/matlab/gsa/scatter_mcf.m index 211b2e74b..facea3cfa 100644 --- a/matlab/gsa/scatter_mcf.m +++ b/matlab/gsa/scatter_mcf.m @@ -143,7 +143,7 @@ for i = 1:p end if i==1 if nflag == 1 - ylabel(vnames(j,:),'Rotation',45,'interpreter','none', ... + ylabel(vnames(j,:),'Rotation',45, ... 'HorizontalAlignment','right','VerticalAlignment','middle'); else ylabel([num2str(j),' '],'Rotation',90) @@ -151,7 +151,7 @@ for i = 1:p end if j==1 if nflag == 1 - title(vnames(i,:),'interpreter','none','Rotation',45, ... + title(vnames(i,:),'Rotation',45, ... 'HorizontalAlignment','left','VerticalAlignment','bottom') else title(num2str(i)) From 3acdcd36572cc683d79a5b62df199b230ba2cb31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 15 Nov 2018 18:00:20 +0100 Subject: [PATCH 42/53] Update preprocessor submodule --- preprocessor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preprocessor b/preprocessor index 989532a6a..e89dd9cb8 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 989532a6a289fd54b6b3f13759dc91f7138144d2 +Subproject commit e89dd9cb8bebdc194a0045a4b9ca3926db86d74d From 60d95b65f2e1f3937ba1099c6c6f79fb5cab42f0 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Thu, 15 Nov 2018 19:31:55 +0100 Subject: [PATCH 43/53] Identification strength: make plotting consistent 1. Rely on actually computed standard deviations in bayestopt_ instead of potentially unset estim_params_ 2. Remove arbitrary normalizations/omitted normalization in case of division by 0 in normalization 3. Distinguish between 0 identification and division by 0 due to normalization in plots (cherry picked from commit 7341e21a381850c47fbed018bf6a7acdda4fa92e) --- matlab/identification_analysis.m | 48 ++++++++++++++++++-------------- matlab/plot_identification.m | 29 ++++++++++++++++++- 2 files changed, 55 insertions(+), 22 deletions(-) diff --git a/matlab/identification_analysis.m b/matlab/identification_analysis.m index 69b10efad..74b625d5d 100644 --- a/matlab/identification_analysis.m +++ b/matlab/identification_analysis.m @@ -123,24 +123,27 @@ if info(1)==0 ide_strength_J=NaN(1,nparam); ide_strength_J_prior=NaN(1,nparam); if init - normaliz = NaN(1,nparam); + ide_uncert_unnormaliz = NaN(1,nparam); + offset=0; if prior_exist if ~isempty(estim_params_.var_exo) - normaliz1 = estim_params_.var_exo(:,7)'; % normalize with prior standard deviation + normaliz_prior_std = bayestopt_.p2(1:estim_params_.nvx)'; % normalize with prior standard deviation + offset=offset+estim_params_.nvx+estim_params_.nvn; else - normaliz1=[]; + normaliz_prior_std=[]; end if ~isempty(estim_params_.corrx) - normaliz1 = [normaliz1 estim_params_.corrx(:,8)']; % normalize with prior standard deviation + normaliz_prior_std = [normaliz_prior_std bayestopt_.p2(offset+1:offset+estim_params_.ncx)']; % normalize with prior standard deviation + offset=offset+estim_params_.ncx+estim_params_.ncn; end if ~isempty(estim_params_.param_vals) - normaliz1 = [normaliz1 estim_params_.param_vals(:,7)']; % normalize with prior standard deviation + normaliz_prior_std = [normaliz_prior_std bayestopt_.p2(offset+1:offset+estim_params_.np)']; % normalize with prior standard deviation end % normaliz = max([normaliz; normaliz1]); - normaliz1(isinf(normaliz1)) = 1; +% normaliz1(isinf(normaliz1)) = 1; else - normaliz1 = NaN(1,nparam); + normaliz_prior_std = NaN(1,nparam); end try options_.irf = 0; @@ -176,7 +179,7 @@ if info(1)==0 end indok = find(max(ide_hess.indno,[],1)==0); cparam(indok,indok) = inv(AHess(indok,indok)); - normaliz(indok) = sqrt(diag(cparam(indok,indok)))'; + ide_uncert_unnormaliz(indok) = sqrt(diag(cparam(indok,indok)))'; cmm = NaN(size(siJ,1),size(siJ,1)); ind1=find(ide_hess.ind0); cmm = siJ(:,ind1)*((AHess(ind1,ind1))\siJ(:,ind1)'); @@ -242,22 +245,23 @@ if info(1)==0 clre = siLRE(:,ind1-offset)*((MIM(ind1,ind1))\siLRE(:,ind1-offset)'); if ~isempty(indok) rhoM(indok)=sqrt(1./diag(inv(tildaM(indok,indok)))); - normaliz(indok) = (sqrt(diag(inv(tildaM(indok,indok))))./deltaM(indok))'; %sqrt(diag(inv(MIM(indok,indok))))'; + ide_uncert_unnormaliz(indok) = (sqrt(diag(inv(tildaM(indok,indok))))./deltaM(indok))'; %sqrt(diag(inv(MIM(indok,indok))))'; end % deltaM = deltaM.*abs(params') flag_score=0; - end - ide_strength_J(indok) = (1./(normaliz(indok)'./abs(params(indok)'))); - ide_strength_J_prior(indok) = (1./(normaliz(indok)'./normaliz1(indok)')); - ide_strength_J(params==0)=1./normaliz(params==0)'; - deltaM_prior = deltaM.*abs(normaliz1'); + end + ide_strength_J(indok) = (1./(ide_uncert_unnormaliz(indok)'./abs(params(indok)'))); + ide_strength_J_prior(indok) = (1./(ide_uncert_unnormaliz(indok)'./normaliz_prior_std(indok)')); + %ide_strength_J(params==0)=1./ide_uncert_unnormaliz(params==0)'; + sensitivity_zero_pos=find(isinf(deltaM)); + deltaM_prior = deltaM.*abs(normaliz_prior_std'); deltaM = deltaM.*abs(params'); - deltaM(params==0)=deltaM_prior(params==0); + %deltaM(params==0)=deltaM_prior(params==0); quant = siJ./repmat(sqrt(diag(cmm)),1,nparam); if size(quant,1)==1 - siJnorm = abs(quant).*normaliz1; + siJnorm = abs(quant).*normaliz_prior_std; else - siJnorm = vnorm(quant).*normaliz1; + siJnorm = vnorm(quant).*normaliz_prior_std; end % siJnorm = vnorm(siJ(inok,:)).*normaliz; quant=[]; @@ -272,9 +276,9 @@ if info(1)==0 if ~isempty(iy) quant = siH./repmat(sqrt(diag_chh(iy)),1,nparam); if size(quant,1)==1 - siHnorm = abs(quant).*normaliz1; + siHnorm = abs(quant).*normaliz_prior_std; else - siHnorm = vnorm(quant).*normaliz1; + siHnorm = vnorm(quant).*normaliz_prior_std; end else siHnorm = []; @@ -292,9 +296,9 @@ if info(1)==0 if ~isempty(iy) quant = siLRE./repmat(sqrt(diag_clre(iy)),1,np); if size(quant,1)==1 - siLREnorm = abs(quant).*normaliz1(offset+1:end); + siLREnorm = abs(quant).*normaliz_prior_std(offset+1:end); else - siLREnorm = vnorm(quant).*normaliz1(offset+1:end); + siLREnorm = vnorm(quant).*normaliz_prior_std(offset+1:end); end else siLREnorm=[]; @@ -304,6 +308,8 @@ if info(1)==0 ide_hess.ide_strength_J_prior=ide_strength_J_prior; ide_hess.deltaM=deltaM; ide_hess.deltaM_prior=deltaM_prior; + ide_hess.sensitivity_zero_pos=sensitivity_zero_pos; + ide_hess.identified_parameter_indices=indok; ide_moments.siJnorm=siJnorm; ide_model.siHnorm=siHnorm; ide_lre.siLREnorm=siLREnorm; diff --git a/matlab/plot_identification.m b/matlab/plot_identification.m index 12da56804..15b0cf2c9 100644 --- a/matlab/plot_identification.m +++ b/matlab/plot_identification.m @@ -69,6 +69,19 @@ if SampleSize == 1 else bar(log([idehess.ide_strength_J(:,is)' ])) end + hold on + plot((1:length(idehess.ide_strength_J(:,is)))-0.15,log([idehess.ide_strength_J(:,is)']),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none') + plot((1:length(idehess.ide_strength_J_prior(:,is)))+0.15,log([idehess.ide_strength_J_prior(:,is)']),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none') + if any(isinf(log(idehess.ide_strength_J(idehess.identified_parameter_indices)))) + inf_indices=find(isinf(log(idehess.ide_strength_J(idehess.identified_parameter_indices)))); + inf_pos=ismember(is,inf_indices); + plot(find(inf_pos)-0.15,zeros(sum(inf_pos),1),'o','MarkerSize',7,'MarkerFaceColor',[1 1 1],'MarkerEdgeColor',[0 0 0]) + end + if any(isinf(log(idehess.ide_strength_J_prior(idehess.identified_parameter_indices)))) + inf_indices=find(isinf(log(idehess.ide_strength_J_prior(idehess.identified_parameter_indices)))); + inf_pos=ismember(is,inf_indices); + plot(find(inf_pos)+0.15,zeros(sum(inf_pos),1),'o','MarkerSize',7,'MarkerFaceColor',[1 1 1],'MarkerEdgeColor',[0 0 0]) + end set(gca,'xlim',[0 nparam+1]) set(gca,'xticklabel','') dy = get(gca,'ylim'); @@ -92,7 +105,21 @@ if SampleSize == 1 else bar(log([idehess.deltaM(is)])) end - + hold on + plot((1:length(idehess.deltaM(is)))-0.15,log([idehess.deltaM(is)']),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none') + plot((1:length(idehess.deltaM_prior(is)))+0.15,log([idehess.deltaM_prior(is)']),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none') + inf_pos=find(isinf(log(idehess.deltaM))); + if ~isempty(inf_pos) + inf_indices=~ismember(inf_pos,idehess.sensitivity_zero_pos); + inf_pos=ismember(is,inf_pos(inf_indices)); + plot(find(inf_pos)-0.15,zeros(sum(inf_pos),1),'o','MarkerSize',7,'MarkerFaceColor',[1 1 1],'MarkerEdgeColor',[0 0 0]) + end + inf_pos=find(isinf(log(idehess.deltaM_prior))); + if ~isempty(inf_pos) + inf_indices=~ismember(inf_pos,idehess.sensitivity_zero_pos); + inf_pos=ismember(is,inf_pos(inf_indices)); + plot(find(inf_pos)+0.15,zeros(sum(inf_pos),1),'o','MarkerSize',7,'MarkerFaceColor',[1 1 1],'MarkerEdgeColor',[0 0 0]) + end set(gca,'xlim',[0 nparam+1]) set(gca,'xticklabel','') dy = get(gca,'ylim'); From f947a31b80590ea7b6f8e32ce51fb7fed80aebe2 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Fri, 16 Nov 2018 09:24:43 +0000 Subject: [PATCH 44/53] evaluate_steady_state_file.m: fix two bugs in debugging mode --- matlab/evaluate_steady_state_file.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/matlab/evaluate_steady_state_file.m b/matlab/evaluate_steady_state_file.m index cbb0e63db..523c255e0 100644 --- a/matlab/evaluate_steady_state_file.m +++ b/matlab/evaluate_steady_state_file.m @@ -122,7 +122,7 @@ if length(M.aux_vars) > 0 && ~options.ramsey_policy ys = h_set_auxiliary_variables(ys,exo_ss,params); end ys3 = ys; - idx = find(abs(ys0-ys1)>0); + idx = find(abs(ys0-ys1(1:M.orig_endo_nbr))>0); if ~isempty(idx) M.endo_names{idx} else @@ -134,7 +134,7 @@ if length(M.aux_vars) > 0 && ~options.ramsey_policy else disp('2-invariant') end - idx = find(abs(ys3-ys3)>0); + idx = find(abs(ys3-ys2)>0); if ~isempty(idx) M.endo_names{idx} else From 4ecbcbb13656f630b37a5836f9311fee4b88c2e8 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Fri, 16 Nov 2018 10:32:30 +0100 Subject: [PATCH 45/53] evaluate_steady_state_file.m: Remove redundant setting of auxiliary variables The original problems seems to have been fixed by #1133 Essentially reverts https://git.dynare.org/Dynare/dynare/commit/3c7e60b744567f6f39a9c611bce6dcaadcd52bc6 and closes #1175 --- matlab/evaluate_steady_state_file.m | 40 ----------------------------- 1 file changed, 40 deletions(-) diff --git a/matlab/evaluate_steady_state_file.m b/matlab/evaluate_steady_state_file.m index 523c255e0..fa0eeba23 100644 --- a/matlab/evaluate_steady_state_file.m +++ b/matlab/evaluate_steady_state_file.m @@ -36,8 +36,6 @@ function [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options, % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -debug = false; - ys = []; params = M.params; info = 0; @@ -102,49 +100,11 @@ end % adding values for auxiliary variables if length(M.aux_vars) > 0 && ~options.ramsey_policy - if debug - ys0 = ys; - end if M.set_auxiliary_variables ys = h_set_auxiliary_variables(ys,exo_ss,params); end - if debug - ys1 = ys; - end - if M.set_auxiliary_variables - ys = h_set_auxiliary_variables(ys,exo_ss,params); - end - if debug - ys2 = ys; - end - if debug - if M.set_auxiliary_variables - ys = h_set_auxiliary_variables(ys,exo_ss,params); - end - ys3 = ys; - idx = find(abs(ys0-ys1(1:M.orig_endo_nbr))>0); - if ~isempty(idx) - M.endo_names{idx} - else - disp('1-invariant') - end - idx = find(abs(ys2-ys1)>0); - if ~isempty(idx) - M.endo_names{idx} - else - disp('2-invariant') - end - idx = find(abs(ys3-ys2)>0); - if ~isempty(idx) - M.endo_names{idx} - else - disp('3-invariant') - end - pause - end end -check1 = 0; if steady_state_checkflag % Check whether the steady state obtained from the _steadystate file is a steady state. [residuals, check] = evaluate_static_model(ys, exo_ss, params, M, options); From b615d2d795ca5e1dfe9d990a37e1636973efb5b4 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Fri, 16 Nov 2018 16:20:27 +0100 Subject: [PATCH 46/53] identification_analysis.m: Fix bug introduced in 60d95b65f2e1f3937ba1099c6c6f79fb5cab42f0 We already used a variable called offset --- matlab/identification_analysis.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/matlab/identification_analysis.m b/matlab/identification_analysis.m index 74b625d5d..8b6276e53 100644 --- a/matlab/identification_analysis.m +++ b/matlab/identification_analysis.m @@ -124,20 +124,20 @@ if info(1)==0 ide_strength_J_prior=NaN(1,nparam); if init ide_uncert_unnormaliz = NaN(1,nparam); - offset=0; if prior_exist + offset_prior=0; if ~isempty(estim_params_.var_exo) normaliz_prior_std = bayestopt_.p2(1:estim_params_.nvx)'; % normalize with prior standard deviation - offset=offset+estim_params_.nvx+estim_params_.nvn; + offset_prior=offset_prior+estim_params_.nvx+estim_params_.nvn; else normaliz_prior_std=[]; end if ~isempty(estim_params_.corrx) - normaliz_prior_std = [normaliz_prior_std bayestopt_.p2(offset+1:offset+estim_params_.ncx)']; % normalize with prior standard deviation - offset=offset+estim_params_.ncx+estim_params_.ncn; + normaliz_prior_std = [normaliz_prior_std bayestopt_.p2(offset_prior+1:offset_prior+estim_params_.ncx)']; % normalize with prior standard deviation + offset_prior=offset_prior+estim_params_.ncx+estim_params_.ncn; end if ~isempty(estim_params_.param_vals) - normaliz_prior_std = [normaliz_prior_std bayestopt_.p2(offset+1:offset+estim_params_.np)']; % normalize with prior standard deviation + normaliz_prior_std = [normaliz_prior_std bayestopt_.p2(offset_prior+1:offset_prior+estim_params_.np)']; % normalize with prior standard deviation end % normaliz = max([normaliz; normaliz1]); % normaliz1(isinf(normaliz1)) = 1; From 981e2e247a25769e51ab63e19f69af5990523a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Fri, 16 Nov 2018 17:51:11 +0100 Subject: [PATCH 47/53] Fix MATLAB version number in announcement --- NEWS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 3ad74e2f2..cae41b3ae 100644 --- a/NEWS +++ b/NEWS @@ -11,7 +11,7 @@ The Windows packages are already available for download at: The Mac and GNU/Linux packages (for Debian and Ubuntu LTS) should follow soon. -This release is compatible with MATLAB versions 7.5 (R2007b) to 9.3 (R2018a) +This release is compatible with MATLAB versions 7.5 (R2007b) to 9.4 (R2018a) and with GNU Octave versions 4.4. Here is a list of the problems identified in version 4.5.5 and that have been @@ -57,7 +57,7 @@ The Windows packages are already available for download at: The Mac and GNU/Linux packages (for Debian and Ubuntu LTS) should follow soon. -This release is compatible with MATLAB versions 7.5 (R2007b) to 9.3 (R2018a) +This release is compatible with MATLAB versions 7.5 (R2007b) to 9.4 (R2018a) and with GNU Octave versions 4.2. Here is a list of the problems identified in version 4.5.4 and that have been From 33d35d8fccf0f7440791eaa1ef0c9c89c384c7b2 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Fri, 16 Nov 2018 16:36:33 +0100 Subject: [PATCH 48/53] kim2.mod: trigger case where estim_params_block is not detected --- tests/identification/kim/kim2.mod | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/identification/kim/kim2.mod b/tests/identification/kim/kim2.mod index 0984bf4ec..df5989d85 100644 --- a/tests/identification/kim/kim2.mod +++ b/tests/identification/kim/kim2.mod @@ -55,3 +55,7 @@ identification(advanced=1,max_dim_cova_group=3); //varobs c i lam; //to check if observing lam identifies phi and theta //identification(ar=1,advanced=1,max_dim_cova_group=3,prior_mc=250); //identification(prior_mc=100); + + +estim_params_=[]; +identification(advanced=1,max_dim_cova_group=3); From c407b63e8423a463f0002e23e48ffcbdf59da70f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Fri, 16 Nov 2018 18:34:37 +0100 Subject: [PATCH 49/53] Update preprocessor submodule + add test Ref Dynare/preprocessor#13 --- preprocessor | 2 +- tests/Makefile.am | 1 + tests/ramst.mod | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/preprocessor b/preprocessor index e89dd9cb8..b524e19cd 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit e89dd9cb8bebdc194a0045a4b9ca3926db86d74d +Subproject commit b524e19cde2e42caa68be41bd573ee76eb6d4cc2 diff --git a/tests/Makefile.am b/tests/Makefile.am index 47695d7aa..8db128811 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -66,6 +66,7 @@ MODFILES = \ example1_irf_shocks.mod \ example1_abs_sign.mod \ example1_macro.mod \ + example1_mlv.mod \ example1long.mod \ example2long.mod \ example2long_use_dll.mod \ diff --git a/tests/ramst.mod b/tests/ramst.mod index cd05cc619..f75747202 100644 --- a/tests/ramst.mod +++ b/tests/ramst.mod @@ -11,7 +11,8 @@ aa=0.5; model; c + k - aa*x*k(-1)^alph - (1-delt)*k(-1); -c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam); +#glou = (aa*alph*x(+1)*k^(alph-1) + 1 - delt); +c^(-gam) - (1+bet)^(-1)*glou*c(+1)^(-gam); end; initval; From a7a46a6b751775ae3fcb80ae2e4448d11dafb024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Fri, 16 Nov 2018 18:36:57 +0100 Subject: [PATCH 50/53] Add missing file in c407b63e8423a463f0002e23e48ffcbdf59da70f Ref Dynare/preprocessor#13 --- tests/example1_mlv.mod | 53 ++++++++++++++++++++++++++++++++++++++++++ tests/ramst.mod | 3 +-- 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 tests/example1_mlv.mod diff --git a/tests/example1_mlv.mod b/tests/example1_mlv.mod new file mode 100644 index 000000000..19b3608ed --- /dev/null +++ b/tests/example1_mlv.mod @@ -0,0 +1,53 @@ +// Tests for model local variables +// (including in params derivs file, i.e. with identification, see Dynare/preprocessor#13) + +var c, y, k, a, h, b; +varexo e, u; + +parameters beta, rho, alpha, delta, theta, psi, tau; + +alpha = 0.36; +rho = 0.95; +tau = 0.025; +beta = 0.99; +delta = 0.025; +psi = 0; +theta = 2.95; + +phi = 0.1; + +model; +#foo = (exp(b)*c)/(exp(b(+1))*c(+1)); +c*theta*h^(1+psi)=(1-alpha)*y; +k = beta*(foo + *(exp(b(+1))*alpha*y(+1)+(1-delta)*k)); +y = exp(a)*(k(-1)^alpha)*(h^(1-alpha)); +k = exp(b)*(y-c)+(1-delta)*k(-1); +a = rho*a(-1)+tau*b(-1) + e; +b = tau*a(-1)+rho*b(-1) + u; +end; + +initval; +y = 1.08068253095672; +c = 0.80359242014163; +h = 0.29175631001732; +k = 11.08360443260358; +a = 0; +b = 0; +e = 0; +u = 0; +end; + +shocks; +var e; stderr 0.009; +var u; stderr 0.009; +var e, u = phi*0.009*0.009; +end; + +steady; +check; +stoch_simul; + +varobs c; + +identification(parameter_set=calibration); diff --git a/tests/ramst.mod b/tests/ramst.mod index f75747202..cd05cc619 100644 --- a/tests/ramst.mod +++ b/tests/ramst.mod @@ -11,8 +11,7 @@ aa=0.5; model; c + k - aa*x*k(-1)^alph - (1-delt)*k(-1); -#glou = (aa*alph*x(+1)*k^(alph-1) + 1 - delt); -c^(-gam) - (1+bet)^(-1)*glou*c(+1)^(-gam); +c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam); end; initval; From 6995e248634654f885ddc0d6d9cdfc18de21f775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 21 Nov 2018 16:21:46 +0100 Subject: [PATCH 51/53] The testsuite can now be run from Windows --- README.md | 4 ++++ configure.ac | 7 +++++++ tests/Makefile.am | 6 +++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f75faafe4..3d5897319 100644 --- a/README.md +++ b/README.md @@ -287,6 +287,10 @@ to use something like `/c/Progra~1/MATLAB/…`. ``` make ``` +- Run the testsuite: +``` +make -C tests check-matlab +``` **Note:** The above assumes that you have a 64-bit version of MATLAB. It can be adapted to a 32-bit MATLAB with the following modifications: diff --git a/configure.ac b/configure.ac index 87375750c..f3a8f7e37 100644 --- a/configure.ac +++ b/configure.ac @@ -175,6 +175,13 @@ AC_ARG_ENABLE([matlab], AS_HELP_STRING([--disable-matlab], [disable compilation if test "x$enable_matlab" = "xyes"; then AC_CONFIG_SUBDIRS([mex/build/matlab]) AX_MATLAB + AX_MATLAB_ARCH + if test "${MATLAB_ARCH}" = win32 -o "${MATLAB_ARCH}" = win64; then + MATLAB_BATCH_OPTIONS='-nosplash -automation -wait -sd "$(CURDIR)"' + else + MATLAB_BATCH_OPTIONS='-nosplash -nodisplay' + fi + AC_SUBST([MATLAB_BATCH_OPTIONS]) fi AM_CONDITIONAL([ENABLE_MATLAB], [test "x$enable_matlab" = "xyes"]) AM_CONDITIONAL([HAVE_CMD_LINE_MATLAB], [test "x$ax_enable_matlab" = "xyes" -a "x$have_windows" = "x"]) diff --git a/tests/Makefile.am b/tests/Makefile.am index 8db128811..ae8a0b910 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -870,7 +870,7 @@ check-octave: $(O_XFAIL_TRS_FILES) $(O_TRS_FILES) %.m.trs %.m.log: %.mod @echo "`tput bold``tput setaf 8`MATLAB: $(CURDIR)/$*... `tput sgr0`" @DYNARE_VERSION="$(PACKAGE_VERSION)" TOP_TEST_DIR="$(CURDIR)" FILESTEM="$*" \ - $(MATLAB)/bin/matlab -nosplash -nodisplay -r run_test_matlab > $*.m.log 2> /dev/null || \ + $(MATLAB)/bin/matlab $(MATLAB_BATCH_OPTIONS) -r run_test_matlab > $*.m.log 2> /dev/null || \ printf ":test-result: FAIL\n:number-tests: 1\n:number-failed-tests: 1\n:list-of-failed-tests: $*.mod\n:elapsed-time: 0.0\n" > $*.m.trs @if grep -q ":test-result: PASS" $*.m.trs; then \ echo "`tput bold``tput setaf 2`MATLAB: $(CURDIR)/$* PASSED!`tput sgr0`" ; \ @@ -884,7 +884,7 @@ check-octave: $(O_XFAIL_TRS_FILES) $(O_TRS_FILES) %.m.trs %.m.log : %.m @echo "`tput bold``tput setaf 8`MATLAB: $(CURDIR)/$*... `tput sgr0`" @DYNARE_VERSION="$(PACKAGE_VERSION)" TOP_TEST_DIR="$(CURDIR)" \ - $(MATLAB)/bin/matlab -nosplash -nodisplay -r $* > $*.m.log 2> /dev/null + $(MATLAB)/bin/matlab $(MATLAB_BATCH_OPTIONS) -r $* > $*.m.log 2> /dev/null @echo "`tput bold``tput setaf 8`MATLAB: $(CURDIR)/$* Done!`tput sgr0`" %.o.trs %.o.log: %.mod @@ -911,7 +911,7 @@ check-octave: $(O_XFAIL_TRS_FILES) $(O_TRS_FILES) %.m.tls : %.m @echo "`tput bold``tput setaf 8`MATLAB: $(CURDIR)/$*... `tput sgr0`" @TOP_TEST_DIR="$(CURDIR)" FILESTEM="$*" \ - $(MATLAB)/bin/matlab -nosplash -nodisplay -r run_m_script >/dev/null 2>&1 + $(MATLAB)/bin/matlab $(MATLAB_BATCH_OPTIONS) -r run_m_script >/dev/null 2>&1 @touch $*.m.tls @echo "`tput bold`MATLAB`tput setaf 8`: $(CURDIR)/$* Done!`tput sgr0`" From efec66466724047c78ca2f1d07f4110df481fe5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 22 Nov 2018 17:53:39 +0100 Subject: [PATCH 52/53] Preprocessor update + corresponding change in parameters derivatives In the *_params_derivs.m files, in the "hp" matrix, the preprocessor now fully outputs the symmetric elements, so getH needs to be adapted. By the way, also clean up code for "rpp" and "gpp", were full symmetric elements were also already present (and therefore do not need to be duplicated in getH). --- matlab/getH.m | 11 ----------- preprocessor | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/matlab/getH.m b/matlab/getH.m index efd53d9d6..895c9dcc4 100644 --- a/matlab/getH.m +++ b/matlab/getH.m @@ -651,7 +651,6 @@ is=is(find(gpp(is,2)==j)); if ~isempty(is) g22(sub2ind([n,n],gpp(is,3),gpp(is,4)))=gpp(is,5)'; - g22(sub2ind([n,n],gpp(is,4),gpp(is,3)))=gpp(is,5)'; end return @@ -675,10 +674,8 @@ for is=1:length(gpp) % indx = find(ic==find(d)); if fsparse g22(sub2ind([m,n],gpp(is,1),gpp(is,2)),sub2ind([npar,npar],gpp(is,3),gpp(is,4)))=gpp(is,5); - g22(sub2ind([m,n],gpp(is,1),gpp(is,2)),sub2ind([npar,npar],gpp(is,4),gpp(is,3)))=gpp(is,5); else g22(gpp(is,1),gpp(is,2),gpp(is,3),gpp(is,4))=gpp(is,5); - g22(gpp(is,1),gpp(is,2),gpp(is,4),gpp(is,3))=gpp(is,5); end end @@ -696,7 +693,6 @@ for is=1:length(rpp) % d(rpp(is,2),rpp(is,3))=1; % indx = find(ic==find(d)); r22(rpp(is,1),rpp(is,2),rpp(is,3))=rpp(is,4); - r22(rpp(is,1),rpp(is,3),rpp(is,2))=rpp(is,4); end return @@ -707,7 +703,6 @@ h2=zeros(r,m,m,npar); for is=1:length(hp) h2(hp(is,1),hp(is,2),hp(is,3),hp(is,4))=hp(is,5); - h2(hp(is,1),hp(is,3),hp(is,2),hp(is,4))=hp(is,5); end return @@ -722,10 +717,4 @@ if ~isempty(is) h2(sub2ind([m,npar],hp(is,3),hp(is,4)))=hp(is,5)'; end -is=is1(find(hp(is1,3)==j)); - -if ~isempty(is) - h2(sub2ind([m,npar],hp(is,2),hp(is,4)))=hp(is,5)'; -end - return \ No newline at end of file diff --git a/preprocessor b/preprocessor index b524e19cd..fc9cc2dc5 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit b524e19cde2e42caa68be41bd573ee76eb6d4cc2 +Subproject commit fc9cc2dc503e2c8b0921b320e041b0d5f49057ab From 9c75f6e91358e74c4ed1f13617d3e6cc7faea9a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemia=20=28Scylla=29?= Date: Fri, 30 Nov 2018 21:30:08 +0100 Subject: [PATCH 53/53] Updated the preprocessor submodule. --- preprocessor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preprocessor b/preprocessor index fc9cc2dc5..571b5d081 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit fc9cc2dc503e2c8b0921b320e041b0d5f49057ab +Subproject commit 571b5d081657271b7f5e02f93778bddf9020787b