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
ComplexMatrix.h
Go to the documentation of this file.
1 /**
2  * @file ComplexMatrix.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 with the class for complex matrices.
9  *
10  * @version kspaceFirstOrder3D 2.15
11  *
12  * @date 11 July 2011, 14:02 (created) \n
13  * 25 September 2014, 12:27 (revised)
14  *
15  * @section License
16  * This file is part of the C++ extension of the k-Wave Toolbox (http://www.k-wave.org).\n
17  * Copyright (C) 2014 Jiri Jaros and Bradley Treeby
18  *
19  * This file is part of k-Wave. k-Wave is free software: you can redistribute it
20  * and/or modify it under the terms of the GNU Lesser General Public License as
21  * published by the Free Software Foundation, either version 3 of the License,
22  * or (at your option) any later version.
23  *
24  * k-Wave is distributed in the hope that it will be useful, but
25  * WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27  * See the GNU Lesser General Public License for more details.
28  *
29  * You should have received a copy of the GNU Lesser General Public License
30  * along with k-Wave. If not, see <http://www.gnu.org/licenses/>.
31  */
32 
33 #ifndef COMPLEXMATRIXDATA_H
34 #define COMPLEXMATRIXDATA_H
35 
38 
39 #include <Utils/DimensionSizes.h>
40 
41 
42 using namespace std;
43 
44 /**
45  * @struct TFloatComplex
46  * @brief Structure for complex values
47  * @todo: Change to classic C++ complex (better support of vectorisation)
48  */
50 {
51  /// real part
52  float real;
53  /// imaginary part
54  float imag;
55 };//TFloatComplex
56 //------------------------------------------------------------------------------
57 
58 
59 /**
60  * @class TComplexMatrix
61  * @brief The class for complex matrices.
62  * @details The class for complex matrices.
63  */
65 {
66  public:
67 
68  /// Constructor.
69  TComplexMatrix(const TDimensionSizes & DimensionSizes);
70 
71  /// Destructor.
72  virtual ~TComplexMatrix()
73  {
74  FreeMemory();
75  };
76 
77  /**
78  * @brief operator [].
79  * @details operator [].
80  * @param [in] index - 1D index into the array
81  * @return - element of the matrix
82  */
83  inline TFloatComplex& operator [](const size_t& index)
84  {
85  return ((TFloatComplex *) pMatrixData)[index];
86  };
87 
88  /**
89  * @brief operator [], constant version.
90  * @details operator [], constant version.
91  * @param [in] index - 1D index into the array
92  * @return element of the matrix
93  */
94  inline const TFloatComplex& operator [](const size_t& index) const
95  {
96  return ((TFloatComplex *) pMatrixData)[index];
97  };
98 
99  /**
100  * @brief Get element from 3D matrix.
101  * @details Get element from 3D matrix.
102  * @param [in] X - X dimension
103  * @param [in] Y - Y dimension
104  * @param [in] Z - Z dimension
105  * @return a complex element of the class
106  */
107  inline TFloatComplex& GetElementFrom3D(const size_t X,
108  const size_t Y,
109  const size_t Z)
110  {
111  return ((TFloatComplex *) pMatrixData)[Z * (p2DDataSliceSize>>1) + Y * (pDataRowSize>>1) + X];
112  };
113 
114  /**
115  * @brief Get element from 3D matrix, constant version.
116  * @details Get element from 3D matrix, constant version.
117  * @param [in] X - X dimension
118  * @param [in] Y - Y dimension
119  * @param [in] Z - Z dimension
120  * @return a complex element of the class
121  */
122  inline const TFloatComplex& GetElementFrom3D(const size_t X,
123  const size_t Y,
124  const size_t Z) const
125  {
126  return ((TFloatComplex *) pMatrixData)[Z * (p2DDataSliceSize>>1) + Y * (pDataRowSize>>1) + X];
127  };
128 
129 
130  /// Load data from the HDF5_File.
131  virtual void ReadDataFromHDF5File(THDF5_File & HDF5_File,
132  const char * MatrixName);
133 
134  /// Write data into the HDF5_File
135  virtual void WriteDataToHDF5File(THDF5_File & HDF5_File,
136  const char * MatrixName,
137  const size_t CompressionLevel);
138 
139  protected:
140  /// Default constructor not allowed for public.
142 
143  /// Copy constructor not allowed for public.
144  TComplexMatrix(const TComplexMatrix& src);
145 
146  /// Operator not allowed for public.
147  TComplexMatrix& operator = (const TComplexMatrix& src);
148 
149  /// Initialize dimension sizes and related structures.
150  virtual void InitDimensions(const TDimensionSizes& DimensionSizes);
151 
152  private:
153 
154 };// end of TComplexMatrix
155 //------------------------------------------------------------------------------
156 
157 #endif /* COMPLEXMATRIXDATA_H */
Abstract base class for float based matrices defining basic interface. Higher dimensional matrices st...
const TFloatComplex & GetElementFrom3D(const size_t X, const size_t Y, const size_t Z) const
Get element from 3D matrix, constant version.
The header file containing the class for real matrices.
float imag
imaginary part
Definition: ComplexMatrix.h:54
Structure for complex values.
Definition: ComplexMatrix.h:49
The header file containing the structure with 3D dimension sizes.
TComplexMatrix()
Default constructor not allowed for public.
The header file containing the base class for single precisions floating point numbers (floats) ...
TFloatComplex & GetElementFrom3D(const size_t X, const size_t Y, const size_t Z)
Get element from 3D matrix.
float real
real part
Definition: ComplexMatrix.h:52
The class for complex matrices.
Definition: ComplexMatrix.h:64
virtual ~TComplexMatrix()
Destructor.
Definition: ComplexMatrix.h:72
Class wrapping the HDF5 routines.
Definition: HDF5_File.h:506
Structure with 4D dimension sizes (3 in space and 1 in time).