getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] r5259 - /trunk/getfem/src/gmm/gmm_iter.h


From: logari81
Subject: [Getfem-commits] r5259 - /trunk/getfem/src/gmm/gmm_iter.h
Date: Wed, 23 Mar 2016 08:56:04 -0000

Author: logari81
Date: Wed Mar 23 09:56:04 2016
New Revision: 5259

URL: http://svn.gna.org/viewcvs/getfem?rev=5259&view=rev
Log:
make gmm_iter tolerant to NaN residuals

Modified:
    trunk/getfem/src/gmm/gmm_iter.h

Modified: trunk/getfem/src/gmm/gmm_iter.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/gmm/gmm_iter.h?rev=5259&r1=5258&r2=5259&view=diff
==============================================================================
--- trunk/getfem/src/gmm/gmm_iter.h     (original)
+++ trunk/getfem/src/gmm/gmm_iter.h     Wed Mar 23 09:56:04 2016
@@ -111,17 +111,23 @@
     double get_rhsnorm(void) const { return rhsn; }
     void set_rhsnorm(double r) { rhsn = r; }
     
-    bool converged(void) { return res <= rhsn * resmax; }
+    bool converged(void) {
+      return !isnan(res) && res <= rhsn * resmax;
+    }
     bool converged(double nr) { 
-      res = gmm::abs(nr); resminreach = std::min(resminreach, res);
+      res = gmm::abs(nr);
+      resminreach = std::min(resminreach, res);
       return converged();
     }
     template <typename VECT> bool converged(const VECT &v)
     { return converged(gmm::vect_norm2(v)); }
-    bool diverged(void)
-    { return (nit>=maxiter) || (res>=rhsn*diverged_res && nit > 4); }
-    bool diverged(double nr) { 
-      res = gmm::abs(nr); resminreach = std::min(resminreach, res);
+    bool diverged(void) {
+      return isnan(res) || (nit>=maxiter)
+                        || (res>=rhsn*diverged_res && nit > 4);
+    }
+    bool diverged(double nr) {
+      res = gmm::abs(nr);
+      resminreach = std::min(resminreach, res);
       return diverged();
     }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]