On 9/7/06, Andrew Jaffe <[EMAIL PROTECTED]> wrote:
Hi all,

It seems that scipy and numpy define rfft differently.

numpy returns n/2+1 complex numbers (so the first and last numbers are
actually real) with the frequencies equivalent to the positive part of
the fftfreq, whereas scipy returns n real numbers with the frequencies
as in rfftfreq (i.e., two real numbers at the same frequency, except for
the highest and lowest) [All of the above for even n; but the difference
between numpy and scipy remains for odd n.]

I think the numpy behavior makes more sense, as it doesn't require any
unpacking after the fact, at the expense of a tiny amount of wasted
space. But would this in fact require scipy doing extra work from
whatever the 'native' real_fft (fftw, I assume) produces?

Anyone else have an opinion?

Yes, I prefer the scipy version because the result is actually a complex array and can immediately be use as the coefficients of the fft for frequencies <= Nyquist. I suspect, without checking, that what you get in numpy is a real array with f[0] == zero frequency, f[1] + 1j* f[2] as the coefficient of the second frequency, etc. This makes it difficult to multiply by a complex transfer function or phase shift the result to rotate the original points by some fractional amount.

As to unpacking, for some algorithms the two real coefficients are packed into the real and complex parts of the zero frequency so all that is needed is an extra complex slot at the end. Other algorithms produce what you describe. I just think it is more convenient to think of the real fft as an efficient complex fft that only computes the coefficients <= Nyquist because Hermitean symmetry determines the rest.

Chuck

-------------------------------------------------------------------------
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

Reply via email to