chiark / gitweb /
move definition of util functions
authorAmro <amroamroamro@gmail.com>
Fri, 29 Jul 2016 12:23:23 +0000 (15:23 +0300)
committerAmro <amroamroamro@gmail.com>
Tue, 13 Sep 2016 18:24:30 +0000 (21:24 +0300)
api/general.c
util/stop.c

index dc2fb3818323b232f58ca2358ff4d085fe66abf7..26af0d3b2576c2c4a6edd0cb59a57a3092f47d1e 100644 (file)
  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
  */
 
-#include <math.h>
-#include <float.h>
-
 #include "nlopt-internal.h"
 
 /*************************************************************************/
 
-int nlopt_isinf(double x) {
-     return fabs(x) >= HUGE_VAL * 0.99
-#ifdef HAVE_ISINF
-         || isinf(x)
-#endif
-         ;
-}
-
-int nlopt_isfinite(double x) {
-    return fabs(x) <= DBL_MAX;
-}
-
-int nlopt_istiny(double x)
-{
-#if defined(HAVE_FPCLASSIFY)
-    return x == 0.0 || fpclassify(x) == FP_SUBNORMAL;
-#elif defined(_WIN32)
-    if (x == 0.0)
-        return 1;
-    else {
-        int c = _fpclass(x);
-        return c == _FPCLASS_ND || c == _FPCLASS_PD;
-    }
-#else
-    return fabs(x) < 2.2250738585072014e-308; /* assume IEEE 754 double */
-#endif
-}
-
-int nlopt_isnan(double x)
-{
-#if defined(HAVE_ISNAN)
-    return isnan(x);
-#elif defined(_WIN32)
-    return _isnan(x);
-#else
-    return x != x; /* might fail with aggressive optimization */
-#endif
-}
-
-/*************************************************************************/
-
 void NLOPT_STDCALL nlopt_version(int *major, int *minor, int *bugfix)
 {
      *major = MAJOR_VERSION;
index 0eeed3ddb8ddd6b636f9b7e5c249b55449b8d492..3cfb8d264a2e84ca21a327abbd6a5054bbe1e071 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <math.h>
+#include <float.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdarg.h>
@@ -163,3 +164,46 @@ void nlopt_stop_msg(const nlopt_stopping *s, const char *format, ...)
         va_end(ap);
     }
 }
+
+/*************************************************************************/
+
+int nlopt_isinf(double x)
+{
+    return (fabs(x) >= HUGE_VAL * 0.99)
+#ifdef HAVE_ISINF
+        || isinf(x)
+#endif
+    ;
+}
+
+int nlopt_isfinite(double x)
+{
+    return (fabs(x) <= DBL_MAX);
+}
+
+int nlopt_istiny(double x)
+{
+#if defined(HAVE_FPCLASSIFY)
+    return x == 0.0 || fpclassify(x) == FP_SUBNORMAL;
+#elif defined(_WIN32)
+    if (x == 0.0)
+        return 1;
+    else {
+        int c = _fpclass(x);
+        return c == _FPCLASS_ND || c == _FPCLASS_PD;
+    }
+#else
+    return fabs(x) < 2.2250738585072014e-308; /* assume IEEE 754 double */
+#endif
+}
+
+int nlopt_isnan(double x)
+{
+#if defined(HAVE_ISNAN)
+    return isnan(x);
+#elif defined(_WIN32)
+    return _isnan(x);
+#else
+    return (x != x); /* might fail with aggressive optimization */
+#endif
+}