annotate fft/fftw/fftw-3.3.4/doc/html/Multi_002dDimensional-DFTs-of-Real-Data.html @ 40:223f770b5341 kissfft-double tip

Try a double-precision kissfft
author Chris Cannam
date Wed, 07 Sep 2016 10:40:32 +0100
parents 26056e866c29
children
rev   line source
Chris@19 1 <html lang="en">
Chris@19 2 <head>
Chris@19 3 <title>Multi-Dimensional DFTs of Real Data - FFTW 3.3.4</title>
Chris@19 4 <meta http-equiv="Content-Type" content="text/html">
Chris@19 5 <meta name="description" content="FFTW 3.3.4">
Chris@19 6 <meta name="generator" content="makeinfo 4.13">
Chris@19 7 <link title="Top" rel="start" href="index.html#Top">
Chris@19 8 <link rel="up" href="Tutorial.html#Tutorial" title="Tutorial">
Chris@19 9 <link rel="prev" href="One_002dDimensional-DFTs-of-Real-Data.html#One_002dDimensional-DFTs-of-Real-Data" title="One-Dimensional DFTs of Real Data">
Chris@19 10 <link rel="next" href="More-DFTs-of-Real-Data.html#More-DFTs-of-Real-Data" title="More DFTs of Real Data">
Chris@19 11 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
Chris@19 12 <!--
Chris@19 13 This manual is for FFTW
Chris@19 14 (version 3.3.4, 20 September 2013).
Chris@19 15
Chris@19 16 Copyright (C) 2003 Matteo Frigo.
Chris@19 17
Chris@19 18 Copyright (C) 2003 Massachusetts Institute of Technology.
Chris@19 19
Chris@19 20 Permission is granted to make and distribute verbatim copies of
Chris@19 21 this manual provided the copyright notice and this permission
Chris@19 22 notice are preserved on all copies.
Chris@19 23
Chris@19 24 Permission is granted to copy and distribute modified versions of
Chris@19 25 this manual under the conditions for verbatim copying, provided
Chris@19 26 that the entire resulting derived work is distributed under the
Chris@19 27 terms of a permission notice identical to this one.
Chris@19 28
Chris@19 29 Permission is granted to copy and distribute translations of this
Chris@19 30 manual into another language, under the above conditions for
Chris@19 31 modified versions, except that this permission notice may be
Chris@19 32 stated in a translation approved by the Free Software Foundation.
Chris@19 33 -->
Chris@19 34 <meta http-equiv="Content-Style-Type" content="text/css">
Chris@19 35 <style type="text/css"><!--
Chris@19 36 pre.display { font-family:inherit }
Chris@19 37 pre.format { font-family:inherit }
Chris@19 38 pre.smalldisplay { font-family:inherit; font-size:smaller }
Chris@19 39 pre.smallformat { font-family:inherit; font-size:smaller }
Chris@19 40 pre.smallexample { font-size:smaller }
Chris@19 41 pre.smalllisp { font-size:smaller }
Chris@19 42 span.sc { font-variant:small-caps }
Chris@19 43 span.roman { font-family:serif; font-weight:normal; }
Chris@19 44 span.sansserif { font-family:sans-serif; font-weight:normal; }
Chris@19 45 --></style>
Chris@19 46 </head>
Chris@19 47 <body>
Chris@19 48 <div class="node">
Chris@19 49 <a name="Multi-Dimensional-DFTs-of-Real-Data"></a>
Chris@19 50 <a name="Multi_002dDimensional-DFTs-of-Real-Data"></a>
Chris@19 51 <p>
Chris@19 52 Next:&nbsp;<a rel="next" accesskey="n" href="More-DFTs-of-Real-Data.html#More-DFTs-of-Real-Data">More DFTs of Real Data</a>,
Chris@19 53 Previous:&nbsp;<a rel="previous" accesskey="p" href="One_002dDimensional-DFTs-of-Real-Data.html#One_002dDimensional-DFTs-of-Real-Data">One-Dimensional DFTs of Real Data</a>,
Chris@19 54 Up:&nbsp;<a rel="up" accesskey="u" href="Tutorial.html#Tutorial">Tutorial</a>
Chris@19 55 <hr>
Chris@19 56 </div>
Chris@19 57
Chris@19 58 <h3 class="section">2.4 Multi-Dimensional DFTs of Real Data</h3>
Chris@19 59
Chris@19 60 <p>Multi-dimensional DFTs of real data use the following planner routines:
Chris@19 61
Chris@19 62 <pre class="example"> fftw_plan fftw_plan_dft_r2c_2d(int n0, int n1,
Chris@19 63 double *in, fftw_complex *out,
Chris@19 64 unsigned flags);
Chris@19 65 fftw_plan fftw_plan_dft_r2c_3d(int n0, int n1, int n2,
Chris@19 66 double *in, fftw_complex *out,
Chris@19 67 unsigned flags);
Chris@19 68 fftw_plan fftw_plan_dft_r2c(int rank, const int *n,
Chris@19 69 double *in, fftw_complex *out,
Chris@19 70 unsigned flags);
Chris@19 71 </pre>
Chris@19 72 <p><a name="index-fftw_005fplan_005fdft_005fr2c_005f2d-59"></a><a name="index-fftw_005fplan_005fdft_005fr2c_005f3d-60"></a><a name="index-fftw_005fplan_005fdft_005fr2c-61"></a>
Chris@19 73 as well as the corresponding <code>c2r</code> routines with the input/output
Chris@19 74 types swapped. These routines work similarly to their complex
Chris@19 75 analogues, except for the fact that here the complex output array is cut
Chris@19 76 roughly in half and the real array requires padding for in-place
Chris@19 77 transforms (as in 1d, above).
Chris@19 78
Chris@19 79 <p>As before, <code>n</code> is the logical size of the array, and the
Chris@19 80 consequences of this on the the format of the complex arrays deserve
Chris@19 81 careful attention.
Chris@19 82 <a name="index-r2c_002fc2r-multi_002ddimensional-array-format-62"></a>Suppose that the real data has dimensions n<sub>0</sub>&nbsp;&times;&nbsp;n<sub>1</sub>&nbsp;&times;&nbsp;n<sub>2</sub>&nbsp;&times;&nbsp;&hellip;&nbsp;&times;&nbsp;n<sub>d-1</sub> (in row-major order).
Chris@19 83 Then, after an r2c transform, the output is an n<sub>0</sub>&nbsp;&times;&nbsp;n<sub>1</sub>&nbsp;&times;&nbsp;n<sub>2</sub>&nbsp;&times;&nbsp;&hellip;&nbsp;&times;&nbsp;(n<sub>d-1</sub>/2 + 1) array of
Chris@19 84 <code>fftw_complex</code> values in row-major order, corresponding to slightly
Chris@19 85 over half of the output of the corresponding complex DFT. (The division
Chris@19 86 is rounded down.) The ordering of the data is otherwise exactly the
Chris@19 87 same as in the complex-DFT case.
Chris@19 88
Chris@19 89 <p>For out-of-place transforms, this is the end of the story: the real
Chris@19 90 data is stored as a row-major array of size n<sub>0</sub>&nbsp;&times;&nbsp;n<sub>1</sub>&nbsp;&times;&nbsp;n<sub>2</sub>&nbsp;&times;&nbsp;&hellip;&nbsp;&times;&nbsp;n<sub>d-1</sub> and the complex
Chris@19 91 data is stored as a row-major array of size n<sub>0</sub>&nbsp;&times;&nbsp;n<sub>1</sub>&nbsp;&times;&nbsp;n<sub>2</sub>&nbsp;&times;&nbsp;&hellip;&nbsp;&times;&nbsp;(n<sub>d-1</sub>/2 + 1).
Chris@19 92
Chris@19 93 <p>For in-place transforms, however, extra padding of the real-data array
Chris@19 94 is necessary because the complex array is larger than the real array,
Chris@19 95 and the two arrays share the same memory locations. Thus, for
Chris@19 96 in-place transforms, the final dimension of the real-data array must
Chris@19 97 be padded with extra values to accommodate the size of the complex
Chris@19 98 data&mdash;two values if the last dimension is even and one if it is odd.
Chris@19 99 <a name="index-padding-63"></a>That is, the last dimension of the real data must physically contain
Chris@19 100 2 * (n<sub>d-1</sub>/2+1)<code>double</code> values (exactly enough to hold the complex data).
Chris@19 101 This physical array size does not, however, change the <em>logical</em>
Chris@19 102 array size&mdash;only
Chris@19 103 n<sub>d-1</sub>values are actually stored in the last dimension, and
Chris@19 104 n<sub>d-1</sub>is the last dimension passed to the plan-creation routine.
Chris@19 105
Chris@19 106 <p>For example, consider the transform of a two-dimensional real array of
Chris@19 107 size <code>n0</code> by <code>n1</code>. The output of the r2c transform is a
Chris@19 108 two-dimensional complex array of size <code>n0</code> by <code>n1/2+1</code>, where
Chris@19 109 the <code>y</code> dimension has been cut nearly in half because of
Chris@19 110 redundancies in the output. Because <code>fftw_complex</code> is twice the
Chris@19 111 size of <code>double</code>, the output array is slightly bigger than the
Chris@19 112 input array. Thus, if we want to compute the transform in place, we
Chris@19 113 must <em>pad</em> the input array so that it is of size <code>n0</code> by
Chris@19 114 <code>2*(n1/2+1)</code>. If <code>n1</code> is even, then there are two padding
Chris@19 115 elements at the end of each row (which need not be initialized, as they
Chris@19 116 are only used for output).
Chris@19 117
Chris@19 118 <p>The following illustration depicts the input and output arrays just
Chris@19 119 described, for both the out-of-place and in-place transforms (with the
Chris@19 120 arrows indicating consecutive memory locations):
Chris@19 121 <img src="rfftwnd-for-html.png" alt="rfftwnd-for-html.png">
Chris@19 122
Chris@19 123 <p>These transforms are unnormalized, so an r2c followed by a c2r
Chris@19 124 transform (or vice versa) will result in the original data scaled by
Chris@19 125 the number of real data elements&mdash;that is, the product of the
Chris@19 126 (logical) dimensions of the real data.
Chris@19 127 <a name="index-normalization-64"></a>
Chris@19 128
Chris@19 129 <p>(Because the last dimension is treated specially, if it is equal to
Chris@19 130 <code>1</code> the transform is <em>not</em> equivalent to a lower-dimensional
Chris@19 131 r2c/c2r transform. In that case, the last complex dimension also has
Chris@19 132 size <code>1</code> (<code>=1/2+1</code>), and no advantage is gained over the
Chris@19 133 complex transforms.)
Chris@19 134
Chris@19 135 <!-- -->
Chris@19 136 </body></html>
Chris@19 137