[PD-cvs] pd/src builtins_dsp.c,1.1.2.29,1.1.2.30

Mathieu Bouchard matju at users.sourceforge.net
Thu Jul 19 21:35:22 CEST 2007


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9793

Modified Files:
      Tag: desiredata
	builtins_dsp.c 
Log Message:
interleaved code of square root classes


Index: builtins_dsp.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/builtins_dsp.c,v
retrieving revision 1.1.2.29
retrieving revision 1.1.2.30
diff -C2 -d -r1.1.2.29 -r1.1.2.30
*** builtins_dsp.c	19 Jul 2007 19:23:20 -0000	1.1.2.29
--- builtins_dsp.c	19 Jul 2007 19:35:19 -0000	1.1.2.30
***************
*** 3221,3224 ****
--- 3221,3225 ----
  
  /* sigrsqrt - reciprocal square root good to 8 mantissa bits  */
+ /* sigsqrt -  square root good to 8 mantissa bits  */
  
  #define DUMTAB1SIZE 256
***************
*** 3241,3261 ****
      long l = *(long *)(&f);
      if (f < 0) return 0;
!     else return rsqrt_exptab[(l >> 23) & 0xff] *
!            rsqrt_mantissatab[(l >> 13) & 0x3ff];
  }
  float q8_sqrt(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
! float qsqrt(float f)  {return q8_sqrt(f);}
  float qrsqrt(float f) {return q8_rsqrt(f);}
  #endif
! struct t_sigrsqrt : t_object {float a;};
! static t_class *sigrsqrt_class;
  static void *sigrsqrt_new() {
      t_sigrsqrt *x = (t_sigrsqrt *)pd_new(sigrsqrt_class);
--- 3242,3262 ----
      long l = *(long *)(&f);
      if (f < 0) return 0;
!     return rsqrt_exptab[(l >> 23) & 0xff] *
!       rsqrt_mantissatab[(l >> 13) & 0x3ff];
  }
  float q8_sqrt(float f) {
      long l = *(long *)(&f);
      if (f < 0) return 0;
!     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
! float  qsqrt(float f) {return  q8_sqrt(f);}
  float qrsqrt(float f) {return q8_rsqrt(f);}
  #endif
! static t_class *sigrsqrt_class; struct t_sigrsqrt : t_object {float a;};
! static t_class * sigsqrt_class; struct  t_sigsqrt : t_object {float a;};
  static void *sigrsqrt_new() {
      t_sigrsqrt *x = (t_sigrsqrt *)pd_new(sigrsqrt_class);
***************
*** 3264,3267 ****
--- 3265,3275 ----
      return x;
  }
+ static void *sigsqrt_new() {
+     t_sigsqrt *x = (t_sigsqrt *)pd_new(sigsqrt_class);
+     outlet_new(x, &s_signal);
+     x->a = 0;
+     return x;
+ }
+ 
  static t_int *sigrsqrt_perform(t_int *w) {
      float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2);
***************
*** 3279,3305 ****
      return w+4;
  }
- static void sigrsqrt_dsp(t_sigrsqrt *x, t_signal **sp) {
-     if(SIMD_CHECK2(sp[0]->n,sp[0]->v,sp[1]->v))
- 	 dsp_add(sigrsqrt_perf_simd, 3, sp[0]->v, sp[1]->v, sp[0]->n);
-     else dsp_add(sigrsqrt_perform, 3, sp[0]->v, sp[1]->v, sp[0]->n);
- }
- void sigrsqrt_setup() {
-     init_rsqrt();
-     sigrsqrt_class = class_new2("rsqrt~",sigrsqrt_new,0,sizeof(t_sigrsqrt),0,"");
-     /* an old name for it: */
-     class_addcreator2("q8_rsqrt~",sigrsqrt_new,"");
-     CLASS_MAINSIGNALIN(sigrsqrt_class, t_sigrsqrt, a);
-     class_addmethod2(sigrsqrt_class, sigrsqrt_dsp, "dsp","");
- }
- 
- /* sigsqrt -  square root good to 8 mantissa bits  */
- struct t_sigsqrt : t_object {float a;};
- static t_class *sigsqrt_class;
- static void *sigsqrt_new() {
-     t_sigsqrt *x = (t_sigsqrt *)pd_new(sigsqrt_class);
-     outlet_new(x, &s_signal);
-     x->a = 0;
-     return x;
- }
  /* not static; also used in d_fft.c */
  t_int *sigsqrt_perform(t_int *w) {
--- 3287,3290 ----
***************
*** 3318,3321 ****
--- 3303,3312 ----
      return w+4;
  }
+ 
+ static void sigrsqrt_dsp(t_sigrsqrt *x, t_signal **sp) {
+     if(SIMD_CHECK2(sp[0]->n,sp[0]->v,sp[1]->v))
+ 	 dsp_add(sigrsqrt_perf_simd, 3, sp[0]->v, sp[1]->v, sp[0]->n);
+     else dsp_add(sigrsqrt_perform,   3, sp[0]->v, sp[1]->v, sp[0]->n);
+ }
  static void sigsqrt_dsp(t_sigsqrt *x, t_signal **sp) {
      if(SIMD_CHECK2(sp[0]->n,sp[0]->v,sp[1]->v))
***************
*** 3323,3331 ****
      else dsp_add(sigsqrt_perform,   3, sp[0]->v, sp[1]->v, sp[0]->n);
  }
  void sigsqrt_setup() {
!     sigsqrt_class = class_new2("sqrt~",sigsqrt_new,0,sizeof(t_sigsqrt),0,"");
!     class_addcreator2("q8_sqrt~",sigsqrt_new,""); /* old name */
!     CLASS_MAINSIGNALIN(sigsqrt_class, t_sigsqrt, a);
!     class_addmethod2(sigsqrt_class, sigsqrt_dsp, "dsp","");
  }
  
--- 3314,3328 ----
      else dsp_add(sigsqrt_perform,   3, sp[0]->v, sp[1]->v, sp[0]->n);
  }
+ 
  void sigsqrt_setup() {
!     init_rsqrt();
!     sigrsqrt_class = class_new2("rsqrt~",sigrsqrt_new,0,sizeof(t_sigrsqrt),0,"");
!     sigsqrt_class  = class_new2( "sqrt~", sigsqrt_new,0, sizeof(t_sigsqrt),0,"");
!     CLASS_MAINSIGNALIN(sigrsqrt_class,t_sigrsqrt,a);
!     CLASS_MAINSIGNALIN( sigsqrt_class, t_sigsqrt,a);
!     class_addmethod2( sigsqrt_class, sigsqrt_dsp,"dsp","");
!     class_addmethod2(sigrsqrt_class,sigrsqrt_dsp,"dsp","");
!     class_addcreator2("q8_rsqrt~",sigrsqrt_new,"");
!     class_addcreator2("q8_sqrt~",  sigsqrt_new,"");
  }
  
***************
*** 3862,3866 ****
  
      clip_setup();
-     sigrsqrt_setup();
      sigsqrt_setup();
      sigwrap_setup();
--- 3859,3862 ----





More information about the Pd-cvs mailing list