summaryrefslogtreecommitdiff
path: root/math/py-scipy/patches/patch-scipy_special___logit.h
blob: 2073f0dd9577063c8a0718d86c28b8b1b7497139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
$NetBSD: patch-scipy_special___logit.h,v 1.2 2022/05/13 09:49:31 tnn Exp $

py-scipy: work around undefined PLT symbol "log1pl" on NetBSD

--- scipy/special/_logit.h.orig	2022-01-29 22:59:08.000000000 +0000
+++ scipy/special/_logit.h
@@ -31,6 +31,17 @@ inline T _expit(T x) {
 // obtain accurate results (compared to the naive implementation
 // log(expit(x))).
 //
+#if defined(__NetBSD__)
+template <typename T>
+inline T _log_expit(T x) {
+    if (x < 0.0) {
+        return x - std::log(std::exp(x) + 1.0);
+    }
+    else {
+        return -std::log(std::exp(-x) + 1.0);
+    }
+};
+#else
 template <typename T>
 inline T _log_expit(T x) {
     if (x < 0.0) {
@@ -40,6 +51,7 @@ inline T _log_expit(T x) {
         return -std::log1p(std::exp(-x));
     }
 };
+#endif
 
 
 npy_float logitf(npy_float x)  {return _logit(x);};