aboutsummaryrefslogtreecommitdiff
path: root/externals/vanilla/d_math.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2009-11-10 01:47:02 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2009-11-10 01:47:02 +0000
commit386b0b74b0133acb7caddc0f31f5ebbf255efc00 (patch)
treef922b267aa3fc030b29e3d27901e56e205a86839 /externals/vanilla/d_math.c
parent5bdf08d2c08687f7e13c69d3405f7ff110759bca (diff)
split out d_math.c into standalone objects
svn path=/trunk/; revision=12736
Diffstat (limited to 'externals/vanilla/d_math.c')
-rw-r--r--externals/vanilla/d_math.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/externals/vanilla/d_math.c b/externals/vanilla/d_math.c
new file mode 100644
index 00000000..10f27cfe
--- /dev/null
+++ b/externals/vanilla/d_math.c
@@ -0,0 +1,34 @@
+/* Copyright (c) 1997-2001 Miller Puckette and others.
+* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* mathematical functions and other transfer functions, including tilde
+ versions of stuff from x_acoustics.c.
+*/
+
+#include "d_math.h"
+
+ /* these are used in externs like "bonk" */
+
+t_float q8_rsqrt(t_float f)
+{
+ long l = *(long *)(&f);
+ if (f < 0) return (0);
+ else return (rsqrt_exptab[(l >> 23) & 0xff] *
+ rsqrt_mantissatab[(l >> 13) & 0x3ff]);
+}
+
+t_float q8_sqrt(t_float f)
+{
+ long l = *(long *)(&f);
+ if (f < 0) return (0);
+ else return (f * rsqrt_exptab[(l >> 23) & 0xff] *
+ rsqrt_mantissatab[(l >> 13) & 0x3ff]);
+}
+
+ /* the old names are OK unless we're in IRIX N32 */
+
+#ifndef N32
+t_float qsqrt(t_float f) {return (q8_sqrt(f)); }
+t_float qrsqrt(t_float f) {return (q8_rsqrt(f)); }
+#endif