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