math: add dummy tgamma and tgammaf implementations
authornsz <nsz@port70.net>
Tue, 27 Mar 2012 20:17:36 +0000 (22:17 +0200)
committernsz <nsz@port70.net>
Tue, 27 Mar 2012 20:17:36 +0000 (22:17 +0200)
src/math/tgamma.c [new file with mode: 0644]
src/math/tgammaf.c [new file with mode: 0644]

diff --git a/src/math/tgamma.c b/src/math/tgamma.c
new file mode 100644 (file)
index 0000000..f3bbe37
--- /dev/null
@@ -0,0 +1,16 @@
+#include <math.h>
+
+// FIXME: use lanczos approximation
+
+double __lgamma_r(double, int *);
+
+double tgamma(double x)
+{
+       int sign;
+       double y;
+
+       y = exp(__lgamma_r(x, &sign));
+       if (sign < 0)
+               y = -y;
+       return y;
+}
diff --git a/src/math/tgammaf.c b/src/math/tgammaf.c
new file mode 100644 (file)
index 0000000..16df807
--- /dev/null
@@ -0,0 +1,16 @@
+#include <math.h>
+
+// FIXME: use lanczos approximation
+
+float __lgammaf_r(float, int *);
+
+float tgammaf(float x)
+{
+       int sign;
+       float y;
+
+       y = exp(__lgammaf_r(x, &sign));
+       if (sign < 0)
+               y = -y;
+       return y;
+}