comparison src/fftw-3.3.5/doc/html/Real-even_002fodd-DFTs-_0028cosine_002fsine-transforms_0029.html @ 42:2cd0e3b3e1fd

Current fftw source
author Chris Cannam
date Tue, 18 Oct 2016 13:40:26 +0100
parents
children
comparison
equal deleted inserted replaced
41:481f5f8c5634 42:2cd0e3b3e1fd
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.5, 30 July 2016).
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 5.2, http://www.gnu.org/software/texinfo/ -->
24 <head>
25 <title>FFTW 3.3.5: Real even/odd DFTs (cosine/sine transforms)</title>
26
27 <meta name="description" content="FFTW 3.3.5: Real even/odd DFTs (cosine/sine transforms)">
28 <meta name="keywords" content="FFTW 3.3.5: 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.smallquotation {font-size: smaller}
43 div.display {margin-left: 3.2em}
44 div.example {margin-left: 3.2em}
45 div.indentedblock {margin-left: 3.2em}
46 div.lisp {margin-left: 3.2em}
47 div.smalldisplay {margin-left: 3.2em}
48 div.smallexample {margin-left: 3.2em}
49 div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
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.nocodebreak {white-space:nowrap}
61 span.nolinebreak {white-space:nowrap}
62 span.roman {font-family:serif; font-weight:normal}
63 span.sansserif {font-family:sans-serif; font-weight:normal}
64 ul.no-bullet {list-style: none}
65 -->
66 </style>
67
68
69 </head>
70
71 <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
72 <a name="Real-even_002fodd-DFTs-_0028cosine_002fsine-transforms_0029"></a>
73 <div class="header">
74 <p>
75 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>
76 </div>
77 <hr>
78 <a name="Real-even_002fodd-DFTs-_0028cosine_002fsine-transforms_0029-1"></a>
79 <h4 class="subsection">2.5.2 Real even/odd DFTs (cosine/sine transforms)</h4>
80
81 <p>The Fourier transform of a real-even function <em>f(-x) = f(x)</em> is
82 real-even, and <em>i</em> times the Fourier transform of a real-odd
83 function <em>f(-x) = -f(x)</em> is real-odd. Similar results hold for a
84 discrete Fourier transform, and thus for these symmetries the need for
85 complex inputs/outputs is entirely eliminated. Moreover, one gains a
86 factor of two in speed/space from the fact that the data are real, and
87 an additional factor of two from the even/odd symmetry: only the
88 non-redundant (first) half of the array need be stored. The result is
89 the real-even DFT (<em>REDFT</em>) and the real-odd DFT (<em>RODFT</em>), also
90 known as the discrete cosine and sine transforms (<em>DCT</em> and
91 <em>DST</em>), respectively.
92 <a name="index-real_002deven-DFT"></a>
93 <a name="index-REDFT"></a>
94 <a name="index-real_002dodd-DFT"></a>
95 <a name="index-RODFT"></a>
96 <a name="index-discrete-cosine-transform"></a>
97 <a name="index-DCT"></a>
98 <a name="index-discrete-sine-transform"></a>
99 <a name="index-DST"></a>
100 </p>
101
102 <p>(In this section, we describe the 1d transforms; multi-dimensional
103 transforms are just a separable product of these transforms operating
104 along each dimension.)
105 </p>
106 <p>Because of the discrete sampling, one has an additional choice: is the
107 data even/odd around a sampling point, or around the point halfway
108 between two samples? The latter corresponds to <em>shifting</em> the
109 samples by <em>half</em> an interval, and gives rise to several transform
110 variants denoted by REDFT<em>ab</em> and RODFT<em>ab</em>: <em>a</em> and
111 <em>b</em> are <em>0</em> or <em>1</em>, and indicate whether the input
112 (<em>a</em>) and/or output (<em>b</em>) are shifted by half a sample
113 (<em>1</em> means it is shifted). These are also known as types I-IV of
114 the DCT and DST, and all four types are supported by FFTW&rsquo;s r2r
115 interface.<a name="DOCF3" href="#FOOT3"><sup>3</sup></a>
116 </p>
117 <p>The r2r kinds for the various REDFT and RODFT types supported by FFTW,
118 along with the boundary conditions at both ends of the <em>input</em>
119 array (<code>n</code> real numbers <code>in[j=0..n-1]</code>), are:
120 </p>
121 <ul>
122 <li> <code>FFTW_REDFT00</code> (DCT-I): even around <em>j=0</em> and even around <em>j=n-1</em>.
123 <a name="index-FFTW_005fREDFT00"></a>
124
125 </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>.
126 <a name="index-FFTW_005fREDFT10"></a>
127
128 </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>.
129 <a name="index-FFTW_005fREDFT01"></a>
130 <a name="index-IDCT"></a>
131
132 </li><li> <code>FFTW_REDFT11</code> (DCT-IV): even around <em>j=-0.5</em> and odd around <em>j=n-0.5</em>.
133 <a name="index-FFTW_005fREDFT11"></a>
134
135 </li><li> <code>FFTW_RODFT00</code> (DST-I): odd around <em>j=-1</em> and odd around <em>j=n</em>.
136 <a name="index-FFTW_005fRODFT00"></a>
137
138 </li><li> <code>FFTW_RODFT10</code> (DST-II): odd around <em>j=-0.5</em> and odd around <em>j=n-0.5</em>.
139 <a name="index-FFTW_005fRODFT10"></a>
140
141 </li><li> <code>FFTW_RODFT01</code> (DST-III): odd around <em>j=-1</em> and even around <em>j=n-1</em>.
142 <a name="index-FFTW_005fRODFT01"></a>
143
144 </li><li> <code>FFTW_RODFT11</code> (DST-IV): odd around <em>j=-0.5</em> and even around <em>j=n-0.5</em>.
145 <a name="index-FFTW_005fRODFT11"></a>
146
147 </li></ul>
148
149 <p>Note that these symmetries apply to the &ldquo;logical&rdquo; array being
150 transformed; <strong>there are no constraints on your physical input
151 data</strong>. So, for example, if you specify a size-5 REDFT00 (DCT-I) of the
152 data <em>abcde</em>, it corresponds to the DFT of the logical even array
153 <em>abcdedcb</em> of size 8. A size-4 REDFT10 (DCT-II) of the data
154 <em>abcd</em> corresponds to the size-8 logical DFT of the even array
155 <em>abcddcba</em>, shifted by half a sample.
156 </p>
157 <p>All of these transforms are invertible. The inverse of R*DFT00 is
158 R*DFT00; of R*DFT10 is R*DFT01 and vice versa (these are often called
159 simply &ldquo;the&rdquo; DCT and IDCT, respectively); and of R*DFT11 is R*DFT11.
160 However, the transforms computed by FFTW are unnormalized, exactly
161 like the corresponding real and complex DFTs, so computing a transform
162 followed by its inverse yields the original array scaled by <em>N</em>,
163 where <em>N</em> is the <em>logical</em> DFT size. For REDFT00,
164 <em>N=2(n-1)</em>; for RODFT00, <em>N=2(n+1)</em>; otherwise, <em>N=2n</em>.
165 <a name="index-normalization-3"></a>
166 <a name="index-IDCT-1"></a>
167 </p>
168
169 <p>Note that the boundary conditions of the transform output array are
170 given by the input boundary conditions of the inverse transform.
171 Thus, the above transforms are all inequivalent in terms of
172 input/output boundary conditions, even neglecting the 0.5 shift
173 difference.
174 </p>
175 <p>FFTW is most efficient when <em>N</em> is a product of small factors; note
176 that this <em>differs</em> from the factorization of the physical size
177 <code>n</code> for REDFT00 and RODFT00! There is another oddity: <code>n=1</code>
178 REDFT00 transforms correspond to <em>N=0</em>, and so are <em>not
179 defined</em> (the planner will return <code>NULL</code>). Otherwise, any positive
180 <code>n</code> is supported.
181 </p>
182 <p>For the precise mathematical definitions of these transforms as used by
183 FFTW, see <a href="What-FFTW-Really-Computes.html#What-FFTW-Really-Computes">What FFTW Really Computes</a>. (For people accustomed to
184 the DCT/DST, FFTW&rsquo;s definitions have a coefficient of <em>2</em> in front
185 of the cos/sin functions so that they correspond precisely to an
186 even/odd DFT of size <em>N</em>. Some authors also include additional
187 multiplicative factors of
188 &radic;2for 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>