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

scipy-svn@scip... scipy-svn@scip...
Wed Jan 7 08:45:00 CST 2009


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

Added:
   trunk/scipy/fftpack/src/rfft_fftpack.c
Modified:
   trunk/scipy/fftpack/src/drfft.c
Log:
Add single prec backend for real fft.

Modified: trunk/scipy/fftpack/src/drfft.c
===================================================================
--- trunk/scipy/fftpack/src/drfft.c	2009-01-07 14:44:18 UTC (rev 5345)
+++ trunk/scipy/fftpack/src/drfft.c	2009-01-07 14:44:46 UTC (rev 5346)
@@ -18,7 +18,19 @@
         int direction, int howmany, int normalize)\
 {\
         drfft_##name(inout, n, direction, howmany, normalize);\
+}\
+void destroy_rfft_cache(void)\
+{\
+        destroy_r##name##_caches();\
+}\
+\
+void rfft(float *inout, int n, \
+        int direction, int howmany, int normalize)\
+{\
+        rfft_##name(inout, n, direction, howmany, normalize);\
 }
 
+
 #include "drfft_fftpack.c"
+#include "rfft_fftpack.c"
 GEN_PUBLIC_API(fftpack)

Added: trunk/scipy/fftpack/src/rfft_fftpack.c
===================================================================
--- trunk/scipy/fftpack/src/rfft_fftpack.c	2009-01-07 14:44:18 UTC (rev 5345)
+++ trunk/scipy/fftpack/src/rfft_fftpack.c	2009-01-07 14:44:46 UTC (rev 5346)
@@ -0,0 +1,54 @@
+/*
+ * Last Change: Wed Aug 01 07:00 PM 2007 J
+ *
+ * FFTPACK implementation
+ *
+ * Original code by Pearu Peterson.
+ */
+
+extern void F_FUNC(rfftf, RFFTF) (int *, float *, float *);
+extern void F_FUNC(rfftb, RFFTB) (int *, float *, float *);
+extern void F_FUNC(rffti, RFFTI) (int *, float *);
+GEN_CACHE(rfftpack, (int n)
+	  , float *wsave;
+	  , (caches_rfftpack[i].n == n)
+	  , caches_rfftpack[id].wsave =
+	  (float *) malloc(sizeof(float) * (2 * n + 15));
+	  F_FUNC(rffti, RFFTI) (&n, caches_rfftpack[id].wsave);
+	  , free(caches_rfftpack[id].wsave);
+	  , 10)
+
+static void rfft_fftpack(float *inout, int n, int direction, int howmany,
+			 int normalize)
+{
+    int i;
+    float *ptr = inout;
+    float *wsave = NULL;
+    wsave = caches_rfftpack[get_cache_id_rfftpack(n)].wsave;
+
+
+    switch (direction) {
+        case 1:
+        for (i = 0; i < howmany; ++i, ptr += n) {
+            rfftf_(&n, ptr, wsave);
+        }
+        break;
+
+    case -1:
+        for (i = 0; i < howmany; ++i, ptr += n) {
+            rfftb_(&n, ptr, wsave);
+        }
+        break;
+
+    default:
+        fprintf(stderr, "rfft: invalid direction=%d\n", direction);
+    }
+
+    if (normalize) {
+        float d = 1.0 / n;
+        ptr = inout;
+        for (i = n * howmany - 1; i >= 0; --i) {
+            (*(ptr++)) *= d;
+        }
+    }
+}



More information about the Scipy-svn mailing list