about summary refs log tree commit diff
path: root/src/math/tgamma.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/tgamma.c')
-rw-r--r--src/math/tgamma.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/math/tgamma.c b/src/math/tgamma.c
new file mode 100644
index 00000000..f3bbe370
--- /dev/null
+++ b/src/math/tgamma.c
@@ -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;
+}