From 58ba964bb7e286e2fbf679eb39168e1c4e281b4b Mon Sep 17 00:00:00 2001
From: Michel Juillard <michel.juillard@mjui.fr>
Date: Wed, 7 May 2014 13:34:19 +0200
Subject: [PATCH] trust_region/dogleg: fixing sign error

---
 matlab/trust_region.m | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/matlab/trust_region.m b/matlab/trust_region.m
index 804ba7ce09..1edb87732c 100644
--- a/matlab/trust_region.m
+++ b/matlab/trust_region.m
@@ -181,6 +181,7 @@ while (niter < maxiter && ~info)
     % FIXME -- why tolf*n*xn? If abs (e) ~ abs(x) * eps is a vector
     % of perturbations of x, then norm (fjac*e) <= eps*n*xn, i.e. by
     % tolf ~ eps we demand as much accuracy as we can expect.
+    disp([niter fn ratio])
     if (fn <= tolf*n*xn)
         info = 1;
         % The following tests done only after successful step.
@@ -228,7 +229,7 @@ if (xn > delta)
             bn = norm (b);
             dxn = delta/xn; snmd = snm/delta;
             t = (bn/sn) * (bn/xn) * snmd;
-            t = t - dxn * snmd^2 - sqrt ((t-dxn)^2 + (1-dxn^2)*(1-snmd^2));
+            t = t - dxn * snmd^2 + sqrt ((t-dxn)^2 + (1-dxn^2)*(1-snmd^2));
             alpha = dxn*(1-snmd^2) / t;
         else
             alpha = 0;
-- 
GitLab