[Numpy-svn] r4834 - trunk/numpy/fft

numpy-svn@scip... numpy-svn@scip...
Thu Feb 28 10:07:59 CST 2008


Author: oliphant
Date: 2008-02-28 10:07:59 -0600 (Thu, 28 Feb 2008)
New Revision: 4834

Modified:
   trunk/numpy/fft/helper.py
Log:
Try to speed up fftfreq a bit.

Modified: trunk/numpy/fft/helper.py
===================================================================
--- trunk/numpy/fft/helper.py	2008-02-28 07:06:24 UTC (rev 4833)
+++ trunk/numpy/fft/helper.py	2008-02-28 16:07:59 UTC (rev 4834)
@@ -6,8 +6,7 @@
 __all__ = ['fftshift','ifftshift','fftfreq']
 
 from numpy.core import asarray, concatenate, arange, take, \
-    integer
-from numpy import hstack
+    integer, empty
 import types
 
 def fftshift(x,axes=None):
@@ -63,4 +62,12 @@
       f = [0,1,...,(n-1)/2,-(n-1)/2,...,-1]/(d*n)   if n is odd
     """
     assert isinstance(n,types.IntType) or isinstance(n, integer)
-    return hstack((arange(0,(n-1)/2 + 1), arange(-(n/2),0))) / (n*d)
+    val = 1.0/(n*d)
+    results = empty(n, int)
+    N = (n-1)//2 + 1
+    p1 = arange(0,N,dtype=int)
+    results[:N] = p1
+    p2 = arange(-(n//2),0,dtype=int)
+    results[N:] = p2
+    return results * val
+    #return hstack((arange(0,(n-1)/2 + 1), arange(-(n/2),0))) / (n*d)



More information about the Numpy-svn mailing list