summaryrefslogtreecommitdiff
path: root/numpy/core/src/umathmodule.c.src
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-01-13 02:29:56 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-01-13 02:29:56 +0000
commit968dd66df41a74bc3aea2c806705fdf4c52e61ee (patch)
treeae5884f3f17064adf91bad1f289a280c6f917a5e /numpy/core/src/umathmodule.c.src
parent3883205632b3569a8741176b3888ea48485cf188 (diff)
downloadnumpy-968dd66df41a74bc3aea2c806705fdf4c52e61ee.tar.gz
fix up the expm1 and log1p additions.
Diffstat (limited to 'numpy/core/src/umathmodule.c.src')
-rw-r--r--numpy/core/src/umathmodule.c.src109
1 files changed, 81 insertions, 28 deletions
diff --git a/numpy/core/src/umathmodule.c.src b/numpy/core/src/umathmodule.c.src
index 61c73bcad..a2b25983f 100644
--- a/numpy/core/src/umathmodule.c.src
+++ b/numpy/core/src/umathmodule.c.src
@@ -8,7 +8,8 @@
#include <math.h>
-/* A whole slew of basic math functions are provided originally by Konrad Hinsen. */
+/* A whole slew of basic math functions are provided originally
+ by Konrad Hinsen. */
#if !defined(__STDC__) && !defined(_MSC_VER)
extern double fmod (double, double);
@@ -20,31 +21,6 @@ extern double modf (double, double *);
#define M_PI 3.14159265358979323846264338328
#endif
-#ifndef HAVE_LOG1P
-static double log1p(double x)
-{
- double u = 1. + x;
- if (u == 1.0) {
- return x;
- } else {
- return log(u) * x / (u-1.);
- }
-}
-#endif
-
-#ifndef HAVE_EXPM1
-static double expm1(double x)
-{
- double u = exp(x);
- if (u == 1.0) {
- return x;
- } else if (u-1.0 == -1.0) {
- return -1;
- } else {
- return (u-1.0) * x/log(u);
- }
-}
-#endif
#ifndef HAVE_INVERSE_HYPERBOLIC
static double acosh(double x)
@@ -314,8 +290,6 @@ double hypot(double x, double y)
asinh, acosh, atanh
hypot, atan2, pow
-
- log1p, expm1
*/
/**begin repeat
@@ -365,6 +339,85 @@ double hypot(double x, double y)
+#ifndef HAVE_LOG1P
+static double log1p(double x)
+{
+ double u = 1. + x;
+ if (u == 1.0) {
+ return x;
+ } else {
+ return log(u) * x / (u-1.);
+ }
+}
+#endif
+
+#if !defined(HAVE_LOG1P) || !defined(HAVE_LONGDOUBLE_FUNCS)
+static longdouble log1pl(longdouble x)
+{
+ longdouble u = 1. + x;
+ if (u == 1.0) {
+ return x;
+ } else {
+ return logl(u) * x / (u-1.);
+ }
+}
+#endif
+
+#if !defined(HAVE_LOG1P) || !defined(HAVE_FLOAT_FUNCS)
+static float log1pf(float x)
+{
+ float u = 1. + x;
+ if (u == 1.0) {
+ return x;
+ } else {
+ return logf(u) * x / (u-1.);
+ }
+}
+#endif
+
+#ifndef HAVE_EXPM1
+static double expm1(double x)
+{
+ double u = exp(x);
+ if (u == 1.0) {
+ return x;
+ } else if (u-1.0 == -1.0) {
+ return -1;
+ } else {
+ return (u-1.0) * x/log(u);
+ }
+}
+#endif
+
+#if !defined(HAVE_EXPM1) || !defined(HAVE_LONGDOUBLE_FUNCS)
+static longdouble expm1l(longdouble x)
+{
+ longdouble u = expl(x);
+ if (u == 1.0) {
+ return x;
+ } else if (u-1.0 == -1.0) {
+ return -1;
+ } else {
+ return (u-1.0) * x/logl(u);
+ }
+}
+#endif
+
+#if !defined(HAVE_EXPM1) || !defined(HAVE_FLOAT_FUNCS)
+static float expm1f(float x)
+{
+ float u = expf(x);
+ if (u == 1.0) {
+ return x;
+ } else if (u-1.0 == -1.0) {
+ return -1;
+ } else {
+ return (u-1.0) * x/logf(u);
+ }
+}
+#endif
+
+
/* Don't pass structures between functions (only pointers) because how