summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorEric Moore <ewm@redtetrahedron.org>2016-01-08 17:31:07 -0500
committerEric Moore <ewm@redtetrahedron.org>2016-01-08 17:33:29 -0500
commit3af3753f8f518c8ea542511f8a117508b12e2802 (patch)
tree29d17b9d5d124ff6e2286d5e5124d901776aefc3 /numpy/core/src
parent8a76291c76aa9b33b18ceb06f6e8f37f990c9e27 (diff)
downloadnumpy-3af3753f8f518c8ea542511f8a117508b12e2802.tar.gz
BUG: npy_acosh fallback too simple.
Fixes gh-6712.
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/npymath/npy_math.c.src15
1 files changed, 14 insertions, 1 deletions
diff --git a/numpy/core/src/npymath/npy_math.c.src b/numpy/core/src/npymath/npy_math.c.src
index 32fa41788..4dcb01986 100644
--- a/numpy/core/src/npymath/npy_math.c.src
+++ b/numpy/core/src/npymath/npy_math.c.src
@@ -221,7 +221,20 @@ double npy_hypot(double x, double y)
#ifndef HAVE_ACOSH
double npy_acosh(double x)
{
- return 2*npy_log(npy_sqrt((x + 1.0)/2) + npy_sqrt((x - 1.0)/2));
+ if (x < 1.0) {
+ return NPY_NAN;
+ }
+
+ if (npy_isfinite(x)) {
+ if (x > 1e8) {
+ return npy_log(x) + NPY_LOGE2;
+ }
+ else {
+ double u = x - 1.0;
+ return npy_log1p(u + npy_sqrt(2*u + u*u));
+ }
+ }
+ return x;
}
#endif