I have the following code:
Ga=rfft2(A)
A
is type float32
, but Ga
comes out as complex128
effectively doubling my data. How can I get out complex64
data? Certainly this isn't the default functionality for fftw
?
Well, it seems that the type is defined quite deep in the C code. fftpack_litemodule.c uses NPY_CDOUBLE
as the array type and that is basically your complex128
. The only solution that I see is to transform the array to complex64
using astype(np.complex64)
or to use the scipy.fftpack package which returns an array of float64
encoding the 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.