diff --git a/matlab/trust_region.m b/matlab/trust_region.m index 6b070d62bb12ddf170634b06882f8b7f2c00ac70..d826b47914e73bb70b74fd5abacf95dc85048ce4 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