# FFTW FAQ - Section 3
Using FFTW

- Q3.1. FFTW seems really slow.
- Q3.2. FFTW slows down after repeated calls.
- Q3.3. An FFTW routine is crashing when I call it.
- Q3.4. My Fortran program crashes when calling FFTW.
- Q3.5. FFTW gives results different from my old FFT.
- Q3.6. Your in-place transform gives incorrect results.
- Q3.7. Can I save FFTW's plans?
- Q3.8. Why does your inverse transform return a scaled result?
- Q3.9. How can I make FFTW put the origin (zero frequency) at the center of its output?
- Q3.10. How do I FFT an image/audio file in foobar format?
- Q3.11. My program does not link (on Unix).
- Q3.12. My program crashes, complaining about stack space.

## Question 3.1. FFTW seems really slow.

You are probably recreating the plan before every transform, rather than creating it once and reusing it for all transforms of the same size. FFTW is designed to be used in the following way:

- First, you create a plan. This will take several seconds.
- Then, you reuse the plan many times to perform FFTs. These are fast.

If you don't need to compute many transforms and the time for the planner is significant, you have two options. First, you can use the `FFTW_ESTIMATE` option in the planner, which uses heuristics instead of runtime measurements and produces a good plan in a short time. Second, you can use the wisdom feature to precompute the plan; see Q3.7 `Can I save FFTW's plans?'

## Question 3.2. FFTW slows down after repeated calls.

Probably, NaNs or similar are creeping into your data, and the slowdown is due to the resulting floating-point exceptions. For example, be aware that repeatedly FFTing the same array is a diverging process (because FFTW computes the unnormalized transform).

## Question 3.3. An FFTW routine is crashing when I call it.

You almost certainly have a bug in your code. For example, you could be passing invalid arguments (such as wrongly-sized arrays) to FFTW, or you could simply have memory corruption elsewhere in your program that causes random crashes later on. Learn to debug, and don't complain to us unless you can come up with a minimal program (preferably under 30 lines) that illustrates the problem.

## Question 3.4. My Fortran program crashes when calling FFTW.

As described in the manual, on 64-bit machines you must store the plans in variables large enough to hold a pointer, for example `integer*8`.

## Question 3.5. FFTW gives results different from my old FFT.

People follow many different conventions for the DFT, and you should be sure to know the ones that we use (described in the FFTW manual). In particular, you should be aware that the `FFTW_FORWARD`/`FFTW_BACKWARD` directions correspond to signs of -1/+1 in the exponent of the DFT definition. (Numerical Recipes uses the opposite convention.)

You should also know that we compute an unnormalized transform. In contrast, Matlab is an example of program that computes a normalized transform. See Q3.8 `Why does your inverse transform return a scaled result?'.

Finally, note that floating-point arithmetic is not exact, so different FFT algorithms will give slightly different results (on the order of the numerical accuracy; typically a fractional difference of 1e-15 or so).

## Question 3.6. Your in-place transform gives incorrect results.

As described in the FFTW manual, the output array argument has a special meaning for `FFTW_INPLACE` transforms; you should not pass the input array for this argument.

## Question 3.7. Can I save FFTW's plans?

Yes. Starting with version 1.2, FFTW provides the `wisdom` mechanism for saving plans. See Q4.3 `What is this `wisdom` thing?' and the FFTW manual.

## Question 3.8. Why does your inverse transform return a scaled result?

Computing the forward transform followed by the backward transform (or vice versa) yields the original array scaled by the size of the array. (For multi-dimensional transforms, the size of the array is the product of the dimensions.) We could, instead, have chosen a normalization that would have returned the unscaled array. Or, to accomodate the many conventions in this matter, the transform routines could have accepted a "scale factor" parameter. We did not do this, however, for two reasons. First, we didn't want to sacrifice performance in the common case where the scale factor is 1. Second, in real applications the FFT is followed or preceded by some computation on the data, into which the scale factor can typically be absorbed at little or no cost.

## Question 3.9. How can I make FFTW put the origin (zero frequency) at the center of its output?

For human viewing of a spectrum, it is often convenient to put the origin in frequency space at the center of the output array, rather than in the zero-th element (the default in FFTW). If all of the dimensions of your array are even, you can accomplish this by simply multiplying each element of the input array by (-1)^(i + j + ...), where i, j, etcetera are the indices of the element. (This trick is a general property of the DFT, and is not specific to FFTW.)

## Question 3.10. How do I FFT an image/audio file in foobar format?

FFTW performs an FFT on an array of floating-point values. You can certainly use it to compute the transform of an image or audio stream, but you are responsible for figuring out your data format and converting it to the form FFTW requires.

## Question 3.11. My program does not link (on Unix).

Please use the exact order in which libraries are specified by the FFTW manual (e.g. `-lrfftw -lfftw -lm`). Also, note that the libraries must be listed after your program sources/objects. (The general rule is that if A uses B, then A must be listed before B in the link command.). For example, switching the order to `-lfftw -lrfftw -lm` will fail.

## Question 3.12. My program crashes, complaining about stack space.

You cannot declare large arrays statically; you should use `malloc` (or equivalent) to allocate the arrays you want to transform if they are larger than a few hundred elements.

Next: Internals of FFTW.
Back: Installing FFTW.
Return to contents.

Extracted from FFTW Frequently Asked Questions with Answers, Copyright © 2026 Massachusetts Institute of Technology.