From: stevenj Date: Thu, 12 Nov 2009 22:12:19 +0000 (-0500) Subject: if reltol > 0, catch convergence case where new == old == 0 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=8572bb604ac39aa44436d854d5b024fb7bacfa67;p=nlopt.git if reltol > 0, catch convergence case where new == old == 0 darcs-hash:20091112221219-c8de0-04e133b083c9f326593ad295b7309bf931c16bc4.gz --- diff --git a/util/stop.c b/util/stop.c index 22d31dd..72e6a23 100644 --- a/util/stop.c +++ b/util/stop.c @@ -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)