summaryrefslogtreecommitdiff
path: root/numpy/fft/helper.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2008-02-28 16:07:59 +0000
committerTravis Oliphant <oliphant@enthought.com>2008-02-28 16:07:59 +0000
commit75b86e12526899cda4e901db9fb951e57d118b6e (patch)
treea4d0e331db44eaa2329f02b1124af781700153de /numpy/fft/helper.py
parent3cbfb32167361a681ab1d7cad8305b528ee92c81 (diff)
downloadnumpy-75b86e12526899cda4e901db9fb951e57d118b6e.tar.gz
Try to speed up fftfreq a bit.
Diffstat (limited to 'numpy/fft/helper.py')
-rw-r--r--numpy/fft/helper.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/numpy/fft/helper.py b/numpy/fft/helper.py
index 17a4a24dc..74f4e363b 100644
--- a/numpy/fft/helper.py
+++ b/numpy/fft/helper.py
@@ -6,8 +6,7 @@ Discrete Fourier Transforms - helper.py
__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 @@ def fftfreq(n,d=1.0):
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)