chiark / gitweb /
if reltol > 0, catch convergence case where new == old == 0
authorstevenj <stevenj@alum.mit.edu>
Thu, 12 Nov 2009 22:12:19 +0000 (17:12 -0500)
committerstevenj <stevenj@alum.mit.edu>
Thu, 12 Nov 2009 22:12:19 +0000 (17:12 -0500)
darcs-hash:20091112221219-c8de0-04e133b083c9f326593ad295b7309bf931c16bc4.gz

util/stop.c

index 22d31ddbd18e77e02313dd8b4a3145b4ba855edd..72e6a23cc9f8247c1e0e6b7bd4d3443f3e267d38 100644 (file)
@@ -29,7 +29,8 @@ static int relstop(double old, double new, double reltol, double abstol)
 {
      if (nlopt_isinf(old)) return 0;
      return(fabs(new - old) < abstol 
-           || fabs(new - old) < reltol * (fabs(new) + fabs(old)) * 0.5);
+           || fabs(new - old) < reltol * (fabs(new) + fabs(old)) * 0.5
+           || (reltol > 0 && new == old)); /* catch new == old == 0 case */
 }
 
 int nlopt_stop_ftol(const nlopt_stopping *s, const double f, double oldf)