Hi, In the following program, I use the "func_basic_FFT()" tu compute the fft of vector [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]. Now I want to use the "func_advanced_fft()" to compute a array (including four vectors) 's fft. The array is displayed as follows: Assume four vectors are A,B,C,D, and the array is [ A[0],B[0],C[0],D[0],A[1],B[1],C[1],D[1],... A[15],B[15],C[15],D [15] ] But the result is wrong. I couldn't find the reason... ================================================ #include <stdlib.h> #include <stdio.h> #include "fftw3.h" #define N1 16 #define N2 4 int func_advanced_FFT(); int func_basic_FFT(); int main() { func_basic_FFT(); func_advanced_FFT(); return 0; } int func_basic_FFT() { fftwf_complex * dataIn = (fftwf_complex *) fftwf_malloc(sizeof (fftwf_complex)*N1); fftwf_complex * dataOut = (fftwf_complex *) fftwf_malloc(sizeof (fftwf_complex)*N1); printf("********** Basic FFTW **********\nInputData :\n"); for (int i=0;i<N1;i++) { dataIn[i][0] = (float)i; dataIn[i][1] = 0; printf ("%5.2f + i * %5.2f ",dataIn[i][0],dataIn[i][1]); } fftwf_plan plan = fftwf_plan_dft_1d (N1,dataIn,dataOut,FFTW_FORWARD,FFTW_MEASURE); fftwf_execute(plan); printf("\nOutputData :\n"); for (i=0;i<N1;i++) { printf ("%6.2f + i*%6.2f ",dataOut[i][0],dataOut[i][1]); } fftwf_free(dataIn); fftwf_free(dataOut); fftwf_destroy_plan(plan); return 0; } int func_advanced_FFT() { fftwf_complex * dataIn = (fftwf_complex *) fftwf_malloc(sizeof (fftwf_complex)*N1*N2); fftwf_complex * dataOut = (fftwf_complex *) fftwf_malloc(sizeof (fftwf_complex)*N1*N2); printf("\n********** Advanced FFTW ***********\nInputData :\n"); for (int i=0;i<N1*N2;i++) { dataIn[i][0] = (float)(i/N2); dataIn[i][1] = 0; printf ("%5.2f + i * %5.2f ",dataIn[i][0],dataIn[i][1]); } int rank = 1; // dimensionality int * n = new int[1]; n[0] = N1; // the length of each vector int howmany = N2; // the number of transforms int stride = N2; // stride int dist = 1; // starting at dataIn+k*dist and dataOut +k*dist. // int * nembed = new int [1]; // @@ // nembed[0]=N1*N2; /* fftwf_plan plan = fftwf_plan_many_dft(rank, n, howmany, dataIn, nembed, stride, dist,dataOut, nembed, stride, dist,FFTW_FORWARD,FFTW_MEASURE); */ fftwf_plan plan = fftwf_plan_many_dft(rank, n, howmany, dataIn, NULL, stride, dist,dataOut, NULL, stride, dist,FFTW_FORWARD,FFTW_MEASURE); fftwf_execute(plan); printf("\nOutputData :\n"); for (i=0;i<N1*N2;i++) { printf ("%6.2f + i*%6.2f ",dataOut[i][0],dataOut[i][1]); } fftwf_free(dataIn); fftwf_free(dataOut); fftwf_destroy_plan(plan); return 0; }
problem of advanced fftw using
Started by ●May 19, 2009
Reply by ●May 20, 20092009-05-20
here's a 2D implementation: http://www.adislindia.com/pdn.html original link: http://divyarathore.googlepages.com/fftwpluginforimageapprentice.htm does that help you?