annotate src/fftw-3.3.8/doc/html/Complex-One_002dDimensional-DFTs.html @ 169:223a55898ab9 tip default

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