Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
2
<html>
3
<head><title>
4
FFTW FAQ - Section 3
5
</title>
6
<link rev="made" href="mailto:fftw@theory.lcs.mit.edu">
7
<link rel="Contents" href="index.html">
8
<link rel="Start" href="index.html">
9
<link rel="Next" href="section4.html"><link rel="Previous" href="section2.html"><link rel="Bookmark" title="FFTW FAQ" href="index.html">
10
</head><body text="#000000" bgcolor="#FFFFFF"><h1>
11
FFTW FAQ - Section 3 <br>
12
Using FFTW
13
</h1>
14
 
15
<ul>
16
<li><a href="#slow" rel=subdocument>Q3.1. FFTW seems really slow.</a>
17
<li><a href="#conventions" rel=subdocument>Q3.2. FFTW gives results different from my old
18
FFT.</a>
19
<li><a href="#savePlans" rel=subdocument>Q3.3. Can I save FFTW's plans?</a>
20
<li><a href="#whyscaled" rel=subdocument>Q3.4. Why does your inverse transform return a scaled
21
result?</a>
22
<li><a href="#centerorigin" rel=subdocument>Q3.5. How can I make FFTW put the origin (zero frequency) at the center of
23
its output?</a>
24
<li><a href="#imageaudio" rel=subdocument>Q3.6. How do I FFT an image/audio file in <i>foobar</i> format?</a>
25
<li><a href="#linkfails" rel=subdocument>Q3.7. My program does not link (on Unix).</a>
26
</ul><hr>
27
 
28
<h2><A name="slow">
29
Question 3.1.  FFTW seems really slow.
30
</A></h2>
31
 
32
You are probably recreating the plan before every transform, rather
33
than creating it once and reusing it for all transforms of the same
34
size.  FFTW is designed to be used in the following way:
35
 
36
<ul>
37
<li>First, you create a plan.  This will take several seconds.
38
 
39
<li>Then, you reuse the plan many times to perform FFTs.  These are fast.
40
 
41
</ul>
42
If you don't need to compute many transforms and the time for the
43
planner is significant, you have two options.  First, you can use the
44
<code>FFTW_ESTIMATE</code> option in the planner, which uses heuristics
45
instead of runtime measurements and produces a good plan in a short
46
time.  Second, you can use the wisdom feature to precompute the plan;
47
see <A href="#savePlans">Q3.3 `Can I save FFTW's plans?'</A>
48
<h2><A name="conventions">
49
Question 3.2.  FFTW gives results different from my old
50
FFT.
51
</A></h2>
52
 
53
People follow many different conventions for the DFT, and you should
54
be sure to know the ones that we use (described in the FFTW manual).
55
In particular, you should be aware that the
56
<code>FFTW_FORWARD</code>/<code>FFTW_BACKWARD</code> directions correspond to signs of -1/+1 in the exponent of the DFT definition.
57
(<i>Numerical Recipes</i> uses the opposite convention.)  
58
<p>
59
You should also know that we compute an unnormalized transform.  In
60
contrast, Matlab is an example of program that computes a normalized
61
transform.  See <A href="#whyscaled">Q3.4 `Why does your inverse transform return a scaled
62
result?'</A>.  
63
<h2><A name="savePlans">
64
Question 3.3.  Can I save FFTW's plans?
65
</A></h2>
66
 
67
Yes. Starting with version 1.2, FFTW provides the
68
<code>wisdom</code> mechanism for saving plans.  See <A href="section4.html#wisdom">Q4.3 `What is this <code>wisdom</code> thing?'</A> and the FFTW manual.  
69
<h2><A name="whyscaled">
70
Question 3.4.  Why does your inverse transform return a scaled
71
result?
72
</A></h2>
73
 
74
Computing the forward transform followed by the backward transform (or
75
vice versa) yields the original array scaled by the size of the array.
76
 (For multi-dimensional transforms, the size of the array is the
77
product of the dimensions.)  We could, instead, have chosen a
78
normalization that would have returned the unscaled array. Or, to
79
accomodate the many conventions in this matter, the transform routines
80
could have accepted a &quot;scale factor&quot; parameter. We did not
81
do this, however, for two reasons. First, we didn't want to sacrifice
82
performance in the common case where the scale factor is 1. Second, in
83
real applications the FFT is followed or preceded by some computation
84
on the data, into which the scale factor can typically be absorbed at
85
little or no cost.  
86
<h2><A name="centerorigin">
87
Question 3.5.  How can I make FFTW put the origin (zero frequency) at
88
the center of its output?
89
</A></h2>
90
 
91
For human viewing of a spectrum, it is often convenient to put the
92
origin in frequency space at the center of the output array, rather
93
than in the zero-th element (the default in FFTW).  If all of the
94
dimensions of your array are even, you can accomplish this by simply
95
multiplying each element of the input array by (-1)^(i + j + ...),
96
where i, j, etcetera are the indices of the element.  (This trick is a
97
general property of the DFT, and is not specific to FFTW.)
98
 
99
<h2><A name="imageaudio">
100
Question 3.6.  How do I FFT an image/audio file in
101
<i>foobar</i> format?
102
</A></h2>
103
 
104
FFTW performs an FFT on an array of floating-point values.  You can
105
certainly use it to compute the transform of an image or audio stream,
106
but you are responsible for figuring out your data format and
107
converting it to the form FFTW requires.
108
 
109
<h2><A name="linkfails">
110
Question 3.7.  My program does not link (on
111
Unix).
112
</A></h2>
113
 
114
Please use the exact order in which libraries are specified by the
115
FFTW manual (e.g. <code>-lrfftw -lfftw -lm</code>).  Also, note that the libraries must be listed after your program sources/objects.  (The
116
general rule is that if <i>A</i> uses <i>B</i>, then <i>A</i> must be listed before <i>B</i> in the link command.).  For example, switching the order to <code>-lfftw -lrfftw -lm</code> will fail.  <hr>
117
Next: <a href="section4.html" rel=precedes>Internals of FFTW</a>.<br>
118
Back: <a href="section2.html" rev=precedes>Installing FFTW</a>.<br>
119
<a href="index.html" rev=subdocument>Return to contents</a>.<p>
120
<address>
121
<A href="http://theory.lcs.mit.edu/~fftw/">Matteo Frigo and Steven G. Johnson</A> / <A href="mailto:fftw@theory.lcs.mit.edu">fftw@theory.lcs.mit.edu</A>
122
- 18 May 1999
123
</address><br>
124
Extracted from FFTW Frequently Asked Questions with Answers,
125
Copyright &copy; 1999 Massachusetts Institute of Technology.
126
</body></html>