ITK  4.10.0
Insight Segmentation and Registration Toolkit
itkFFTWCommonExtended.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkFFTWCommon.h,v $
5  Language: C++
6  Date: $Date: 2008-12-21 19:13:11 $
7  Version: $Revision: 1.8 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkFFTWCommonExtended_h
18 #define __itkFFTWCommonExtended_h
19 
21 
22 #if defined(ITK_USE_FFTWF) || defined(ITK_USE_FFTWD)
23 #include "fftw3.h"
24 #endif
25 
26 #include "itkMutexLockHolder.h"
27 
28 namespace itk
29 {
30 namespace fftw
31 {
38 template <typename TPixel>
40 {
41  // empty -- only double and float specializations work
42 protected:
45 };
47 
48 #if defined(ITK_USE_FFTWF)
49 
50 template <>
52 {
53 public:
54  typedef float PixelType;
55  typedef fftwf_complex ComplexType;
56  typedef fftwf_plan PlanType;
58 
59  static PlanType Plan_dft_c2r_1d(int n,
60  ComplexType *in,
61  PixelType *out,
62  unsigned flags,
63  int threads=1)
64  {
66  fftwf_plan_with_nthreads(threads);
67  PlanType plan = fftwf_plan_dft_c2r_1d(n,in,out,flags);
68  return plan;
69  }
70  static PlanType Plan_dft_c2r_2d(int nx,
71  int ny,
72  ComplexType *in,
73  PixelType *out,
74  unsigned flags,
75  int threads=1)
76  {
78  fftwf_plan_with_nthreads(threads);
79  PlanType plan = fftwf_plan_dft_c2r_2d(nx,ny,in,out,flags);
80  return plan;
81  }
82  static PlanType Plan_dft_c2r_3d(int nx,
83  int ny,
84  int nz,
85  ComplexType *in,
86  PixelType *out,
87  unsigned flags,
88  int threads=1)
89  {
91  fftwf_plan_with_nthreads(threads);
92  PlanType plan = fftwf_plan_dft_c2r_3d(nx,ny,nz,in,out,flags);
93  return plan;
94  }
95  static PlanType Plan_dft_c2r(int rank,
96  const int *n,
97  ComplexType *in,
98  PixelType *out,
99  unsigned flags,
100  int threads=1)
101  {
103  fftwf_plan_with_nthreads(threads);
104  PlanType plan = fftwf_plan_dft_c2r(rank,n,in,out,flags);
105  return plan;
106  }
107 
108  static PlanType Plan_dft_r2c_1d(int n,
109  PixelType *in,
110  ComplexType *out,
111  unsigned flags,
112  int threads=1)
113  {
115  fftwf_plan_with_nthreads(threads);
116  PlanType plan = fftwf_plan_dft_r2c_1d(n,in,out,flags);
117  return plan;
118  }
119  static PlanType Plan_dft_r2c_2d(int nx,
120  int ny,
121  PixelType *in,
122  ComplexType *out,
123  unsigned flags,
124  int threads=1)
125  {
127  fftwf_plan_with_nthreads(threads);
128  PlanType plan = fftwf_plan_dft_r2c_2d(nx,ny,in,out,flags);
129  return plan;
130  }
131  static PlanType Plan_dft_r2c_3d(int nx,
132  int ny,
133  int nz,
134  PixelType *in,
135  ComplexType *out,
136  unsigned flags,
137  int threads=1)
138  {
140  fftwf_plan_with_nthreads(threads);
141  PlanType plan = fftwf_plan_dft_r2c_3d(nx,ny,nz,in,out,flags);
142  return plan;
143  }
144  static PlanType Plan_dft_r2c(int rank,
145  const int *n,
146  PixelType *in,
147  ComplexType *out,
148  unsigned flags,
149  int threads=1)
150  {
152  fftwf_plan_with_nthreads(threads);
153  PlanType plan = fftwf_plan_dft_r2c(rank,n,in,out,flags);
154  return plan;
155  }
156  static PlanType Plan_dft_1d(const int n,
157  ComplexType *in,
158  ComplexType *out,
159  int sign,
160  unsigned flags,
161  int threads=1)
162  {
164  fftwf_plan_with_nthreads(threads);
165  PlanType plan = fftwf_plan_dft_1d(n,in,out,sign,flags);
166  return plan;
167  }
168 
169 
170  static void Execute(PlanType p)
171  {
172  fftwf_execute(p);
173  }
174  static void DestroyPlan(PlanType p)
175  {
176  fftwf_destroy_plan(p);
177  }
178 };
179 
180 #endif // USE_FFTWF
181 
182 
183 #if defined(ITK_USE_FFTWD)
184 template <>
186 {
187 public:
188  typedef double PixelType;
189  typedef fftw_complex ComplexType;
190  typedef fftw_plan PlanType;
192 
193  static PlanType Plan_dft_c2r_1d(int n,
194  ComplexType *in,
195  PixelType *out,
196  unsigned flags,
197  int threads=1)
198  {
200  fftw_plan_with_nthreads(threads);
201  PlanType plan = fftw_plan_dft_c2r_1d(n,in,out,flags);
202  return plan;
203  }
204  static PlanType Plan_dft_c2r_2d(int nx,
205  int ny,
206  ComplexType *in,
207  PixelType *out,
208  unsigned flags,
209  int threads=1)
210  {
212  fftw_plan_with_nthreads(threads);
213  PlanType plan = fftw_plan_dft_c2r_2d(nx,ny,in,out,flags);
214  return plan;
215  }
216  static PlanType Plan_dft_c2r_3d(int nx,
217  int ny,
218  int nz,
219  ComplexType *in,
220  PixelType *out,
221  unsigned flags,
222  int threads=1)
223  {
225  fftw_plan_with_nthreads(threads);
226  PlanType plan = fftw_plan_dft_c2r_3d(nx,ny,nz,in,out,flags);
227  return plan;
228  }
229  static PlanType Plan_dft_c2r(int rank,
230  const int *n,
231  ComplexType *in,
232  PixelType *out,
233  unsigned flags,
234  int threads=1)
235  {
237  fftw_plan_with_nthreads(threads);
238  PlanType plan = fftw_plan_dft_c2r(rank,n,in,out,flags);
239  return plan;
240  }
241 
242  static PlanType Plan_dft_r2c_1d(int n,
243  PixelType *in,
244  ComplexType *out,
245  unsigned flags,
246  int threads=1)
247  {
249  fftw_plan_with_nthreads(threads);
250  PlanType plan = fftw_plan_dft_r2c_1d(n,in,out,flags);
251  return plan;
252  }
253  static PlanType Plan_dft_r2c_2d(int nx,
254  int ny,
255  PixelType *in,
256  ComplexType *out,
257  unsigned flags,
258  int threads=1)
259  {
261  fftw_plan_with_nthreads(threads);
262  PlanType plan = fftw_plan_dft_r2c_2d(nx,ny,in,out,flags);
263  return plan;
264  }
265  static PlanType Plan_dft_r2c_3d(int nx,
266  int ny,
267  int nz,
268  PixelType *in,
269  ComplexType *out,
270  unsigned flags,
271  int threads=1)
272  {
274  fftw_plan_with_nthreads(threads);
275  PlanType plan = fftw_plan_dft_r2c_3d(nx,ny,nz,in,out,flags);
276  return plan;
277  }
278  static PlanType Plan_dft_r2c(int rank,
279  const int *n,
280  PixelType *in,
281  ComplexType *out,
282  unsigned flags,
283  int threads=1)
284  {
286  fftw_plan_with_nthreads(threads);
287  PlanType plan = fftw_plan_dft_r2c(rank,n,in,out,flags);
288  return plan;
289  }
290  static PlanType Plan_dft_1d(const int n,
291  ComplexType *in,
292  ComplexType *out,
293  int sign,
294  unsigned flags,
295  int threads=1)
296  {
298  fftw_plan_with_nthreads(threads);
299  PlanType plan = fftw_plan_dft_1d(n,in,out,sign,flags);
300  return plan;
301  }
302 
303  static void Execute(PlanType p)
304  {
305  fftw_execute(p);
306  }
307  static void DestroyPlan(PlanType p)
308  {
309  fftw_destroy_plan(p);
310  }
311 };
312 
313 #endif
314 }
315 }
316 #endif
static PlanType Plan_dft_c2r_1d(int n, ComplexType *in, PixelType *out, unsigned flags, int threads=1)
static SimpleFastMutexLock & GetLockMutex()
A container to store a Mutex. This holder class for ensuring that locks are released in the event of ...
static PlanType Plan_dft_c2r(int rank, const int *n, ComplexType *in, PixelType *out, unsigned flags, int threads=1)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes...
Definition: itkArray.h:30
static PlanType Plan_dft_c2r_2d(int nx, int ny, ComplexType *in, PixelType *out, unsigned flags, int threads=1)
static PlanType Plan_dft_r2c_2d(int nx, int ny, PixelType *in, ComplexType *out, unsigned flags, int threads=1)
static PlanType Plan_dft_1d(const int n, ComplexType *in, ComplexType *out, int sign, unsigned flags, int threads=1)
static PlanType Plan_dft_r2c_3d(int nx, int ny, int nz, PixelType *in, ComplexType *out, unsigned flags, int threads=1)
static PlanType Plan_dft_c2r_3d(int nx, int ny, int nz, ComplexType *in, PixelType *out, unsigned flags, int threads=1)
static PlanType Plan_dft_r2c_3d(int nx, int ny, int nz, PixelType *in, ComplexType *out, unsigned flags, int threads=1)
static PlanType Plan_dft_r2c(int rank, const int *n, PixelType *in, ComplexType *out, unsigned flags, int threads=1)
static PlanType Plan_dft_r2c_1d(int n, PixelType *in, ComplexType *out, unsigned flags, int threads=1)
static PlanType Plan_dft_c2r_2d(int nx, int ny, ComplexType *in, PixelType *out, unsigned flags, int threads=1)
static PlanType Plan_dft_r2c(int rank, const int *n, PixelType *in, ComplexType *out, unsigned flags, int threads=1)
static PlanType Plan_dft_c2r_1d(int n, ComplexType *in, PixelType *out, unsigned flags, int threads=1)
static PlanType Plan_dft_1d(const int n, ComplexType *in, ComplexType *out, int sign, unsigned flags, int threads=1)
static PlanType Plan_dft_c2r_3d(int nx, int ny, int nz, ComplexType *in, PixelType *out, unsigned flags, int threads=1)
static PlanType Plan_dft_c2r(int rank, const int *n, ComplexType *in, PixelType *out, unsigned flags, int threads=1)
static PlanType Plan_dft_r2c_2d(int nx, int ny, PixelType *in, ComplexType *out, unsigned flags, int threads=1)
static PlanType Plan_dft_r2c_1d(int n, PixelType *in, ComplexType *out, unsigned flags, int threads=1)