perfect_foresight_solver_core.m: when relevant, use bytecode MEX to recompute ∞-norm of residuals

Since commit 7722e8e36b it would always use the
perfect_foresight_problem MEX, but the latter is less efficient than bytecode.
remove-submodule
Sébastien Villemot 2023-06-12 19:17:34 +02:00
parent 73ae1ac8ce
commit 4431a89e87
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 16 additions and 12 deletions

View File

@ -130,19 +130,23 @@ end
% Some solvers do not compute the maximum error, so do it here if needed
if nargout > 2 && isempty(maxerror)
ny = size(oo_.endo_simul, 1);
if M_.maximum_lag > 0
y0 = y(:, M_.maximum_lag);
if options_.bytecode
residuals = bytecode('dynamic', 'evaluate', y, oo_.exo_simul, M_.params, oo_.steady_state, periods);
else
y0 = NaN(ny, 1);
end
if M_.maximum_lead > 0
yT = y(:, M_.maximum_lag+periods+1);
else
yT = NaN(ny, 1);
end
yy = y(:,M_.maximum_lag+(1:periods));
ny = size(y, 1);
if M_.maximum_lag > 0
y0 = y(:, M_.maximum_lag);
else
y0 = NaN(ny, 1);
end
if M_.maximum_lead > 0
yT = y(:, M_.maximum_lag+periods+1);
else
yT = NaN(ny, 1);
end
yy = y(:,M_.maximum_lag+(1:periods));
residuals = perfect_foresight_problem(yy(:), y0, yT, oo_.exo_simul, M_.params, oo_.steady_state, periods, M_, options_);
residuals = perfect_foresight_problem(yy(:), y0, yT, oo_.exo_simul, M_.params, oo_.steady_state, periods, M_, options_);
end
maxerror = max(max(abs(residuals)));
end