Prev: what is the typical program memory space designers encounter?
Next: Tomorrow, the 30-th of March, despite to our protests, CERN plans to perform the first collisions of protons with the energy 3.5 TeV per proton (7 TeV per collision).
From: Kamran on 29 Mar 2010 05:50 Hi, Sorry if this is not the right forum but, I didn't know who else to turn to. I have a quite simple process. I use FFTW library to take a forward fft of a one dimensional signal and then do some multiplication in freq. domain and then a backward (inverse) fft. (called in a C++ code). I check the result with matlab (as I understand matlab uses the same library). The forward result is identical in both matlab and my C++ code, but the backward fft is completely off mark, this is the relevant code: (I use the number of samples in the signal for number of frequency samples, nfft) fftwf_complex* m_array; for (int i= 0; i < ns; i++) m_array[i][0] = some_values; m_array[i][1] = some_other_values; } // take forward fft fftwf_plan p = 0; p = fftwf_plan_dft_1d(size, (fftwf_complex*) &m_array[0][0],(fftwf_complex*) &m_array[0][0],FFTW_FORWARD, FFTW_ESTIMATE); fftwf_execute(p); fftwf_destroy_plan(p); // m_array now contains correct coefficients // take backward fft, this should get me back to my original data // but it doesn't fftwf_plan p = 0; p = fftwf_plan_dft_1d(size, (fftwf_complex*) &m_array[0][0],(fftwf_complex*) &m_array[0][0],FFTW_BACKWARD, FFTW_ESTIMATE); fftwf_execute(p); fftwf_destroy_plan(p); // m_array is now filled with rubbish appreciate any help, Kamran
From: Kamran on 29 Mar 2010 06:15 Sorry guys, disregard the whole thing. Id forgotten to normalize after taking inverse. stupid. Kamran wrote: > > Hi, > Sorry if this is not the right forum but, I didn't know who else to turn > to. > I have a quite simple process. I use FFTW library to take a forward fft > of a one dimensional signal and then do some multiplication in freq. > domain and then a backward (inverse) fft. (called in a C++ code). > I check the result with matlab (as I understand matlab uses the same > library). The forward result is identical in both matlab and my C++ > code, but the backward fft is completely off mark, this is the relevant > code: (I use the number of samples in the signal for number of frequency > samples, nfft) > > fftwf_complex* m_array; > > for (int i= 0; i < ns; i++) > m_array[i][0] = some_values; > m_array[i][1] = some_other_values; > } > > // take forward fft > fftwf_plan p = 0; > p = fftwf_plan_dft_1d(size, (fftwf_complex*) > &m_array[0][0],(fftwf_complex*) &m_array[0][0],FFTW_FORWARD, > FFTW_ESTIMATE); > fftwf_execute(p); > fftwf_destroy_plan(p); > > > // m_array now contains correct coefficients > > // take backward fft, this should get me back to my original data > // but it doesn't > > fftwf_plan p = 0; > p = fftwf_plan_dft_1d(size, (fftwf_complex*) > &m_array[0][0],(fftwf_complex*) &m_array[0][0],FFTW_BACKWARD, > FFTW_ESTIMATE); > fftwf_execute(p); > fftwf_destroy_plan(p); > > // m_array is now filled with rubbish > > appreciate any help, > > Kamran
From: divya_rathore_ on 29 Mar 2010 13:09
On Mar 29, 2:50 pm, Kamran <kam...(a)uio.no> wrote: > Hi, > Sorry if this is not the right forum but, I didn't know who else to turn to. > I have a quite simple process. I use FFTW library to take a forward fft > of a one dimensional signal and then do some multiplication in freq. > domain and then a backward (inverse) fft. (called in a C++ code). > > > Kamran Great that you could figure that out. Just to help others who might be having issues, here's link to my CFFTWWrapper class (includes usage code as well) that uses FFTW. Made it as a plugin for Image Apprentice couple of years ago. http://code.google.com/p/cfftwwrapper/ best regards, Divya Rathore www.adislindia.com |