From: Joshua Nathaniel Pritikin Date: Fri, 20 Mar 2015 18:12:20 +0000 (-0400) Subject: Add nlopt_isfinite X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=54047c363c3dd8702ac341b012798c40e4d9bac7;p=nlopt.git Add nlopt_isfinite --- diff --git a/api/general.c b/api/general.c index d97fcb5..dfe2010 100644 --- a/api/general.c +++ b/api/general.c @@ -34,6 +34,11 @@ int nlopt_isinf(double x) { #endif ; } + +int nlopt_isfinite(double x) { + return fabs(x) <= DBL_MAX; +} + /*************************************************************************/ void NLOPT_STDCALL nlopt_version(int *major, int *minor, int *bugfix) diff --git a/util/nlopt-util.h b/util/nlopt-util.h index f460c2d..d20a8b1 100644 --- a/util/nlopt-util.h +++ b/util/nlopt-util.h @@ -46,6 +46,7 @@ extern "C" #endif /* __cplusplus */ int nlopt_isinf(double x); +int nlopt_isfinite(double x); /* re-entrant qsort */ extern void nlopt_qsort_r(void *base_, size_t nmemb, size_t size, void *thunk,