kspaceFirstOrder3D-OMP  1.1
The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
 All Classes Files Functions Variables Typedefs Enumerations Friends Pages
FFTWComplexMatrix.h
Go to the documentation of this file.
1 /**
2  * @file FFTWComplexMatrix.h
3  * @author Jiri Jaros \n
4  * Faculty of Information Technology\n
5  * Brno University of Technology \n
6  * jarosjir@fit.vutbr.cz
7  *
8  * @brief The header file containing the class that implements
9  * 3D FFT using the FFTW interface
10  *
11  * @version kspaceFirstOrder3D 2.15
12  *
13  * @date 09 August 2011, 13:10 (created) \n
14  * 25 September 2014, 12:45 (revised)
15  *
16  * @section License
17  * This file is part of the C++ extension of the k-Wave Toolbox (http://www.k-wave.org).\n
18  * Copyright (C) 2014 Jiri Jaros and Bradley Treeby
19  *
20  * This file is part of k-Wave. k-Wave is free software: you can redistribute it
21  * and/or modify it under the terms of the GNU Lesser General Public License as
22  * published by the Free Software Foundation, either version 3 of the License,
23  * or (at your option) any later version.
24  *
25  * k-Wave is distributed in the hope that it will be useful, but
26  * WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
28  * See the GNU Lesser General Public License for more details.
29  *
30  * You should have received a copy of the GNU Lesser General Public License
31  * along with k-Wave. If not, see <http://www.gnu.org/licenses/>.
32  */
33 
34 #ifndef FFTWCOMPLEXMATRIX_H
35 #define FFTWCOMPLEXMATRIX_H
36 
37 
38 #include <fftw3.h>
39 
41 
42 /**
43  * @class TFFTWComplexMatrix
44  * @brief Class implementing 3D Real-To-Complex and Complex-To-Real transforms
45  * using FFTW interface.
46  * @details Class implementing 3D Real-To-Complex and Complex-To-Real transforms
47  * using FFTW interface.
48  *
49  */
51 {
52  public:
53  /// Constructor.
54  TFFTWComplexMatrix(const TDimensionSizes& DimensionSizes);
55  /// Destructor.
56  virtual ~TFFTWComplexMatrix();
57 
58  /// Create FFTW plan for Real-to-Complex.
59  void Create_FFT_Plan_3D_R2C(TRealMatrix& InMatrix);
60  /// Create FFTW plan for Complex-to-Real.
61  void Create_FFT_Plan_3D_C2R(TRealMatrix& OutMatrix);
62 
63  /// Create FFTW plan for Real-to-Complex in the X dimension.
64  void Create_FFT_Plan_1DX_R2C(TRealMatrix& InMatrix);
65  /// Create FFTW plan for Real-to-Complex in the Y dimension.
66  void Create_FFT_Plan_1DY_R2C(TRealMatrix& InMatrix);
67  /// Create FFTW plan for Real-to-Complex in the Z dimension.
68  void Create_FFT_Plan_1DZ_R2C(TRealMatrix& InMatrix);
69 
70  /// Create FFTW plan for Complex-to-Real in the X dimension.
71  void Create_FFT_Plan_1DX_C2R(TRealMatrix& OutMatrix);
72  /// Create FFTW plan for Complex-to-Real in the Y dimension.
73  void Create_FFT_Plan_1DY_C2R(TRealMatrix& OutMatrix);
74  /// Create FFTW plan for Complex-to-Real in the Z dimension.
75  void Create_FFT_Plan_1DZ_C2R(TRealMatrix& OutMatrix);
76 
77 
78 
79  /// Compute 3D out-of-place Real-to-Complex FFT.
80  void Compute_FFT_3D_R2C(TRealMatrix& InMatrix);
81  /// Compute 3D out-of-place Complex-to-Real FFT.
82  void Compute_FFT_3D_C2R(TRealMatrix& OutMatrix);
83 
84  /// Compute 1D out-of-place Real-to-Complex FFT in the X dimension.
85  void Compute_FFT_1DX_R2C(TRealMatrix& InMatrix);
86  /// Compute 1D out-of-place Real-to-Complex FFT in the Y dimension.
87  void Compute_FFT_1DY_R2C(TRealMatrix& InMatrix);
88  /// Compute 1D out-of-place Real-to-Complex FFT in the Z dimension.
89  void Compute_FFT_1DZ_R2C(TRealMatrix& InMatrix);
90 
91  /// Compute 1D out-of-place Complex-to-Real FFT in the X dimension.
92  void Compute_FFT_1DX_C2R(TRealMatrix& OutMatrix);
93  /// Compute 1D out-of-place Complex-to-Real FFT in the Y dimension.
94  void Compute_FFT_1DY_C2R(TRealMatrix& OutMatrix);
95  /// Compute 1D out-of-place Complex-to-Real FFT in the Z dimension.
96  void Compute_FFT_1DZ_C2R(TRealMatrix& OutMatrix);
97 
98  /// Export wisdom to the file.
99  static void ExportWisdom();
100  /// Import wisdom from the file.
101  static void ImportWisdom();
102  /// Destroy wisdom in the file (delete it).
103  static void DeleteStoredWisdom();
104 
105 protected:
106  /// Default constructor not allowed for public
108  TComplexMatrix(),
109  fftw_plan_3D_R2C(NULL), fftw_plan_3D_C2R(NULL),
112  {};
113 
114  /// Copy constructor not allowed for public.
116 
117  /// Operator = not allowed for public.
119 
120  /// Get Wisdom file name, base on the checkpoint filename.
121  static string GetWisdomFileName();
122 
123  /// Allocate memory for the FFTW matrix.
124  virtual void AllocateMemory();
125  /// Free memory of the FFTW matrix.
126  virtual void FreeMemory();
127 
128  /// FFTW plan flag.
129  static const unsigned TFFTWComplexMatrix_FFT_FLAG = FFTW_MEASURE;
130  /// The file extension for FFTW wisdom.
131  static const string FFTW_Wisdom_FileName_Extension;// = "FFTW_Wisdom";
132 
133  /// FFTW plan for the 3D Real-to-Complex transform.
134  fftwf_plan fftw_plan_3D_R2C;
135  /// FFTW plan for the 3D Complex-to-Real transform.
136  fftwf_plan fftw_plan_3D_C2R;
137 
138  /// FFTW plan for the 1D Real-to-Complex transform in the X dimension.
139  fftwf_plan fftw_plan_1DX_R2C;
140  /// FFTW plan for the 3D Real-to-Complex transform in the Y dimension.
141  fftwf_plan fftw_plan_1DY_R2C;
142  /// FFTW plan for the 3D Real-to-Complex transform in the Z dimension.
143  fftwf_plan fftw_plan_1DZ_R2C;
144 
145  /// FFTW plan for the 3D Complex-to-Real transform in the X dimension.
146  fftwf_plan fftw_plan_1DX_C2R;
147  /// FFTW plan for the 3D Complex-to-Real transform in the Y dimension.
148  fftwf_plan fftw_plan_1DY_C2R;
149  /// FFTW plan for the 3Z Complex-to-Real transform in the Z dimension.
150  fftwf_plan fftw_plan_1DZ_C2R;
151 
152 private:
153 
154 };// TFFTWComplexMatrix
155 
156 #endif /* FFTWCOMPLEXMATRIX_H */
157 
static void ExportWisdom()
Export wisdom to the file.
virtual void FreeMemory()
Free memory of the FFTW matrix.
fftwf_plan fftw_plan_1DY_R2C
FFTW plan for the 3D Real-to-Complex transform in the Y dimension.
void Compute_FFT_1DY_R2C(TRealMatrix &InMatrix)
Compute 1D out-of-place Real-to-Complex FFT in the Y dimension.
static const unsigned TFFTWComplexMatrix_FFT_FLAG
FFTW plan flag.
void Create_FFT_Plan_1DZ_C2R(TRealMatrix &OutMatrix)
Create FFTW plan for Complex-to-Real in the Z dimension.
void Compute_FFT_1DX_C2R(TRealMatrix &OutMatrix)
Compute 1D out-of-place Complex-to-Real FFT in the X dimension.
void Create_FFT_Plan_1DY_R2C(TRealMatrix &InMatrix)
Create FFTW plan for Real-to-Complex in the Y dimension.
void Create_FFT_Plan_3D_R2C(TRealMatrix &InMatrix)
Create FFTW plan for Real-to-Complex.
void Compute_FFT_1DZ_C2R(TRealMatrix &OutMatrix)
Compute 1D out-of-place Complex-to-Real FFT in the Z dimension.
fftwf_plan fftw_plan_1DZ_R2C
FFTW plan for the 3D Real-to-Complex transform in the Z dimension.
fftwf_plan fftw_plan_3D_R2C
FFTW plan for the 3D Real-to-Complex transform.
virtual void AllocateMemory()
Allocate memory for the FFTW matrix.
fftwf_plan fftw_plan_3D_C2R
FFTW plan for the 3D Complex-to-Real transform.
TFFTWComplexMatrix()
Default constructor not allowed for public.
void Create_FFT_Plan_1DX_R2C(TRealMatrix &InMatrix)
Create FFTW plan for Real-to-Complex in the X dimension.
Class implementing 3D Real-To-Complex and Complex-To-Real transforms using FFTW interface.
void Create_FFT_Plan_1DZ_R2C(TRealMatrix &InMatrix)
Create FFTW plan for Real-to-Complex in the Z dimension.
void Compute_FFT_3D_C2R(TRealMatrix &OutMatrix)
Compute 3D out-of-place Complex-to-Real FFT.
void Compute_FFT_1DX_R2C(TRealMatrix &InMatrix)
Compute 1D out-of-place Real-to-Complex FFT in the X dimension.
static void DeleteStoredWisdom()
Destroy wisdom in the file (delete it).
fftwf_plan fftw_plan_1DZ_C2R
FFTW plan for the 3Z Complex-to-Real transform in the Z dimension.
void Create_FFT_Plan_1DY_C2R(TRealMatrix &OutMatrix)
Create FFTW plan for Complex-to-Real in the Y dimension.
void Compute_FFT_1DY_C2R(TRealMatrix &OutMatrix)
Compute 1D out-of-place Complex-to-Real FFT in the Y dimension.
static string GetWisdomFileName()
Get Wisdom file name, base on the checkpoint filename.
static void ImportWisdom()
Import wisdom from the file.
The header file with the class for complex matrices.
The class for real matrices.
Definition: RealMatrix.h:48
static const string FFTW_Wisdom_FileName_Extension
The file extension for FFTW wisdom.
void Compute_FFT_1DZ_R2C(TRealMatrix &InMatrix)
Compute 1D out-of-place Real-to-Complex FFT in the Z dimension.
void Create_FFT_Plan_3D_C2R(TRealMatrix &OutMatrix)
Create FFTW plan for Complex-to-Real.
void Compute_FFT_3D_R2C(TRealMatrix &InMatrix)
Compute 3D out-of-place Real-to-Complex FFT.
TFFTWComplexMatrix & operator=(const TFFTWComplexMatrix &src)
Operator = not allowed for public.
fftwf_plan fftw_plan_1DX_C2R
FFTW plan for the 3D Complex-to-Real transform in the X dimension.
fftwf_plan fftw_plan_1DY_C2R
FFTW plan for the 3D Complex-to-Real transform in the Y dimension.
fftwf_plan fftw_plan_1DX_R2C
FFTW plan for the 1D Real-to-Complex transform in the X dimension.
The class for complex matrices.
Definition: ComplexMatrix.h:64
void Create_FFT_Plan_1DX_C2R(TRealMatrix &OutMatrix)
Create FFTW plan for Complex-to-Real in the X dimension.
virtual ~TFFTWComplexMatrix()
Destructor.
Structure with 4D dimension sizes (3 in space and 1 in time).