annotate src/fftw-3.3.5/doc/html/One_002dDimensional-DFTs-of-Real-Data.html @ 127:7867fa7e1b6b

Current fftw source
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 18 Oct 2016 13:40:26 +0100
parents
children
rev   line source
cannam@127 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
cannam@127 2 <html>
cannam@127 3 <!-- This manual is for FFTW
cannam@127 4 (version 3.3.5, 30 July 2016).
cannam@127 5
cannam@127 6 Copyright (C) 2003 Matteo Frigo.
cannam@127 7
cannam@127 8 Copyright (C) 2003 Massachusetts Institute of Technology.
cannam@127 9
cannam@127 10 Permission is granted to make and distribute verbatim copies of this
cannam@127 11 manual provided the copyright notice and this permission notice are
cannam@127 12 preserved on all copies.
cannam@127 13
cannam@127 14 Permission is granted to copy and distribute modified versions of this
cannam@127 15 manual under the conditions for verbatim copying, provided that the
cannam@127 16 entire resulting derived work is distributed under the terms of a
cannam@127 17 permission notice identical to this one.
cannam@127 18
cannam@127 19 Permission is granted to copy and distribute translations of this manual
cannam@127 20 into another language, under the above conditions for modified versions,
cannam@127 21 except that this permission notice may be stated in a translation
cannam@127 22 approved by the Free Software Foundation. -->
cannam@127 23 <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
cannam@127 24 <head>
cannam@127 25 <title>FFTW 3.3.5: One-Dimensional DFTs of Real Data</title>
cannam@127 26
cannam@127 27 <meta name="description" content="FFTW 3.3.5: One-Dimensional DFTs of Real Data">
cannam@127 28 <meta name="keywords" content="FFTW 3.3.5: One-Dimensional DFTs of Real Data">
cannam@127 29 <meta name="resource-type" content="document">
cannam@127 30 <meta name="distribution" content="global">
cannam@127 31 <meta name="Generator" content="makeinfo">
cannam@127 32 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
cannam@127 33 <link href="index.html#Top" rel="start" title="Top">
cannam@127 34 <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
cannam@127 35 <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
cannam@127 36 <link href="Tutorial.html#Tutorial" rel="up" title="Tutorial">
cannam@127 37 <link href="Multi_002dDimensional-DFTs-of-Real-Data.html#Multi_002dDimensional-DFTs-of-Real-Data" rel="next" title="Multi-Dimensional DFTs of Real Data">
cannam@127 38 <link href="Complex-Multi_002dDimensional-DFTs.html#Complex-Multi_002dDimensional-DFTs" rel="prev" title="Complex Multi-Dimensional DFTs">
cannam@127 39 <style type="text/css">
cannam@127 40 <!--
cannam@127 41 a.summary-letter {text-decoration: none}
cannam@127 42 blockquote.smallquotation {font-size: smaller}
cannam@127 43 div.display {margin-left: 3.2em}
cannam@127 44 div.example {margin-left: 3.2em}
cannam@127 45 div.indentedblock {margin-left: 3.2em}
cannam@127 46 div.lisp {margin-left: 3.2em}
cannam@127 47 div.smalldisplay {margin-left: 3.2em}
cannam@127 48 div.smallexample {margin-left: 3.2em}
cannam@127 49 div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
cannam@127 50 div.smalllisp {margin-left: 3.2em}
cannam@127 51 kbd {font-style:oblique}
cannam@127 52 pre.display {font-family: inherit}
cannam@127 53 pre.format {font-family: inherit}
cannam@127 54 pre.menu-comment {font-family: serif}
cannam@127 55 pre.menu-preformatted {font-family: serif}
cannam@127 56 pre.smalldisplay {font-family: inherit; font-size: smaller}
cannam@127 57 pre.smallexample {font-size: smaller}
cannam@127 58 pre.smallformat {font-family: inherit; font-size: smaller}
cannam@127 59 pre.smalllisp {font-size: smaller}
cannam@127 60 span.nocodebreak {white-space:nowrap}
cannam@127 61 span.nolinebreak {white-space:nowrap}
cannam@127 62 span.roman {font-family:serif; font-weight:normal}
cannam@127 63 span.sansserif {font-family:sans-serif; font-weight:normal}
cannam@127 64 ul.no-bullet {list-style: none}
cannam@127 65 -->
cannam@127 66 </style>
cannam@127 67
cannam@127 68
cannam@127 69 </head>
cannam@127 70
cannam@127 71 <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
cannam@127 72 <a name="One_002dDimensional-DFTs-of-Real-Data"></a>
cannam@127 73 <div class="header">
cannam@127 74 <p>
cannam@127 75 Next: <a href="Multi_002dDimensional-DFTs-of-Real-Data.html#Multi_002dDimensional-DFTs-of-Real-Data" accesskey="n" rel="next">Multi-Dimensional DFTs of Real Data</a>, Previous: <a href="Complex-Multi_002dDimensional-DFTs.html#Complex-Multi_002dDimensional-DFTs" accesskey="p" rel="prev">Complex Multi-Dimensional DFTs</a>, Up: <a href="Tutorial.html#Tutorial" accesskey="u" rel="up">Tutorial</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>
cannam@127 76 </div>
cannam@127 77 <hr>
cannam@127 78 <a name="One_002dDimensional-DFTs-of-Real-Data-1"></a>
cannam@127 79 <h3 class="section">2.3 One-Dimensional DFTs of Real Data</h3>
cannam@127 80
cannam@127 81 <p>In many practical applications, the input data <code>in[i]</code> are purely
cannam@127 82 real numbers, in which case the DFT output satisfies the &ldquo;Hermitian&rdquo;
cannam@127 83 <a name="index-Hermitian"></a>
cannam@127 84 redundancy: <code>out[i]</code> is the conjugate of <code>out[n-i]</code>. It is
cannam@127 85 possible to take advantage of these circumstances in order to achieve
cannam@127 86 roughly a factor of two improvement in both speed and memory usage.
cannam@127 87 </p>
cannam@127 88 <p>In exchange for these speed and space advantages, the user sacrifices
cannam@127 89 some of the simplicity of FFTW&rsquo;s complex transforms. First of all, the
cannam@127 90 input and output arrays are of <em>different sizes and types</em>: the
cannam@127 91 input is <code>n</code> real numbers, while the output is <code>n/2+1</code>
cannam@127 92 complex numbers (the non-redundant outputs); this also requires slight
cannam@127 93 &ldquo;padding&rdquo; of the input array for
cannam@127 94 <a name="index-padding"></a>
cannam@127 95 in-place transforms. Second, the inverse transform (complex to real)
cannam@127 96 has the side-effect of <em>overwriting its input array</em>, by default.
cannam@127 97 Neither of these inconveniences should pose a serious problem for
cannam@127 98 users, but it is important to be aware of them.
cannam@127 99 </p>
cannam@127 100 <p>The routines to perform real-data transforms are almost the same as
cannam@127 101 those for complex transforms: you allocate arrays of <code>double</code>
cannam@127 102 and/or <code>fftw_complex</code> (preferably using <code>fftw_malloc</code> or
cannam@127 103 <code>fftw_alloc_complex</code>), create an <code>fftw_plan</code>, execute it as
cannam@127 104 many times as you want with <code>fftw_execute(plan)</code>, and clean up
cannam@127 105 with <code>fftw_destroy_plan(plan)</code> (and <code>fftw_free</code>). The only
cannam@127 106 differences are that the input (or output) is of type <code>double</code>
cannam@127 107 and there are new routines to create the plan. In one dimension:
cannam@127 108 </p>
cannam@127 109 <div class="example">
cannam@127 110 <pre class="example">fftw_plan fftw_plan_dft_r2c_1d(int n, double *in, fftw_complex *out,
cannam@127 111 unsigned flags);
cannam@127 112 fftw_plan fftw_plan_dft_c2r_1d(int n, fftw_complex *in, double *out,
cannam@127 113 unsigned flags);
cannam@127 114 </pre></div>
cannam@127 115 <a name="index-fftw_005fplan_005fdft_005fr2c_005f1d"></a>
cannam@127 116 <a name="index-fftw_005fplan_005fdft_005fc2r_005f1d"></a>
cannam@127 117
cannam@127 118 <p>for the real input to complex-Hermitian output (<em>r2c</em>) and
cannam@127 119 complex-Hermitian input to real output (<em>c2r</em>) transforms.
cannam@127 120 <a name="index-r2c"></a>
cannam@127 121 <a name="index-c2r"></a>
cannam@127 122 Unlike the complex DFT planner, there is no <code>sign</code> argument.
cannam@127 123 Instead, r2c DFTs are always <code>FFTW_FORWARD</code> and c2r DFTs are
cannam@127 124 always <code>FFTW_BACKWARD</code>.
cannam@127 125 <a name="index-FFTW_005fFORWARD-1"></a>
cannam@127 126 <a name="index-FFTW_005fBACKWARD-1"></a>
cannam@127 127 (For single/long-double precision
cannam@127 128 <code>fftwf</code> and <code>fftwl</code>, <code>double</code> should be replaced by
cannam@127 129 <code>float</code> and <code>long double</code>, respectively.)
cannam@127 130 <a name="index-precision-1"></a>
cannam@127 131 </p>
cannam@127 132
cannam@127 133 <p>Here, <code>n</code> is the &ldquo;logical&rdquo; size of the DFT, not necessarily the
cannam@127 134 physical size of the array. In particular, the real (<code>double</code>)
cannam@127 135 array has <code>n</code> elements, while the complex (<code>fftw_complex</code>)
cannam@127 136 array has <code>n/2+1</code> elements (where the division is rounded down).
cannam@127 137 For an in-place transform,
cannam@127 138 <a name="index-in_002dplace-1"></a>
cannam@127 139 <code>in</code> and <code>out</code> are aliased to the same array, which must be
cannam@127 140 big enough to hold both; so, the real array would actually have
cannam@127 141 <code>2*(n/2+1)</code> elements, where the elements beyond the first
cannam@127 142 <code>n</code> are unused padding. (Note that this is very different from
cannam@127 143 the concept of &ldquo;zero-padding&rdquo; a transform to a larger length, which
cannam@127 144 changes the logical size of the DFT by actually adding new input
cannam@127 145 data.) The <em>k</em>th element of the complex array is exactly the
cannam@127 146 same as the <em>k</em>th element of the corresponding complex DFT. All
cannam@127 147 positive <code>n</code> are supported; products of small factors are most
cannam@127 148 efficient, but an <i>O</i>(<i>n</i>&nbsp;log&nbsp;<i>n</i>) algorithm is used even for prime sizes.
cannam@127 149 </p>
cannam@127 150 <p>As noted above, the c2r transform destroys its input array even for
cannam@127 151 out-of-place transforms. This can be prevented, if necessary, by
cannam@127 152 including <code>FFTW_PRESERVE_INPUT</code> in the <code>flags</code>, with
cannam@127 153 unfortunately some sacrifice in performance.
cannam@127 154 <a name="index-flags-1"></a>
cannam@127 155 <a name="index-FFTW_005fPRESERVE_005fINPUT"></a>
cannam@127 156 This flag is also not currently supported for multi-dimensional real
cannam@127 157 DFTs (next section).
cannam@127 158 </p>
cannam@127 159 <p>Readers familiar with DFTs of real data will recall that the 0th (the
cannam@127 160 &ldquo;DC&rdquo;) and <code>n/2</code>-th (the &ldquo;Nyquist&rdquo; frequency, when <code>n</code> is
cannam@127 161 even) elements of the complex output are purely real. Some
cannam@127 162 implementations therefore store the Nyquist element where the DC
cannam@127 163 imaginary part would go, in order to make the input and output arrays
cannam@127 164 the same size. Such packing, however, does not generalize well to
cannam@127 165 multi-dimensional transforms, and the space savings are miniscule in
cannam@127 166 any case; FFTW does not support it.
cannam@127 167 </p>
cannam@127 168 <p>An alternative interface for one-dimensional r2c and c2r DFTs can be
cannam@127 169 found in the &lsquo;<samp>r2r</samp>&rsquo; interface (see <a href="The-Halfcomplex_002dformat-DFT.html#The-Halfcomplex_002dformat-DFT">The Halfcomplex-format DFT</a>), with &ldquo;halfcomplex&rdquo;-format output that <em>is</em> the same size
cannam@127 170 (and type) as the input array.
cannam@127 171 <a name="index-halfcomplex-format"></a>
cannam@127 172 That interface, although it is not very useful for multi-dimensional
cannam@127 173 transforms, may sometimes yield better performance.
cannam@127 174 </p>
cannam@127 175 <hr>
cannam@127 176 <div class="header">
cannam@127 177 <p>
cannam@127 178 Next: <a href="Multi_002dDimensional-DFTs-of-Real-Data.html#Multi_002dDimensional-DFTs-of-Real-Data" accesskey="n" rel="next">Multi-Dimensional DFTs of Real Data</a>, Previous: <a href="Complex-Multi_002dDimensional-DFTs.html#Complex-Multi_002dDimensional-DFTs" accesskey="p" rel="prev">Complex Multi-Dimensional DFTs</a>, Up: <a href="Tutorial.html#Tutorial" accesskey="u" rel="up">Tutorial</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>
cannam@127 179 </div>
cannam@127 180
cannam@127 181
cannam@127 182
cannam@127 183 </body>
cannam@127 184 </html>