From 8572bb604ac39aa44436d854d5b024fb7bacfa67 Mon Sep 17 00:00:00 2001 From: stevenj Date: Thu, 12 Nov 2009 17:12:19 -0500 Subject: [PATCH] if reltol > 0, catch convergence case where new == old == 0 darcs-hash:20091112221219-c8de0-04e133b083c9f326593ad295b7309bf931c16bc4.gz --- util/stop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) -- 2.30.2