summaryrefslogtreecommitdiff
path: root/silx/math/include
diff options
context:
space:
mode:
authorPicca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>2018-07-31 16:22:25 +0200
committerPicca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>2018-07-31 16:22:25 +0200
commit159ef14fb9e198bb0066ea14e6b980f065de63dd (patch)
treebc37c7d4ba09ee59deb708897fa0571709aec293 /silx/math/include
parent270d5ddc31c26b62379e3caa9044dd75ccc71847 (diff)
New upstream version 0.8.0+dfsg
Diffstat (limited to 'silx/math/include')
-rw-r--r--silx/math/include/math_compatibility.h (renamed from silx/math/include/isnan.h)24
1 files changed, 18 insertions, 6 deletions
diff --git a/silx/math/include/isnan.h b/silx/math/include/math_compatibility.h
index 1b9a069..3d69c0c 100644
--- a/silx/math/include/isnan.h
+++ b/silx/math/include/math_compatibility.h
@@ -1,6 +1,6 @@
# /*##########################################################################
#
-# Copyright (c) 2017 European Synchrotron Radiation Facility
+# Copyright (c) 2017-2018 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -21,21 +21,33 @@
# THE SOFTWARE.
#
# ###########################################################################*/
-/* This header provides isnan and isfinite functions across platforms.
+/* This header provides libc math functions and macros across platforms.
- VisualStudio 2008 (i.e., Python2.7) provides _isnan and _finite functions.
+ Needed as VisualStudio 2008 (i.e., Python2.7) is missing some functions/macros.
*/
-#ifndef __ISNAN_H__
-#define __ISNAN_H__
+#ifndef __MATH_COMPATIBILITY_H__
+#define __MATH_COMPATIBILITY_H__
#include <math.h>
+#ifndef INFINITY
+#define INFINITY (DBL_MAX+DBL_MAX)
+#endif
+
+#ifndef NAN
+#define NAN (INFINITY-INFINITY)
+#endif
+
#if (defined (_MSC_VER) && _MSC_VER < 1800)
#include <float.h>
+/* Make sure asinh returns -inf rather than NaN for v=-inf */
+#define asinh(v) (v == -INFINITY ? v : log((v) + sqrt((v)*(v) + 1)))
+
#define isnan(v) _isnan(v)
#define isfinite(v) _finite(v)
+#define lrint(v) ((long int) (v))
#endif
-#endif /*__ISNAN_H__*/
+#endif /*__MATH_COMPATIBILITY_H__*/