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).
time-shift
Sébastien Villemot 2021-01-15 17:17:48 +01:00
parent 91b0ba64c6
commit 547969df45
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 7 additions and 2 deletions

View File

@ -25,7 +25,7 @@ function [x,check,info] = trust_region(fcn,x0,j1,j2,jacobian_flag,gstep,tolf,tol
% none
% 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.
%
@ -188,7 +188,12 @@ end
function x = dogleg (r, b, d, delta)
% Get Gauss-Newton direction.
x = decomposition(r, 'CheckCondition', false) \ b;
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;
end
xn = norm (d .* x);
if (xn > delta)
% GN is too big, get scaled gradient.