trust_region.m: trap case where linear combination with weight 0 on infinite value returns NaN

mr#2067
Johannes Pfeifer 2022-05-23 15:24:54 +02:00
parent 20f8dd780f
commit c91e1f895b
1 changed files with 5 additions and 1 deletions

View File

@ -327,5 +327,9 @@ else
end
% Form the appropriate convex combination of the Gauss-Newton direction and the
% scaled gradient direction.
x = alpha*x + (1.0-alpha)*min(sgnorm, delta)*s;
if alpha>0
x = alpha*x + (1.0-alpha)*min(sgnorm, delta)*s;
else %prevent zero weight on Inf evaluating to NaN
x = min(sgnorm, delta)*s;
end
end