comparison src/fftw-3.3.8/doc/html/Real-even_002fodd-DFTs-_0028cosine_002fsine-transforms_0029.html @ 167:bd3cc4d1df30

Add FFTW 3.3.8 source, and a Linux build
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 19 Nov 2019 14:52:55 +0000
parents
children
comparison
equal deleted inserted replaced
166:cbd6d7e562c7 167:bd3cc4d1df30
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <!-- This manual is for FFTW
4 (version 3.3.8, 24 May 2018).
5
6 Copyright (C) 2003 Matteo Frigo.
7
8 Copyright (C) 2003 Massachusetts Institute of Technology.
9
10 Permission is granted to make and distribute verbatim copies of this
11 manual provided the copyright notice and this permission notice are
12 preserved on all copies.
13
14 Permission is granted to copy and distribute modified versions of this
15 manual under the conditions for verbatim copying, provided that the
16 entire resulting derived work is distributed under the terms of a
17 permission notice identical to this one.
18
19 Permission is granted to copy and distribute translations of this manual
20 into another language, under the above conditions for modified versions,
21 except that this permission notice may be stated in a translation
22 approved by the Free Software Foundation. -->
23 <!-- Created by GNU Texinfo 6.3, http://www.gnu.org/software/texinfo/ -->
24 <head>
25 <title>FFTW 3.3.8: Real even/odd DFTs (cosine/sine transforms)</title>
26
27 <meta name="description" content="FFTW 3.3.8: Real even/odd DFTs (cosine/sine transforms)">
28 <meta name="keywords" content="FFTW 3.3.8: Real even/odd DFTs (cosine/sine transforms)">
29 <meta name="resource-type" content="document">
30 <meta name="distribution" content="global">
31 <meta name="Generator" content="makeinfo">
32 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
33 <link href="index.html#Top" rel="start" title="Top">
34 <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
35 <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
36 <link href="More-DFTs-of-Real-Data.html#More-DFTs-of-Real-Data" rel="up" title="More DFTs of Real Data">
37 <link href="The-Discrete-Hartley-Transform.html#The-Discrete-Hartley-Transform" rel="next" title="The Discrete Hartley Transform">
38 <link href="The-Halfcomplex_002dformat-DFT.html#The-Halfcomplex_002dformat-DFT" rel="prev" title="The Halfcomplex-format DFT">
39 <style type="text/css">
40 <!--
41 a.summary-letter {text-decoration: none}
42 blockquote.indentedblock {margin-right: 0em}
43 blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
44 blockquote.smallquotation {font-size: smaller}
45 div.display {margin-left: 3.2em}
46 div.example {margin-left: 3.2em}
47 div.lisp {margin-left: 3.2em}
48 div.smalldisplay {margin-left: 3.2em}
49 div.smallexample {margin-left: 3.2em}
50 div.smalllisp {margin-left: 3.2em}
51 kbd {font-style: oblique}
52 pre.display {font-family: inherit}
53 pre.format {font-family: inherit}
54 pre.menu-comment {font-family: serif}
55 pre.menu-preformatted {font-family: serif}
56 pre.smalldisplay {font-family: inherit; font-size: smaller}
57 pre.smallexample {font-size: smaller}
58 pre.smallformat {font-family: inherit; font-size: smaller}
59 pre.smalllisp {font-size: smaller}
60 span.nolinebreak {white-space: nowrap}
61 span.roman {font-family: initial; font-weight: normal}
62 span.sansserif {font-family: sans-serif; font-weight: normal}
63 ul.no-bullet {list-style: none}
64 -->
65 </style>
66
67
68 </head>
69
70 <body lang="en">
71 <a name="Real-even_002fodd-DFTs-_0028cosine_002fsine-transforms_0029"></a>
72 <div class="header">
73 <p>
74 Next: <a href="The-Discrete-Hartley-Transform.html#The-Discrete-Hartley-Transform" accesskey="n" rel="next">The Discrete Hartley Transform</a>, Previous: <a href="The-Halfcomplex_002dformat-DFT.html#The-Halfcomplex_002dformat-DFT" accesskey="p" rel="prev">The Halfcomplex-format DFT</a>, Up: <a href="More-DFTs-of-Real-Data.html#More-DFTs-of-Real-Data" accesskey="u" rel="up">More DFTs of Real Data</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
75 </div>
76 <hr>
77 <a name="Real-even_002fodd-DFTs-_0028cosine_002fsine-transforms_0029-1"></a>
78 <h4 class="subsection">2.5.2 Real even/odd DFTs (cosine/sine transforms)</h4>
79
80 <p>The Fourier transform of a real-even function <em>f(-x) = f(x)</em> is
81 real-even, and <em>i</em> times the Fourier transform of a real-odd
82 function <em>f(-x) = -f(x)</em> is real-odd. Similar results hold for a
83 discrete Fourier transform, and thus for these symmetries the need for
84 complex inputs/outputs is entirely eliminated. Moreover, one gains a
85 factor of two in speed/space from the fact that the data are real, and
86 an additional factor of two from the even/odd symmetry: only the
87 non-redundant (first) half of the array need be stored. The result is
88 the real-even DFT (<em>REDFT</em>) and the real-odd DFT (<em>RODFT</em>), also
89 known as the discrete cosine and sine transforms (<em>DCT</em> and
90 <em>DST</em>), respectively.
91 <a name="index-real_002deven-DFT"></a>
92 <a name="index-REDFT"></a>
93 <a name="index-real_002dodd-DFT"></a>
94 <a name="index-RODFT"></a>
95 <a name="index-discrete-cosine-transform"></a>
96 <a name="index-DCT"></a>
97 <a name="index-discrete-sine-transform"></a>
98 <a name="index-DST"></a>
99 </p>
100
101 <p>(In this section, we describe the 1d transforms; multi-dimensional
102 transforms are just a separable product of these transforms operating
103 along each dimension.)
104 </p>
105 <p>Because of the discrete sampling, one has an additional choice: is the
106 data even/odd around a sampling point, or around the point halfway
107 between two samples? The latter corresponds to <em>shifting</em> the
108 samples by <em>half</em> an interval, and gives rise to several transform
109 variants denoted by REDFT<em>ab</em> and RODFT<em>ab</em>: <em>a</em> and
110 <em>b</em> are <em>0</em> or <em>1</em>, and indicate whether the input
111 (<em>a</em>) and/or output (<em>b</em>) are shifted by half a sample
112 (<em>1</em> means it is shifted). These are also known as types I-IV of
113 the DCT and DST, and all four types are supported by FFTW&rsquo;s r2r
114 interface.<a name="DOCF3" href="#FOOT3"><sup>3</sup></a>
115 </p>
116 <p>The r2r kinds for the various REDFT and RODFT types supported by FFTW,
117 along with the boundary conditions at both ends of the <em>input</em>
118 array (<code>n</code> real numbers <code>in[j=0..n-1]</code>), are:
119 </p>
120 <ul>
121 <li> <code>FFTW_REDFT00</code> (DCT-I): even around <em>j=0</em> and even around <em>j=n-1</em>.
122 <a name="index-FFTW_005fREDFT00"></a>
123
124 </li><li> <code>FFTW_REDFT10</code> (DCT-II, &ldquo;the&rdquo; DCT): even around <em>j=-0.5</em> and even around <em>j=n-0.5</em>.
125 <a name="index-FFTW_005fREDFT10"></a>
126
127 </li><li> <code>FFTW_REDFT01</code> (DCT-III, &ldquo;the&rdquo; IDCT): even around <em>j=0</em> and odd around <em>j=n</em>.
128 <a name="index-FFTW_005fREDFT01"></a>
129 <a name="index-IDCT"></a>
130
131 </li><li> <code>FFTW_REDFT11</code> (DCT-IV): even around <em>j=-0.5</em> and odd around <em>j=n-0.5</em>.
132 <a name="index-FFTW_005fREDFT11"></a>
133
134 </li><li> <code>FFTW_RODFT00</code> (DST-I): odd around <em>j=-1</em> and odd around <em>j=n</em>.
135 <a name="index-FFTW_005fRODFT00"></a>
136
137 </li><li> <code>FFTW_RODFT10</code> (DST-II): odd around <em>j=-0.5</em> and odd around <em>j=n-0.5</em>.
138 <a name="index-FFTW_005fRODFT10"></a>
139
140 </li><li> <code>FFTW_RODFT01</code> (DST-III): odd around <em>j=-1</em> and even around <em>j=n-1</em>.
141 <a name="index-FFTW_005fRODFT01"></a>
142
143 </li><li> <code>FFTW_RODFT11</code> (DST-IV): odd around <em>j=-0.5</em> and even around <em>j=n-0.5</em>.
144 <a name="index-FFTW_005fRODFT11"></a>
145
146 </li></ul>
147
148 <p>Note that these symmetries apply to the &ldquo;logical&rdquo; array being
149 transformed; <strong>there are no constraints on your physical input
150 data</strong>. So, for example, if you specify a size-5 REDFT00 (DCT-I) of the
151 data <em>abcde</em>, it corresponds to the DFT of the logical even array
152 <em>abcdedcb</em> of size 8. A size-4 REDFT10 (DCT-II) of the data
153 <em>abcd</em> corresponds to the size-8 logical DFT of the even array
154 <em>abcddcba</em>, shifted by half a sample.
155 </p>
156 <p>All of these transforms are invertible. The inverse of R*DFT00 is
157 R*DFT00; of R*DFT10 is R*DFT01 and vice versa (these are often called
158 simply &ldquo;the&rdquo; DCT and IDCT, respectively); and of R*DFT11 is R*DFT11.
159 However, the transforms computed by FFTW are unnormalized, exactly
160 like the corresponding real and complex DFTs, so computing a transform
161 followed by its inverse yields the original array scaled by <em>N</em>,
162 where <em>N</em> is the <em>logical</em> DFT size. For REDFT00,
163 <em>N=2(n-1)</em>; for RODFT00, <em>N=2(n+1)</em>; otherwise, <em>N=2n</em>.
164 <a name="index-normalization-3"></a>
165 <a name="index-IDCT-1"></a>
166 </p>
167
168 <p>Note that the boundary conditions of the transform output array are
169 given by the input boundary conditions of the inverse transform.
170 Thus, the above transforms are all inequivalent in terms of
171 input/output boundary conditions, even neglecting the 0.5 shift
172 difference.
173 </p>
174 <p>FFTW is most efficient when <em>N</em> is a product of small factors; note
175 that this <em>differs</em> from the factorization of the physical size
176 <code>n</code> for REDFT00 and RODFT00! There is another oddity: <code>n=1</code>
177 REDFT00 transforms correspond to <em>N=0</em>, and so are <em>not
178 defined</em> (the planner will return <code>NULL</code>). Otherwise, any positive
179 <code>n</code> is supported.
180 </p>
181 <p>For the precise mathematical definitions of these transforms as used by
182 FFTW, see <a href="What-FFTW-Really-Computes.html#What-FFTW-Really-Computes">What FFTW Really Computes</a>. (For people accustomed to
183 the DCT/DST, FFTW&rsquo;s definitions have a coefficient of <em>2</em> in front
184 of the cos/sin functions so that they correspond precisely to an
185 even/odd DFT of size <em>N</em>. Some authors also include additional
186 multiplicative factors of
187 &radic;2
188 for selected inputs and outputs; this makes
189 the transform orthogonal, but sacrifices the direct equivalence to a
190 symmetric DFT.)
191 </p>
192 <a name="Which-type-do-you-need_003f"></a>
193 <h4 class="subsubheading">Which type do you need?</h4>
194
195 <p>Since the required flavor of even/odd DFT depends upon your problem,
196 you are the best judge of this choice, but we can make a few comments
197 on relative efficiency to help you in your selection. In particular,
198 R*DFT01 and R*DFT10 tend to be slightly faster than R*DFT11
199 (especially for odd sizes), while the R*DFT00 transforms are sometimes
200 significantly slower (especially for even sizes).<a name="DOCF4" href="#FOOT4"><sup>4</sup></a>
201 </p>
202 <p>Thus, if only the boundary conditions on the transform inputs are
203 specified, we generally recommend R*DFT10 over R*DFT00 and R*DFT01 over
204 R*DFT11 (unless the half-sample shift or the self-inverse property is
205 significant for your problem).
206 </p>
207 <p>If performance is important to you and you are using only small sizes
208 (say <em>n&lt;200</em>), e.g. for multi-dimensional transforms, then you
209 might consider generating hard-coded transforms of those sizes and types
210 that you are interested in (see <a href="Generating-your-own-code.html#Generating-your-own-code">Generating your own code</a>).
211 </p>
212 <p>We are interested in hearing what types of symmetric transforms you find
213 most useful.
214 </p>
215 <div class="footnote">
216 <hr>
217 <h4 class="footnotes-heading">Footnotes</h4>
218
219 <h3><a name="FOOT3" href="#DOCF3">(3)</a></h3>
220 <p>There are also type V-VIII transforms, which
221 correspond to a logical DFT of <em>odd</em> size <em>N</em>, independent of
222 whether the physical size <code>n</code> is odd, but we do not support these
223 variants.</p>
224 <h3><a name="FOOT4" href="#DOCF4">(4)</a></h3>
225 <p>R*DFT00 is
226 sometimes slower in FFTW because we discovered that the standard
227 algorithm for computing this by a pre/post-processed real DFT&mdash;the
228 algorithm used in FFTPACK, Numerical Recipes, and other sources for
229 decades now&mdash;has serious numerical problems: it already loses several
230 decimal places of accuracy for 16k sizes. There seem to be only two
231 alternatives in the literature that do not suffer similarly: a
232 recursive decomposition into smaller DCTs, which would require a large
233 set of codelets for efficiency and generality, or sacrificing a factor of
234 2
235 in speed to use a real DFT of twice the size. We currently
236 employ the latter technique for general <em>n</em>, as well as a limited
237 form of the former method: a split-radix decomposition when <em>n</em>
238 is odd (<em>N</em> a multiple of 4). For <em>N</em> containing many
239 factors of 2, the split-radix method seems to recover most of the
240 speed of the standard algorithm without the accuracy tradeoff.</p>
241 </div>
242 <hr>
243 <div class="header">
244 <p>
245 Next: <a href="The-Discrete-Hartley-Transform.html#The-Discrete-Hartley-Transform" accesskey="n" rel="next">The Discrete Hartley Transform</a>, Previous: <a href="The-Halfcomplex_002dformat-DFT.html#The-Halfcomplex_002dformat-DFT" accesskey="p" rel="prev">The Halfcomplex-format DFT</a>, Up: <a href="More-DFTs-of-Real-Data.html#More-DFTs-of-Real-Data" accesskey="u" rel="up">More DFTs of Real Data</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
246 </div>
247
248
249
250 </body>
251 </html>