From 65a9afa3bf17ba83670acc3fee4f18ea8efb5402 Mon Sep 17 00:00:00 2001 From: musil Date: Fri, 6 Mar 2015 17:47:38 +0000 Subject: update sqrt algo to millers exported q8_sqrt svn path=/trunk/externals/iem/iem_spec2/; revision=17435 --- src/spec2_sqrt~.c | 60 ++++++++++++------------------------------------------- 1 file changed, 13 insertions(+), 47 deletions(-) (limited to 'src/spec2_sqrt~.c') diff --git a/src/spec2_sqrt~.c b/src/spec2_sqrt~.c index 275b9b0..6f25ee1 100644 --- a/src/spec2_sqrt~.c +++ b/src/spec2_sqrt~.c @@ -11,34 +11,6 @@ iem_spec2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 200 static t_class *spec2_sqrt_tilde_class; -#define SPEC2DUMTAB1SIZE 256 -#define SPEC2DUMTAB2SIZE 1024 - -static t_float spec2_rsqrt_exptab[SPEC2DUMTAB1SIZE], spec2_rsqrt_mantissatab[SPEC2DUMTAB2SIZE]; - -static void init_spec2_rsqrt(void) -{ -#ifndef __x86_64__ - int i; - - for (i=0; i 0 || PD_MINOR_VERSION > 43)) + t_float g = q8_rsqrt(f); + + *out++ = f*g*(1.5 - 0.5 * g * g * f); #else - t_float f = *in; - long l = *(long *)(in++); - - if(f < 0.0f) - *out++ = 0.0f; - else - { - t_float g = spec2_rsqrt_exptab[(l >> 23) & 0xff] * spec2_rsqrt_mantissatab[(l >> 13) & 0x3ff]; - - *out++ = f*g*(1.5f - 0.5f*g*g*f); - } + *out++ = sqrt(f); #endif + } } return(w+4); } @@ -95,10 +63,8 @@ static void *spec2_sqrt_tilde_new(void) void spec2_sqrt_tilde_setup(void) { - init_spec2_rsqrt(); spec2_sqrt_tilde_class = class_new(gensym("spec2_sqrt~"), (t_newmethod)spec2_sqrt_tilde_new, 0, sizeof(t_spec2_sqrt_tilde), 0, 0); CLASS_MAINSIGNALIN(spec2_sqrt_tilde_class, t_spec2_sqrt_tilde, x_msi); class_addmethod(spec2_sqrt_tilde_class, (t_method)spec2_sqrt_tilde_dsp, gensym("dsp"), 0); -// class_sethelpsymbol(spec2_sqrt_tilde_class, gensym("iemhelp2/spec2_sqrt~-help")); } -- cgit v1.2.1