I use the following code to get an RFT of an 8 byte complex data array. sPadding=1 in this case. typedef struct Complex_Struct { float fReal; float fImaginary; } Complex; ERROR_NUMBER CMyLib::FFTWMake1DInverseFourierTransform(Complex *cpInputVector, float **fppOutputVector, DWORD dwVectorLength, short sPadding) { fftw_complex *in, *out; fftw_plan p; size_t stNumElements=dwVectorLength*sPadding; size_t iInc; if (dwVectorLength<1 || sPadding<1) return ERROR_PARAMETERS; if (!(in = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * stNumElements)) || !(out = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * stNumElements))) { // Error handling } // Create plan. if (!(p = fftw_plan_dft_1d((int)stNumElements, in, out, FFTW_BACKWARD, FFTW_EXHAUSTIVE))) { // Error handling } // Initialise input elements to zero if required if (sPadding>1) { for (iInc=dwVectorLength; iInc<stNumElements; ++iInc) in[iInc] [0]=in[iInc][1]=0; } for (iInc=0; iInc<dwVectorLength; ++iInc) { in[iInc][0]=cpInputVector[iInc].fReal; in[iInc++][1]=cpInputVector[iInc].fImaginary; } // Do FFT. fftw_execute(p); // repeat as needed // Free input fftw_complex vector fftw_destroy_plan(p); fftw_free(in); // Allocate memory to function output if (!(*fppOutputVector=(float *)malloc(stNumElements*sizeof(float)))) { // Error handling } // Copy fftw_complex out vector into function output vector for (iInc=0; iInc<stNumElements; ++iInc) { (*fppOutputVector)[iInc]=(float)(out[iInc][0]); } // Etc. } I get the following output. out[0][0] 1636200805.3022504 double out[1][0] -3.7190885739783542e-007 double out[2][0] 1635147705.0245562 double out[3][0] -2.0041953678394723e-007 double out[4][0] 1634009932.1876054 double out[5][0] -3.1898067317028498e-007 double It would appear that the even numbered elements are what I might expect but the odd numbered elements are wrong. Any assistance would be greatly appreciated. Many thanks in advance, Peter.
FFTW_BACKWARD: Every other element looks bad
Started by ●May 7, 2007