48
48
Section 3, Using FFTW
49
49
* Question 3.1:: FFTW seems really slow.
50
* Question 3.2:: FFTW gives results different from my old FFT.
51
* Question 3.3:: Can I save FFTW's plans?
52
* Question 3.4:: Why does your inverse transform return a scaled
50
* Question 3.2:: FFTW slows down after repeated calls.
51
* Question 3.3:: An FFTW routine is crashing when I call it.
52
* Question 3.4:: My Fortran program crashes when calling FFTW.
53
* Question 3.5:: FFTW gives results different from my old FFT.
54
* Question 3.6:: Your in-place transform gives incorrect results.
55
* Question 3.7:: Can I save FFTW's plans?
56
* Question 3.8:: Why does your inverse transform return a scaled
54
* Question 3.5:: How can I make FFTW put the origin (zero frequency) at
58
* Question 3.9:: How can I make FFTW put the origin (zero frequency) at
55
59
the center of its output?
56
* Question 3.6:: How do I FFT an image/audio file in *foobar* format?
57
* Question 3.7:: My program does not link (on Unix).
60
* Question 3.10:: How do I FFT an image/audio file in *foobar* format?
61
* Question 3.11:: My program does not link (on Unix).
62
* Question 3.12:: My program crashes, complaining about stack space.
59
64
Section 4, Internals of FFTW
60
65
* Question 4.1:: How does FFTW work?
196
202
successful compilations of FFTW using Borland's C/C++ compilers on
205
The Portland Group PGCC compiler, version 4.0 for Linux/x86, reportedly
206
produces incorrect code for FFTW 2.1.3.
199
208
Visual C++ 4.0 crashes when compiling FFTW 1.2 with all optimizations
200
209
turned on. Visual C++ 5.0 reportedly produces incorrect code for the real
201
210
transforms in FFTW 2.x when the option "Maximize speed" is set. We are
213
222
-xO5 option in Sun's SC4.0 C compiler. egcs 1.0.2 produced incorrect code
214
223
for FFTW on the PowerPC (corrected in egcs 1.1).
225
The DEC C compiler, V5.8-009 on Digital UNIX V4.0 (Rev. 1091) is known to
226
have bugs with its EV6 tuning. Specifically, compiling FFTW with -arch
227
host (the default) or -arch ev6 on an Alpha EV6 can cause FFTW (e.g.
228
fftw_test -s 256) to crash.
217
231
File: fftw-faq.info, Node: Question 2.4, Next: Question 2.5, Previous: Question 2.3, Up: Section 2
269
283
code, documented in the FFTW manual, is included with FFTW (versions 1.3
286
By default, FFTW configures its wrapper routines to work with the first
287
compiler it finds, e.g. g77. To configure for a different, incompatible
288
Fortran compiler foobar, use ./configure F77=foobar when installing FFTW.
273
291
File: fftw-faq.info, Node: Question 2.7, Next: Question 2.8, Previous: Question 2.6, Up: Section 2
302
320
* Question 3.1:: FFTW seems really slow.
303
* Question 3.2:: FFTW gives results different from my old FFT.
304
* Question 3.3:: Can I save FFTW's plans?
305
* Question 3.4:: Why does your inverse transform return a scaled
321
* Question 3.2:: FFTW slows down after repeated calls.
322
* Question 3.3:: An FFTW routine is crashing when I call it.
323
* Question 3.4:: My Fortran program crashes when calling FFTW.
324
* Question 3.5:: FFTW gives results different from my old FFT.
325
* Question 3.6:: Your in-place transform gives incorrect results.
326
* Question 3.7:: Can I save FFTW's plans?
327
* Question 3.8:: Why does your inverse transform return a scaled
307
* Question 3.5:: How can I make FFTW put the origin (zero frequency) at
329
* Question 3.9:: How can I make FFTW put the origin (zero frequency) at
308
330
the center of its output?
309
* Question 3.6:: How do I FFT an image/audio file in *foobar* format?
310
* Question 3.7:: My program does not link (on Unix).
331
* Question 3.10:: How do I FFT an image/audio file in *foobar* format?
332
* Question 3.11:: My program does not link (on Unix).
333
* Question 3.12:: My program crashes, complaining about stack space.
326
349
FFTW_ESTIMATE option in the planner, which uses heuristics instead of
327
350
runtime measurements and produces a good plan in a short time. Second,
328
351
you can use the wisdom feature to precompute the plan; see *Note Question
329
3.3:: `Can I save FFTW's plans?'
352
3.7:: `Can I save FFTW's plans?'
332
355
File: fftw-faq.info, Node: Question 3.2, Next: Question 3.3, Previous: Question 3.1, Up: Section 3
334
Question 3.2. FFTW gives results different from my old FFT.
357
Question 3.2. FFTW slows down after repeated calls.
359
Probably, NaNs or similar are creeping into your data, and the slowdown is
360
due to the resulting floating-point exceptions. For example, be aware
361
that repeatedly FFTing the same array is a diverging process (because FFTW
362
computes the unnormalized transform).
365
File: fftw-faq.info, Node: Question 3.3, Next: Question 3.4, Previous: Question 3.2, Up: Section 3
367
Question 3.3. An FFTW routine is crashing when I call it.
369
You almost certainly have a bug in your code. For example, you could be
370
passing invalid arguments (such as wrongly-sized arrays) to FFTW, or you
371
could simply have memory corruption elsewhere in your program that causes
372
random crashes later on. Learn to debug, and don't complain to us unless
373
you can come up with a minimal program (preferably under 30 lines) that
374
illustrates the problem.
377
File: fftw-faq.info, Node: Question 3.4, Next: Question 3.5, Previous: Question 3.3, Up: Section 3
379
Question 3.4. My Fortran program crashes when calling FFTW.
381
As described in the manual, on 64-bit machines you must store the plans in
382
variables large enough to hold a pointer, for example integer*8.
385
File: fftw-faq.info, Node: Question 3.5, Next: Question 3.6, Previous: Question 3.4, Up: Section 3
387
Question 3.5. FFTW gives results different from my old FFT.
336
389
People follow many different conventions for the DFT, and you should be
337
390
sure to know the ones that we use (described in the FFTW manual). In
342
395
You should also know that we compute an unnormalized transform. In
343
396
contrast, Matlab is an example of program that computes a normalized
344
transform. See *Note Question 3.4:: `Why does your inverse transform
397
transform. See *Note Question 3.8:: `Why does your inverse transform
345
398
return a scaled result?'.
348
File: fftw-faq.info, Node: Question 3.3, Next: Question 3.4, Previous: Question 3.2, Up: Section 3
350
Question 3.3. Can I save FFTW's plans?
400
Finally, note that floating-point arithmetic is not exact, so different
401
FFT algorithms will give slightly different results (on the order of the
402
numerical accuracy; typically a fractional difference of 1e-15 or so).
405
File: fftw-faq.info, Node: Question 3.6, Next: Question 3.7, Previous: Question 3.5, Up: Section 3
407
Question 3.6. Your in-place transform gives incorrect results.
409
As described in the FFTW manual, the output array argument has a special
410
meaning for FFTW_INPLACE transforms; you should not pass the input array
414
File: fftw-faq.info, Node: Question 3.7, Next: Question 3.8, Previous: Question 3.6, Up: Section 3
416
Question 3.7. Can I save FFTW's plans?
352
418
Yes. Starting with version 1.2, FFTW provides the wisdom mechanism for
353
419
saving plans. See *Note Question 4.3:: `What is this wisdom thing?' and
357
File: fftw-faq.info, Node: Question 3.4, Next: Question 3.5, Previous: Question 3.3, Up: Section 3
423
File: fftw-faq.info, Node: Question 3.8, Next: Question 3.9, Previous: Question 3.7, Up: Section 3
359
Question 3.4. Why does your inverse transform return a scaled result?
425
Question 3.8. Why does your inverse transform return a scaled result?
361
427
Computing the forward transform followed by the backward transform (or
362
428
vice versa) yields the original array scaled by the size of the array.
371
437
typically be absorbed at little or no cost.
374
File: fftw-faq.info, Node: Question 3.5, Next: Question 3.6, Previous: Question 3.4, Up: Section 3
440
File: fftw-faq.info, Node: Question 3.9, Next: Question 3.10, Previous: Question 3.8, Up: Section 3
376
Question 3.5. How can I make FFTW put the origin (zero frequency) at the center of its output?
442
Question 3.9. How can I make FFTW put the origin (zero frequency) at the center of its output?
378
444
For human viewing of a spectrum, it is often convenient to put the origin
379
445
in frequency space at the center of the output array, rather than in the
384
450
is not specific to FFTW.)
387
File: fftw-faq.info, Node: Question 3.6, Next: Question 3.7, Previous: Question 3.5, Up: Section 3
453
File: fftw-faq.info, Node: Question 3.10, Next: Question 3.11, Previous: Question 3.9, Up: Section 3
389
Question 3.6. How do I FFT an image/audio file in *foobar* format?
455
Question 3.10. How do I FFT an image/audio file in *foobar* format?
391
457
FFTW performs an FFT on an array of floating-point values. You can
392
458
certainly use it to compute the transform of an image or audio stream, but
394
460
the form FFTW requires.
397
File: fftw-faq.info, Node: Question 3.7, Next: Question 4.1, Previous: Question 3.6, Up: Section 3
463
File: fftw-faq.info, Node: Question 3.11, Next: Question 3.12, Previous: Question 3.10, Up: Section 3
399
Question 3.7. My program does not link (on Unix).
465
Question 3.11. My program does not link (on Unix).
401
467
Please use the exact order in which libraries are specified by the FFTW
402
468
manual (e.g. -lrfftw -lfftw -lm). Also, note that the libraries must be
405
471
For example, switching the order to -lfftw -lrfftw -lm will fail.
474
File: fftw-faq.info, Node: Question 3.12, Next: Question 4.1, Previous: Question 3.11, Up: Section 3
476
Question 3.12. My program crashes, complaining about stack space.
478
You cannot declare large arrays statically; you should use malloc (or
479
equivalent) to allocate the arrays you want to transform if they are
480
larger than a few hundred elements.
408
483
File: fftw-faq.info, Node: Section 4, Next: Section 5, Previous: Section 3, Up: Top
410
485
Internals of FFTW
420
File: fftw-faq.info, Node: Question 4.1, Next: Question 4.2, Previous: Question 3.7, Up: Section 4
495
File: fftw-faq.info, Node: Question 4.1, Next: Question 4.2, Previous: Question 3.12, Up: Section 4
422
497
Question 4.1. How does FFTW work?
583
File: fftw-faq.info, Node: Question 5.10, Previous: Question 5.9, Up: Section 5
659
File: fftw-faq.info, Node: Question 5.10, Next: Question 5.11, Previous: Question 5.9, Up: Section 5
585
661
Question 5.10. FFTW 2.1.2's complex transforms give incorrect results for large prime sizes.
589
665
that caused incorrect results for many primes greater than 32768 (on
590
666
32-bit machines). (Sizes without large prime factors are not affected.)
669
File: fftw-faq.info, Node: Question 5.11, Previous: Question 5.10, Up: Section 5
671
Question 5.11. FFTW 2.1.3 crashes on AIX
673
The FFTW 2.1.3 configure script picked incorrect compiler flags for the
674
xlc compiler on newer IBM processors. This is fixed in FFTW 2.1.4.