From 54047c363c3dd8702ac341b012798c40e4d9bac7 Mon Sep 17 00:00:00 2001 From: Joshua Nathaniel Pritikin Date: Fri, 20 Mar 2015 14:12:20 -0400 Subject: [PATCH] Add nlopt_isfinite --- api/general.c | 5 +++++ util/nlopt-util.h | 1 + 2 files changed, 6 insertions(+) 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, -- 2.30.2