[copied to the scipy list since rfftfreq is only in scipy] Andrew Jaffe wrote: > Hi all, > > the current implementation of fftfreq (which is meant to return the > appropriate frequencies for an FFT) does the following: > > k = range(0,(n-1)/2+1)+range(-(n/2),0) > return array(k,'d')/(n*d) > > I have tried this with very long (2**24) arrays, and it is ridiculously > slow. Should this instead use arange (or linspace?) and concatenate > rather than converting the above list? This seems to result in > acceptable performance, but we could also perhaps even pre-allocate the > space. > > The numpy.fft.rfftfreq seems just plain incorrect to me. It seems to > produce lots of duplicated frequencies, contrary to the actual output of > rfft: > > def rfftfreq(n,d=1.0): > """ rfftfreq(n, d=1.0) -> f > > DFT sample frequencies (for usage with rfft,irfft). > > The returned float array contains the frequency bins in > cycles/unit (with zero at the start) given a window length n and a > sample spacing d: > > f = [0,1,1,2,2,...,n/2-1,n/2-1,n/2]/(d*n) if n is even > f = [0,1,1,2,2,...,n/2-1,n/2-1,n/2,n/2]/(d*n) if n is odd > > **** None of these should be doubled, right? > > """ > assert isinstance(n,int) > return array(range(1,n+1),dtype=int)/2/float(n*d) > > Thanks, > > Andrew > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion