From d4ff34524c64076640ca621b22a9d99c882b7244 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer <jpfeifer@gmx.de> Date: Mon, 23 May 2022 15:33:07 +0200 Subject: [PATCH] trust_region.m: trap case where linear combination with weight 0 on infinite value returns NaN --- matlab/trust_region.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/matlab/trust_region.m b/matlab/trust_region.m index 6b070d62bb..d826b47914 100644 --- a/matlab/trust_region.m +++ b/matlab/trust_region.m @@ -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 + x = (1.0-alpha)*min(sgnorm, delta)*s; + end end \ No newline at end of file -- GitLab