[Scipy-svn] r4884 - branches/remove_fft_backends/scipy/fftpack/src

scipy-svn@scip... scipy-svn@scip...
Sat Nov 1 09:04:20 CDT 2008


Author: cdavid
Date: 2008-11-01 09:04:16 -0500 (Sat, 01 Nov 2008)
New Revision: 4884

Modified:
   branches/remove_fft_backends/scipy/fftpack/src/convolve.c
Log:
Update convolve C code to PEP-7.

Modified: branches/remove_fft_backends/scipy/fftpack/src/convolve.c
===================================================================
--- branches/remove_fft_backends/scipy/fftpack/src/convolve.c	2008-11-01 14:00:07 UTC (rev 4883)
+++ branches/remove_fft_backends/scipy/fftpack/src/convolve.c	2008-11-01 14:04:16 UTC (rev 4884)
@@ -12,115 +12,120 @@
 #include "fftpack.h"
 
 /**************** FFTPACK ZFFT **********************/
-extern void F_FUNC(dfftf,DFFTF)(int*,double*,double*);
-extern void F_FUNC(dfftb,DFFTB)(int*,double*,double*);
-extern void F_FUNC(dffti,DFFTI)(int*,double*);
-GEN_CACHE(dfftpack,(int n)
-	  ,double* wsave;
-	  ,(caches_dfftpack[i].n==n)
-	  ,caches_dfftpack[id].wsave = (double*)malloc(sizeof(double)*(2*n+15));
-	   F_FUNC(dffti,DFFTI)(&n,caches_dfftpack[id].wsave);
-	  ,free(caches_dfftpack[id].wsave);
-	  ,20)
-extern void destroy_convolve_cache(void) {
-        destroy_dfftpack_caches();
+extern void F_FUNC(dfftf, DFFTF) (int *, double *, double *);
+extern void F_FUNC(dfftb, DFFTB) (int *, double *, double *);
+extern void F_FUNC(dffti, DFFTI) (int *, double *);
+GEN_CACHE(dfftpack, (int n)
+          , double *wsave;, (caches_dfftpack[i].n == n)
+          , caches_dfftpack[id].wsave =
+          (double *) malloc(sizeof(double) * (2 * n + 15));
+          F_FUNC(dffti, DFFTI) (&n, caches_dfftpack[id].wsave);,
+          free(caches_dfftpack[id].wsave);, 20)
+
+extern void destroy_convolve_cache(void)
+{
+    destroy_dfftpack_caches();
 }
 
 /**************** convolve **********************/
-extern
-void convolve(int n,double* inout,double* omega,int swap_real_imag) {
-  int i;
-  double* wsave = NULL;
+extern void
+convolve(int n, double *inout, double *omega, int swap_real_imag)
+{
+    int i;
+    double *wsave = NULL;
 
     i = get_cache_id_dfftpack(n);
     wsave = caches_dfftpack[i].wsave;
-    F_FUNC(dfftf,DFFTF)(&n,inout,wsave);
+    F_FUNC(dfftf, DFFTF) (&n, inout, wsave);
     if (swap_real_imag) {
-      double c;
-      int n1 = n-1;
-      inout[0] *= omega[0];
-      if (!(n%2))
-	inout[n-1] *= omega[n-1];
-      for(i=1;i<n1;i+=2) {
-	c = inout[i] * omega[i];
-	inout[i] = inout[i+1] * omega[i+1];
-	inout[i+1] = c;
-      }
-    }
-    else
-      for(i=0;i<n;++i)
-	inout[i] *= omega[i];
-    F_FUNC(dfftb,DFFTB)(&n,inout,wsave);
+        double c;
+        int n1 = n - 1;
+        inout[0] *= omega[0];
+        if (!(n % 2))
+            inout[n - 1] *= omega[n - 1];
+        for (i = 1; i < n1; i += 2) {
+            c = inout[i] * omega[i];
+            inout[i] = inout[i + 1] * omega[i + 1];
+            inout[i + 1] = c;
+        }
+    } else
+        for (i = 0; i < n; ++i)
+            inout[i] *= omega[i];
+    F_FUNC(dfftb, DFFTB) (&n, inout, wsave);
 }
 
 /**************** convolve **********************/
-extern
-void convolve_z(int n,double* inout,double* omega_real,double* omega_imag) {
-  int i;
-  double* wsave = NULL;
-  {
+extern void
+convolve_z(int n, double *inout, double *omega_real, double *omega_imag)
+{
+    int i;
+    double *wsave = NULL;
     i = get_cache_id_dfftpack(n);
     wsave = caches_dfftpack[i].wsave;
-    F_FUNC(dfftf,DFFTF)(&n,inout,wsave);
+    F_FUNC(dfftf, DFFTF) (&n, inout, wsave);
     {
-      double c;
-      int n1 = n-1;
-      inout[0] *= (omega_real[0]+omega_imag[0]);
-      if (!(n%2))
-	inout[n-1] *= (omega_real[n-1]+omega_imag[n-1]);
-      for(i=1;i<n1;i+=2) {
-	c = inout[i] * omega_imag[i];
-	inout[i] *= omega_real[i];
-	inout[i] += inout[i+1] * omega_imag[i+1];
-	inout[i+1] *= omega_real[i+1];
-	inout[i+1] += c;
-      }
+        double c;
+        int n1 = n - 1;
+        inout[0] *= (omega_real[0] + omega_imag[0]);
+        if (!(n % 2))
+            inout[n - 1] *= (omega_real[n - 1] + omega_imag[n - 1]);
+        for (i = 1; i < n1; i += 2) {
+            c = inout[i] * omega_imag[i];
+            inout[i] *= omega_real[i];
+            inout[i] += inout[i + 1] * omega_imag[i + 1];
+            inout[i + 1] *= omega_real[i + 1];
+            inout[i + 1] += c;
+        }
     }
-    F_FUNC(dfftb,DFFTB)(&n,inout,wsave);
-  }
+    F_FUNC(dfftb, DFFTB) (&n, inout, wsave);
 }
 
-extern
-void init_convolution_kernel(int n,double* omega, int d,
-			     double (*kernel_func)(int),
-			     int zero_nyquist) {
-  /*
-    omega[k] = pow(sqrt(-1),d) * kernel_func(k)
-    omega[0] = kernel_func(0)
-    conjugate(omega[-k]) == omega[k]
-   */
-  {
-    int j,k,l=(n%2?n:n-1);
-    omega[0] = (*kernel_func)(0)/n;
-    switch (d%4) {
-    case 0:
-      for (k=j=1;j<l;j+=2,++k)
-	omega[j] = omega[j+1] = (*kernel_func)(k)/n;
-      if (!(n%2))
-	omega[n-1] = (zero_nyquist?0.0:(*kernel_func)(k)/n);
-      break;
-    case 1:;case -3:
-      for (k=j=1;j<l;j+=2,++k) {
-	omega[j] = (*kernel_func)(k)/n;
-	omega[j+1] = -omega[j];
-      }
-      if (!(n%2))
-	omega[n-1] = (zero_nyquist?0.0:(*kernel_func)(k)/n);
-      break;
-    case 2:;case -2:
-      for (k=j=1;j<l;j+=2,++k)
-	omega[j] = omega[j+1] = -(*kernel_func)(k)/n;
-      if (!(n%2))
-	omega[n-1] = (zero_nyquist?0.0:-(*kernel_func)(k)/n);
-      break;
-    case 3:;case -1:
-      for (k=j=1;j<l;j+=2,++k) {
-	omega[j] = -(*kernel_func)(k)/n;
-	omega[j+1] = -omega[j];
-      }
-      if (!(n%2))
-	omega[n-1] = (zero_nyquist?0.0:-(*kernel_func)(k)/n);
-      break;
+extern void
+init_convolution_kernel(int n, double *omega, int d,
+                        double (*kernel_func) (int), int zero_nyquist)
+{
+    /*
+       omega[k] = pow(sqrt(-1),d) * kernel_func(k)
+       omega[0] = kernel_func(0)
+       conjugate(omega[-k]) == omega[k]
+     */
+    int j, k, l = (n % 2 ? n : n - 1);
+    omega[0] = (*kernel_func) (0) / n;
+    switch (d % 4) {
+        case 0:
+            for (k = j = 1; j < l; j += 2, ++k)
+                omega[j] = omega[j + 1] = (*kernel_func) (k) / n;
+            if (!(n % 2))
+                omega[n - 1] =
+                    (zero_nyquist ? 0.0 : (*kernel_func) (k) / n);
+            break;
+        case 1:;
+        case -3:
+            for (k = j = 1; j < l; j += 2, ++k) {
+                omega[j] = (*kernel_func) (k) / n;
+                omega[j + 1] = -omega[j];
+            }
+            if (!(n % 2))
+                omega[n - 1] =
+                    (zero_nyquist ? 0.0 : (*kernel_func) (k) / n);
+            break;
+        case 2:;
+        case -2:
+            for (k = j = 1; j < l; j += 2, ++k)
+                omega[j] = omega[j + 1] = -(*kernel_func) (k) / n;
+            if (!(n % 2))
+                omega[n - 1] =
+                    (zero_nyquist ? 0.0 : -(*kernel_func) (k) / n);
+            break;
+        case 3:;
+        case -1:
+            for (k = j = 1; j < l; j += 2, ++k) {
+                omega[j] = -(*kernel_func) (k) / n;
+                omega[j + 1] = -omega[j];
+            }
+            if (!(n % 2))
+                omega[n - 1] =
+                    (zero_nyquist ? 0.0 : -(*kernel_func) (k) / n);
+            break;
     }
-  }
 }



More information about the Scipy-svn mailing list