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

Trust region: compatibility fix for Octave and MATLAB < R2017b

When merging the enterprise code, the dogleg subfunction was modified to
incorporate a call to decomposition(), which does not exist under Octave and
MATLAB < R2017b.

For those cases, we reinstate the old code (which uses a plain matrix right
divide).
parent 91b0ba64
Branches
Tags
No related merge requests found
...@@ -25,7 +25,7 @@ function [x,check,info] = trust_region(fcn,x0,j1,j2,jacobian_flag,gstep,tolf,tol ...@@ -25,7 +25,7 @@ function [x,check,info] = trust_region(fcn,x0,j1,j2,jacobian_flag,gstep,tolf,tol
% none % none
% Copyright (C) 2008-2012 VZLU Prague, a.s. % Copyright (C) 2008-2012 VZLU Prague, a.s.
% Copyright (C) 2014-2020 Dynare Team % Copyright (C) 2014-2021 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -188,7 +188,12 @@ end ...@@ -188,7 +188,12 @@ end
function x = dogleg (r, b, d, delta) function x = dogleg (r, b, d, delta)
% Get Gauss-Newton direction. % Get Gauss-Newton direction.
if isoctave || matlab_ver_less_than('9.3')
% The decomposition() function does not exist in Octave and MATLAB < R2017b
x = r \ b;
else
x = decomposition(r, 'CheckCondition', false) \ b; x = decomposition(r, 'CheckCondition', false) \ b;
end
xn = norm (d .* x); xn = norm (d .* x);
if (xn > delta) if (xn > delta)
% GN is too big, get scaled gradient. % GN is too big, get scaled gradient.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment