Skip to content
Snippets Groups Projects
Verified Commit 9a4e7107 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Conditional forecasting: compatibility fix with MATLAB < R2016b

Implicit expansion (a.k.a. automatic broadcasting) was introduced in MATLAB
R2016b (and it has been present in Octave for quite some time).

Hence use bsxfun() instead.

The problem had been introduced in 228b2a53.

(cherry picked from commit 133b77c0)
parent 0fe204cc
Branches
Tags
1 merge request!1815WIP Cherry-picks for 4.6
Pipeline #3176 passed
...@@ -28,7 +28,7 @@ function imcforecast(constrained_paths, constrained_vars, options_cond_fcst) ...@@ -28,7 +28,7 @@ function imcforecast(constrained_paths, constrained_vars, options_cond_fcst)
% [1] Results are stored in oo_.conditional_forecast. % [1] Results are stored in oo_.conditional_forecast.
% [2] Use the function plot_icforecast to plot the results. % [2] Use the function plot_icforecast to plot the results.
% Copyright (C) 2006-2019 Dynare Team % Copyright (C) 2006-2020 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -249,7 +249,7 @@ for b=1:options_cond_fcst.replic %conditional forecast using cL set to constrain ...@@ -249,7 +249,7 @@ for b=1:options_cond_fcst.replic %conditional forecast using cL set to constrain
[FORCS1(:,:,b), FORCS1_shocks(:,:,b)] = mcforecast3(cL,options_cond_fcst.periods,constrained_paths,shocks,FORCS1(:,:,b),T,R,mv, mu); [FORCS1(:,:,b), FORCS1_shocks(:,:,b)] = mcforecast3(cL,options_cond_fcst.periods,constrained_paths,shocks,FORCS1(:,:,b),T,R,mv, mu);
FORCS1(:,:,b)=FORCS1(:,:,b)+trend; %add trend FORCS1(:,:,b)=FORCS1(:,:,b)+trend; %add trend
end end
if max(max(max(abs(FORCS1(constrained_vars,1:cL,:)-constrained_paths))))>1e-4 if max(max(max(abs(bsxfun(@minus,FORCS1(constrained_vars,1:cL,:),constrained_paths)))))>1e-4
fprintf('\nconditional_forecasts: controlling of variables was not successful.\n') fprintf('\nconditional_forecasts: controlling of variables was not successful.\n')
fprintf('This can be due to numerical imprecision (e.g. explosive simulations)\n') fprintf('This can be due to numerical imprecision (e.g. explosive simulations)\n')
fprintf('or because the instrument(s) do not allow controlling the variable(s).\n') fprintf('or because the instrument(s) do not allow controlling the variable(s).\n')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment