annotate src/fftw-3.3.8/doc/html/Complex-One_002dDimensional-DFTs.html @ 84:08ae793730bd

Add null config files
author Chris Cannam
date Mon, 02 Mar 2020 14:03:47 +0000
parents d0c2a83c1364
children
rev   line source
Chris@82 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Chris@82 2 <html>
Chris@82 3 <!-- This manual is for FFTW
Chris@82 4 (version 3.3.8, 24 May 2018).
Chris@82 5
Chris@82 6 Copyright (C) 2003 Matteo Frigo.
Chris@82 7
Chris@82 8 Copyright (C) 2003 Massachusetts Institute of Technology.
Chris@82 9
Chris@82 10 Permission is granted to make and distribute verbatim copies of this
Chris@82 11 manual provided the copyright notice and this permission notice are
Chris@82 12 preserved on all copies.
Chris@82 13
Chris@82 14 Permission is granted to copy and distribute modified versions of this
Chris@82 15 manual under the conditions for verbatim copying, provided that the
Chris@82 16 entire resulting derived work is distributed under the terms of a
Chris@82 17 permission notice identical to this one.
Chris@82 18
Chris@82 19 Permission is granted to copy and distribute translations of this manual
Chris@82 20 into another language, under the above conditions for modified versions,
Chris@82 21 except that this permission notice may be stated in a translation
Chris@82 22 approved by the Free Software Foundation. -->
Chris@82 23 <!-- Created by GNU Texinfo 6.3, http://www.gnu.org/software/texinfo/ -->
Chris@82 24 <head>
Chris@82 25 <title>FFTW 3.3.8: Complex One-Dimensional DFTs</title>
Chris@82 26
Chris@82 27 <meta name="description" content="FFTW 3.3.8: Complex One-Dimensional DFTs">
Chris@82 28 <meta name="keywords" content="FFTW 3.3.8: Complex One-Dimensional DFTs">
Chris@82 29 <meta name="resource-type" content="document">
Chris@82 30 <meta name="distribution" content="global">
Chris@82 31 <meta name="Generator" content="makeinfo">
Chris@82 32 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Chris@82 33 <link href="index.html#Top" rel="start" title="Top">
Chris@82 34 <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
Chris@82 35 <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
Chris@82 36 <link href="Tutorial.html#Tutorial" rel="up" title="Tutorial">
Chris@82 37 <link href="Complex-Multi_002dDimensional-DFTs.html#Complex-Multi_002dDimensional-DFTs" rel="next" title="Complex Multi-Dimensional DFTs">
Chris@82 38 <link href="Tutorial.html#Tutorial" rel="prev" title="Tutorial">
Chris@82 39 <style type="text/css">
Chris@82 40 <!--
Chris@82 41 a.summary-letter {text-decoration: none}
Chris@82 42 blockquote.indentedblock {margin-right: 0em}
Chris@82 43 blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
Chris@82 44 blockquote.smallquotation {font-size: smaller}
Chris@82 45 div.display {margin-left: 3.2em}
Chris@82 46 div.example {margin-left: 3.2em}
Chris@82 47 div.lisp {margin-left: 3.2em}
Chris@82 48 div.smalldisplay {margin-left: 3.2em}
Chris@82 49 div.smallexample {margin-left: 3.2em}
Chris@82 50 div.smalllisp {margin-left: 3.2em}
Chris@82 51 kbd {font-style: oblique}
Chris@82 52 pre.display {font-family: inherit}
Chris@82 53 pre.format {font-family: inherit}
Chris@82 54 pre.menu-comment {font-family: serif}
Chris@82 55 pre.menu-preformatted {font-family: serif}
Chris@82 56 pre.smalldisplay {font-family: inherit; font-size: smaller}
Chris@82 57 pre.smallexample {font-size: smaller}
Chris@82 58 pre.smallformat {font-family: inherit; font-size: smaller}
Chris@82 59 pre.smalllisp {font-size: smaller}
Chris@82 60 span.nolinebreak {white-space: nowrap}
Chris@82 61 span.roman {font-family: initial; font-weight: normal}
Chris@82 62 span.sansserif {font-family: sans-serif; font-weight: normal}
Chris@82 63 ul.no-bullet {list-style: none}
Chris@82 64 -->
Chris@82 65 </style>
Chris@82 66
Chris@82 67
Chris@82 68 </head>
Chris@82 69
Chris@82 70 <body lang="en">
Chris@82 71 <a name="Complex-One_002dDimensional-DFTs"></a>
Chris@82 72 <div class="header">
Chris@82 73 <p>
Chris@82 74 Next: <a href="Complex-Multi_002dDimensional-DFTs.html#Complex-Multi_002dDimensional-DFTs" accesskey="n" rel="next">Complex Multi-Dimensional DFTs</a>, Previous: <a href="Tutorial.html#Tutorial" accesskey="p" rel="prev">Tutorial</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>
Chris@82 75 </div>
Chris@82 76 <hr>
Chris@82 77 <a name="Complex-One_002dDimensional-DFTs-1"></a>
Chris@82 78 <h3 class="section">2.1 Complex One-Dimensional DFTs</h3>
Chris@82 79
Chris@82 80 <blockquote>
Chris@82 81 <p>Plan: To bother about the best method of accomplishing an accidental result.
Chris@82 82 [Ambrose Bierce, <cite>The Enlarged Devil&rsquo;s Dictionary</cite>.]
Chris@82 83 <a name="index-Devil"></a>
Chris@82 84 </p></blockquote>
Chris@82 85
Chris@82 86
Chris@82 87 <p>The basic usage of FFTW to compute a one-dimensional DFT of size
Chris@82 88 <code>N</code> is simple, and it typically looks something like this code:
Chris@82 89 </p>
Chris@82 90 <div class="example">
Chris@82 91 <pre class="example">#include &lt;fftw3.h&gt;
Chris@82 92 ...
Chris@82 93 {
Chris@82 94 fftw_complex *in, *out;
Chris@82 95 fftw_plan p;
Chris@82 96 ...
Chris@82 97 in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
Chris@82 98 out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
Chris@82 99 p = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
Chris@82 100 ...
Chris@82 101 fftw_execute(p); /* <span class="roman">repeat as needed</span> */
Chris@82 102 ...
Chris@82 103 fftw_destroy_plan(p);
Chris@82 104 fftw_free(in); fftw_free(out);
Chris@82 105 }
Chris@82 106 </pre></div>
Chris@82 107
Chris@82 108 <p>You must link this code with the <code>fftw3</code> library. On Unix systems,
Chris@82 109 link with <code>-lfftw3 -lm</code>.
Chris@82 110 </p>
Chris@82 111 <p>The example code first allocates the input and output arrays. You can
Chris@82 112 allocate them in any way that you like, but we recommend using
Chris@82 113 <code>fftw_malloc</code>, which behaves like
Chris@82 114 <a name="index-fftw_005fmalloc"></a>
Chris@82 115 <code>malloc</code> except that it properly aligns the array when SIMD
Chris@82 116 instructions (such as SSE and Altivec) are available (see <a href="SIMD-alignment-and-fftw_005fmalloc.html#SIMD-alignment-and-fftw_005fmalloc">SIMD alignment and fftw_malloc</a>). [Alternatively, we provide a convenient wrapper function <code>fftw_alloc_complex(N)</code> which has the same effect.]
Chris@82 117 <a name="index-fftw_005falloc_005fcomplex"></a>
Chris@82 118 <a name="index-SIMD"></a>
Chris@82 119 </p>
Chris@82 120
Chris@82 121 <p>The data is an array of type <code>fftw_complex</code>, which is by default a
Chris@82 122 <code>double[2]</code> composed of the real (<code>in[i][0]</code>) and imaginary
Chris@82 123 (<code>in[i][1]</code>) parts of a complex number.
Chris@82 124 <a name="index-fftw_005fcomplex"></a>
Chris@82 125 </p>
Chris@82 126 <p>The next step is to create a <em>plan</em>, which is an object
Chris@82 127 <a name="index-plan-1"></a>
Chris@82 128 that contains all the data that FFTW needs to compute the FFT.
Chris@82 129 This function creates the plan:
Chris@82 130 </p>
Chris@82 131 <div class="example">
Chris@82 132 <pre class="example">fftw_plan fftw_plan_dft_1d(int n, fftw_complex *in, fftw_complex *out,
Chris@82 133 int sign, unsigned flags);
Chris@82 134 </pre></div>
Chris@82 135 <a name="index-fftw_005fplan_005fdft_005f1d"></a>
Chris@82 136 <a name="index-fftw_005fplan"></a>
Chris@82 137
Chris@82 138 <p>The first argument, <code>n</code>, is the size of the transform you are
Chris@82 139 trying to compute. The size <code>n</code> can be any positive integer, but
Chris@82 140 sizes that are products of small factors are transformed most
Chris@82 141 efficiently (although prime sizes still use an <i>O</i>(<i>n</i>&nbsp;log&nbsp;<i>n</i>)
Chris@82 142 algorithm).
Chris@82 143 </p>
Chris@82 144 <p>The next two arguments are pointers to the input and output arrays of
Chris@82 145 the transform. These pointers can be equal, indicating an
Chris@82 146 <em>in-place</em> transform.
Chris@82 147 <a name="index-in_002dplace"></a>
Chris@82 148 </p>
Chris@82 149
Chris@82 150 <p>The fourth argument, <code>sign</code>, can be either <code>FFTW_FORWARD</code>
Chris@82 151 (<code>-1</code>) or <code>FFTW_BACKWARD</code> (<code>+1</code>),
Chris@82 152 <a name="index-FFTW_005fFORWARD"></a>
Chris@82 153 <a name="index-FFTW_005fBACKWARD"></a>
Chris@82 154 and indicates the direction of the transform you are interested in;
Chris@82 155 technically, it is the sign of the exponent in the transform.
Chris@82 156 </p>
Chris@82 157 <p>The <code>flags</code> argument is usually either <code>FFTW_MEASURE</code> or
Chris@82 158 <a name="index-flags"></a>
Chris@82 159 <code>FFTW_ESTIMATE</code>. <code>FFTW_MEASURE</code> instructs FFTW to run
Chris@82 160 <a name="index-FFTW_005fMEASURE"></a>
Chris@82 161 and measure the execution time of several FFTs in order to find the
Chris@82 162 best way to compute the transform of size <code>n</code>. This process takes
Chris@82 163 some time (usually a few seconds), depending on your machine and on
Chris@82 164 the size of the transform. <code>FFTW_ESTIMATE</code>, on the contrary,
Chris@82 165 does not run any computation and just builds a
Chris@82 166 <a name="index-FFTW_005fESTIMATE"></a>
Chris@82 167 reasonable plan that is probably sub-optimal. In short, if your
Chris@82 168 program performs many transforms of the same size and initialization
Chris@82 169 time is not important, use <code>FFTW_MEASURE</code>; otherwise use the
Chris@82 170 estimate.
Chris@82 171 </p>
Chris@82 172 <p><em>You must create the plan before initializing the input</em>, because
Chris@82 173 <code>FFTW_MEASURE</code> overwrites the <code>in</code>/<code>out</code> arrays.
Chris@82 174 (Technically, <code>FFTW_ESTIMATE</code> does not touch your arrays, but you
Chris@82 175 should always create plans first just to be sure.)
Chris@82 176 </p>
Chris@82 177 <p>Once the plan has been created, you can use it as many times as you
Chris@82 178 like for transforms on the specified <code>in</code>/<code>out</code> arrays,
Chris@82 179 computing the actual transforms via <code>fftw_execute(plan)</code>:
Chris@82 180 </p><div class="example">
Chris@82 181 <pre class="example">void fftw_execute(const fftw_plan plan);
Chris@82 182 </pre></div>
Chris@82 183 <a name="index-fftw_005fexecute"></a>
Chris@82 184
Chris@82 185 <p>The DFT results are stored in-order in the array <code>out</code>, with the
Chris@82 186 zero-frequency (DC) component in <code>out[0]</code>.
Chris@82 187 <a name="index-frequency"></a>
Chris@82 188 If <code>in != out</code>, the transform is <em>out-of-place</em> and the input
Chris@82 189 array <code>in</code> is not modified. Otherwise, the input array is
Chris@82 190 overwritten with the transform.
Chris@82 191 </p>
Chris@82 192 <a name="index-execute-1"></a>
Chris@82 193 <p>If you want to transform a <em>different</em> array of the same size, you
Chris@82 194 can create a new plan with <code>fftw_plan_dft_1d</code> and FFTW
Chris@82 195 automatically reuses the information from the previous plan, if
Chris@82 196 possible. Alternatively, with the &ldquo;guru&rdquo; interface you can apply a
Chris@82 197 given plan to a different array, if you are careful.
Chris@82 198 See <a href="FFTW-Reference.html#FFTW-Reference">FFTW Reference</a>.
Chris@82 199 </p>
Chris@82 200 <p>When you are done with the plan, you deallocate it by calling
Chris@82 201 <code>fftw_destroy_plan(plan)</code>:
Chris@82 202 </p><div class="example">
Chris@82 203 <pre class="example">void fftw_destroy_plan(fftw_plan plan);
Chris@82 204 </pre></div>
Chris@82 205 <a name="index-fftw_005fdestroy_005fplan"></a>
Chris@82 206 <p>If you allocate an array with <code>fftw_malloc()</code> you must deallocate
Chris@82 207 it with <code>fftw_free()</code>. Do not use <code>free()</code> or, heaven
Chris@82 208 forbid, <code>delete</code>.
Chris@82 209 <a name="index-fftw_005ffree"></a>
Chris@82 210 </p>
Chris@82 211 <p>FFTW computes an <em>unnormalized</em> DFT. Thus, computing a forward
Chris@82 212 followed by a backward transform (or vice versa) results in the original
Chris@82 213 array scaled by <code>n</code>. For the definition of the DFT, see <a href="What-FFTW-Really-Computes.html#What-FFTW-Really-Computes">What FFTW Really Computes</a>.
Chris@82 214 <a name="index-DFT-1"></a>
Chris@82 215 <a name="index-normalization"></a>
Chris@82 216 </p>
Chris@82 217
Chris@82 218 <p>If you have a C compiler, such as <code>gcc</code>, that supports the
Chris@82 219 C99 standard, and you <code>#include &lt;complex.h&gt;</code> <em>before</em>
Chris@82 220 <code>&lt;fftw3.h&gt;</code>, then <code>fftw_complex</code> is the native
Chris@82 221 double-precision complex type and you can manipulate it with ordinary
Chris@82 222 arithmetic. Otherwise, FFTW defines its own complex type, which is
Chris@82 223 bit-compatible with the C99 complex type. See <a href="Complex-numbers.html#Complex-numbers">Complex numbers</a>.
Chris@82 224 (The C++ <code>&lt;complex&gt;</code> template class may also be usable via a
Chris@82 225 typecast.)
Chris@82 226 <a name="index-C_002b_002b"></a>
Chris@82 227 </p>
Chris@82 228 <p>To use single or long-double precision versions of FFTW, replace the
Chris@82 229 <code>fftw_</code> prefix by <code>fftwf_</code> or <code>fftwl_</code> and link with
Chris@82 230 <code>-lfftw3f</code> or <code>-lfftw3l</code>, but use the <em>same</em>
Chris@82 231 <code>&lt;fftw3.h&gt;</code> header file.
Chris@82 232 <a name="index-precision"></a>
Chris@82 233 </p>
Chris@82 234
Chris@82 235 <p>Many more flags exist besides <code>FFTW_MEASURE</code> and
Chris@82 236 <code>FFTW_ESTIMATE</code>. For example, use <code>FFTW_PATIENT</code> if you&rsquo;re
Chris@82 237 willing to wait even longer for a possibly even faster plan (see <a href="FFTW-Reference.html#FFTW-Reference">FFTW Reference</a>).
Chris@82 238 <a name="index-FFTW_005fPATIENT"></a>
Chris@82 239 You can also save plans for future use, as described by <a href="Words-of-Wisdom_002dSaving-Plans.html#Words-of-Wisdom_002dSaving-Plans">Words of Wisdom-Saving Plans</a>.
Chris@82 240 </p>
Chris@82 241 <hr>
Chris@82 242 <div class="header">
Chris@82 243 <p>
Chris@82 244 Next: <a href="Complex-Multi_002dDimensional-DFTs.html#Complex-Multi_002dDimensional-DFTs" accesskey="n" rel="next">Complex Multi-Dimensional DFTs</a>, Previous: <a href="Tutorial.html#Tutorial" accesskey="p" rel="prev">Tutorial</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>
Chris@82 245 </div>
Chris@82 246
Chris@82 247
Chris@82 248
Chris@82 249 </body>
Chris@82 250 </html>