From 74b41900e54e8fa2943eb548df311f00dec4ec46 Mon Sep 17 00:00:00 2001
From: Jesper Andersson <jesper@fmrib.ox.ac.uk>
Date: Thu, 19 Aug 2010 13:36:51 +0000
Subject: [PATCH] Added gradient descent

---
 nonlin.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/nonlin.h b/nonlin.h
index 6f6edcc..193f7d2 100644
--- a/nonlin.h
+++ b/nonlin.h
@@ -14,7 +14,8 @@ namespace MISCMATHS {
 enum NLMethod {NL_VM,                               // Variable-Metric (see NRinC)
                NL_CG,                               // Conjugate-Gradient (see NRinC)
                NL_SCG,                              // Scaled Conjugate-Gradient (See Moller 1993).
-               NL_LM};                              // Levenberg-Marquardt (see NRinC)
+               NL_LM,                               // Levenberg-Marquardt (see NRinC)
+               NL_GD};                              // Gradient Descent
 
 enum LMType {LM_L, LM_LM};                          // Levenberg or Levenberg-Marquardt
 
@@ -144,6 +145,8 @@ public:
   double InitialCF() const {if (logcf) return(cf[0]); else {throw NonlinException("InitialCF: Cost-function not logged"); return(cf[0]);}}
   const std::vector<double> CFHistory() const {if (logcf) return(cf); else {throw NonlinException("CFHistory: Cost-function not logged"); return(cf);}}
   NonlinOut Status() const {return(status);}
+  bool Success() const { switch(status) { case NL_UNDEFINED: case NL_MAXITER: case NL_LM_MAXITER: return(false); break; default: return(true); } };
+  std::string TextStatus() const;
       
   // Routines to set values of steering parameters
   void SetMethod(NLMethod pmtd) {mtd = pmtd;}
-- 
GitLab