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

scipy-svn@scip... scipy-svn@scip...
Wed Jan 7 08:44:31 CST 2009


Author: cdavid
Date: 2009-01-07 08:44:18 -0600 (Wed, 07 Jan 2009)
New Revision: 5345

Added:
   trunk/scipy/fftpack/src/cfft_fftpack.c
Modified:
   trunk/scipy/fftpack/src/zfft.c
Log:
Add cfft wrapper.

Added: trunk/scipy/fftpack/src/cfft_fftpack.c
===================================================================
--- trunk/scipy/fftpack/src/cfft_fftpack.c	2009-01-07 14:43:52 UTC (rev 5344)
+++ trunk/scipy/fftpack/src/cfft_fftpack.c	2009-01-07 14:44:18 UTC (rev 5345)
@@ -0,0 +1,46 @@
+/* XXX: use the .src mechanism: zfft_cfft are the same */
+extern void F_FUNC(cfftf,CFFTF)(int*,float*,float*);
+extern void F_FUNC(cfftb,CFFTB)(int*,float*,float*);
+extern void F_FUNC(cffti,CFFTI)(int*,float*);
+GEN_CACHE(cfftpack,(int n)
+	  ,float* wsave;
+	  ,(caches_cfftpack[i].n==n)
+	  ,caches_cfftpack[id].wsave = (float*)malloc(sizeof(float)*(4*n+15));
+	   F_FUNC(cffti,CFFTI)(&n,caches_cfftpack[id].wsave);
+	  ,free(caches_cfftpack[id].wsave);
+	  ,10)
+
+static void cfft_fftpack(complex_float * inout,
+			 int n, int direction, int howmany, int normalize)
+{
+	int i;
+	complex_float *ptr = inout;
+	float *wsave = NULL;
+
+	wsave = caches_cfftpack[get_cache_id_cfftpack(n)].wsave;
+
+	switch (direction) {
+	case 1:
+		for (i = 0; i < howmany; ++i, ptr += n) {
+			cfftf_(&n, (float *) (ptr), wsave);
+
+		}
+		break;
+
+	case -1:
+		for (i = 0; i < howmany; ++i, ptr += n) {
+			cfftb_(&n, (float *) (ptr), wsave);
+		}
+		break;
+	default:
+		fprintf(stderr, "cfft: invalid direction=%d\n", direction);
+	}
+
+	if (normalize) {
+		ptr = inout;
+		for (i = n * howmany - 1; i >= 0; --i) {
+			*((float *) (ptr)) /= n;
+			*((float *) (ptr++) + 1) /= n;
+		}
+	}
+}

Modified: trunk/scipy/fftpack/src/zfft.c
===================================================================
--- trunk/scipy/fftpack/src/zfft.c	2009-01-07 14:43:52 UTC (rev 5344)
+++ trunk/scipy/fftpack/src/zfft.c	2009-01-07 14:44:18 UTC (rev 5345)
@@ -18,7 +18,18 @@
         int direction, int howmany, int normalize)\
 {\
         zfft_##name(inout, n, direction, howmany, normalize);\
+}\
+void destroy_cfft_cache(void)\
+{\
+        destroy_c##name##_caches();\
+}\
+\
+void cfft(complex_float *inout, int n, \
+        int direction, int howmany, int normalize)\
+{\
+        cfft_##name(inout, n, direction, howmany, normalize);\
 }
 
 #include "zfft_fftpack.c"
+#include "cfft_fftpack.c"
 GEN_PUBLIC_API(fftpack)



More information about the Scipy-svn mailing list