Fftw interface with complex.h in c

I use this code to create a 2D array having a complex data type (from complex.h to c). Then I want to find the fft of this array in place. However, it gives a segmentation error, which, I fear, is due to the casting of the pointer incorrectly. How do we use the complex data type for fftw?

//a is a 2d array of size blockSize*NO_INPUTS

complex float* a=(complex float*)malloc(sizeof(complex float)*NO_INPUTS*blockSize);

//****** Put data in a*******//
//blah//
//blah//

//a has data now//

fftw_plan p;
p=fftw_plan_dft_2d(blockSize,NO_INPUTS,(fftw_complex*)a,(fftw_complex*)a,FFTW_FORWARD,FFTW_ESTIMATE);

fftw_execute(p);

fftw_destroy_plan(p);

Note that I do not want to use fftw_complex or fftw_malloc. Thank.

+3
source share
2 answers

fftw_complexequivalent complex doubleyou use complex float. This is probably the source of segfault.

Try to turn complex.hup fftw3.h, you do not need to do any casting.

http://www.fftw.org/fftw3_doc/Complex-numbers.html

+3
source

FFTW . - float double. , , complex float , fftw, . fftw fftw fftwf. fftw_plan fftwf_plan. fftw3f fftw3.

+1

All Articles