[Scipy-svn] r5364 - trunk/scipy/fftpack/src

scipy-svn@scip... scipy-svn@scip...
Wed Jan 7 12:23:43 CST 2009


Author: cdavid
Date: 2009-01-07 12:23:33 -0600 (Wed, 07 Jan 2009)
New Revision: 5364

Modified:
   trunk/scipy/fftpack/src/zrfft.c
Log:
Add single precision version of zrfft.

Modified: trunk/scipy/fftpack/src/zrfft.c
===================================================================
--- trunk/scipy/fftpack/src/zrfft.c	2009-01-07 15:53:37 UTC (rev 5363)
+++ trunk/scipy/fftpack/src/zrfft.c	2009-01-07 18:23:33 UTC (rev 5364)
@@ -7,6 +7,7 @@
 #include "fftpack.h"
 
 extern void drfft(double *inout,int n,int direction,int howmany,int normalize);
+extern void rfft(float *inout,int n,int direction,int howmany,int normalize);
 
 extern void zrfft(complex_double *inout,
 		  int n,int direction,int howmany,int normalize) {
@@ -52,3 +53,48 @@
     fprintf(stderr,"zrfft: invalid direction=%d\n",direction);
   }
 }
+
+extern void crfft(complex_float *inout,
+		  int n,int direction,int howmany,int normalize) {
+  int i,j,k;
+  float* ptr = (float *)inout;
+  switch (direction) {
+    case 1:
+      for (i=0;i<howmany;++i,ptr+=2*n) {
+	*(ptr+1) = *ptr;
+	for(j=2,k=3;j<n;++j,++k)
+	  *(ptr+k) = *(ptr+2*j);
+	rfft(ptr+1,n,1,1,normalize);
+	*ptr = *(ptr+1);
+	*(ptr+1) = 0.0;
+	if (!(n%2))
+	  *(ptr+n+1) = 0.0;
+	for(j=2,k=2*n-2;j<n;j+=2,k-=2) {
+	  *(ptr+k) = *(ptr+j);
+	  *(ptr+k+1) = -(*(ptr+j+1));
+	}
+      }
+      break;
+  case -1:
+    for (i=0;i<howmany;++i,ptr+=2*n) {
+      *(ptr+1) = (*ptr);
+      for(j=1,k=2;j<n;++j,++k)
+	*(ptr+k) = (*(ptr+2*j));
+      rfft(ptr+1,n,1,1,normalize);
+      *ptr = *(ptr+1);
+      *(ptr+1) = 0.0;
+      if (!(n%2))
+	*(ptr+n+1) = 0.0;
+      for(j=2,k=2*n-2;j<n;j+=2,k-=2) {
+	float d;
+	*(ptr+k) = *(ptr+j);
+	d = *(ptr+j+1);
+	*(ptr+k+1) = d; 
+	*(ptr+j+1) = -d;
+      }
+    }
+    break;
+  default:
+    fprintf(stderr,"crfft: invalid direction=%d\n",direction);
+  }
+}



More information about the Scipy-svn mailing list