1
$\begingroup$

I've been scanning all of the FFTW documentation, trying to figure out how to inverse FFT my FFT spectrum.

The documentation only mentions how to inverse FFT real-to-complex transformations, using the opposite c2r transform.

There are no FFTW_INVERSE flags anywhere but I suspect that the FFTW_FORWARD/BACKWARD transform might be what I need.

i.e. FORWARD for FFT and BACKWARD for IFFT. The documentation speaks about it flipping the sign; I remember something similar happening with the IFFT.

Is the backwards transform just an IFFT (for forward transform)? If not, how do you achieve an IFFT?

$\endgroup$
1
  • $\begingroup$ Hi, I think you got the answer to your question. Would you be happy to mark one of them as accepted? $\endgroup$
    – jojeck
    Jul 18, 2020 at 10:46

2 Answers 2

5
$\begingroup$

Is the backwards transform just an IFFT (for forward transform)?

Yes.

Compare the "what FFTW actually computes", here

$\endgroup$
5
$\begingroup$

FFTW is a nice library.

Real forward, real backward, complex forward, complex backward.

Refill the input arrays when executing a new plan. Works for me, see documentation via the link graciously supplied by MM for more details.

Extracted from working code:

//--- Have FFTW do the DFT via a FFTW Plan

        fftw_plan thePlan;

/*

//--- Real DFT

        thePlan = fftw_plan_dft_r2c_1d( theSignalN,        
                                        theSignalArray, 
                                        theDftArray, 
                                        FFTW_ESTIMATE );   

//--- Real Inverse DFT

        thePlan = fftw_plan_dft_c2r_1d( theSignalN, 
                                        theDftArray, 
                                        theSignalArray, 
                                        FFTW_ESTIMATE );

//--- Complex DFT
                                        
        thePlan = fftw_plan_dft_1d( theSignalN, 
                                    theSignalArray, 
                                    theDftArray, 
                                    FFTW_FORWARD, 
                                    FFTW_ESTIMATE );
                                    
*/
//--- Comples Inverse DFT

        thePlan = fftw_plan_dft_1d( theSignalN, 
                                    theDftArray, 
                                    theSignalArray, 
                                    FFTW_BACKWARD, 
                                    FFTW_ESTIMATE );

        fftw_execute( thePlan );
        fftw_destroy_plan( thePlan );
$\endgroup$
4
  • $\begingroup$ This does not answer the question. Like marcus said, FFTW_FORWARD and FFTW_BACKWARD are indeed analogous to $\text{FT}$ and $\text{FT}^{-1}$ $\endgroup$ Jul 16, 2020 at 0:50
  • 1
    $\begingroup$ @TobiAkinyemi Sorry I couldn't be helpful for you. I would use the term "specifier" instead of "analagous". FFTW specifies forward and backward differently for real vs complex signals so a succinct summary of the syntax may very well be useful for someone finding this answer doing a search on the key words and they will be grateful. I think most people reading your question and my answer will be puzzled by your comment. You should accept MM's answer to keep this question from recycling. $\endgroup$ Jul 16, 2020 at 10:20
  • $\begingroup$ You've not at all addressed the question; you just said "FFTW is a nice library" and showed an irrelevant code snippet. $\endgroup$ Jul 16, 2020 at 10:23
  • 1
    $\begingroup$ @TobiAkinyemi How you think somebody should infer what you were really asking about the sign change in the definitions of the DFT and inverse DFT when talking about reading the manual about how to do the syntax using the FFTW library is beyond me, or any of my concern. $$ X[k] = \sum_{n=0}^{N-1} x[n] e^{-i \frac{2\pi}{N}nk} $$ $$ x[n] = \sum_{k=0}^{N-1} X[k] e^{i \frac{2\pi}{N}kn} $$ These are the unnormalized definitions using the common conventions favored in this forum. My answer gives the FFTW syntax for both real and complex signals. The relevance is in the eye of the beholder. $\endgroup$ Jul 16, 2020 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.