How to get complex64 output from numpy.fft?

I have the following code:

Ga=rfft2(A)

      

A

is a type float32

, but Ga

appears as complex128

, effectively doubling my data. How can I get the data complex64

? Surely this is not standard functionality for fftw

?

+3


source to share


1 answer


Well, it looks like the type is defined quite deeply in the C code. Fftpack_litemodule.c uses NPY_CDOUBLE

as an array type, and it's basically yours complex128

. The only solution I can see is to convert the array to complex64

using, astype(np.complex64)

or use the scipy.fftpack package , which returns an array from float64

encoding complex values ​​as:



[y(0),Re(y(1)),Im(y(1)),...,Re(y(n/2))]              if n is even
[y(0),Re(y(1)),Im(y(1)),...,Re(y(n/2)),Im(y(n/2))]   if n is odd

      

+2


source







All Articles