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
RealMatrix.h
Go to the documentation of this file.
1 /**
2  * @file RealMatrix.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 for real matrices.
9  *
10  * @version kspaceFirstOrder3D 2.15
11  *
12  * @date 11 July 2011, 10:30 (created) \n
13  * 25 September 2014, 17:34 (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 REALMATRIXDATA_H
34 #define REALMATRIXDATA_H
35 
36 
38 
39 #include <Utils/DimensionSizes.h>
40 
41 class TComplexMatrix;
42 
43 /**
44  * @class TRealMatrix
45  * @brief The class for real matrices
46  * @details The class for real matrices (floats)
47  */
49 {
50  public:
51 
52  /// Constructor
53  TRealMatrix(const TDimensionSizes & DimensionSizes);
54 
55  /// Destructor.
56  virtual ~TRealMatrix()
57  {
58  FreeMemory();
59  };
60 
61  /// Read data from the HDF5 file - only from the root group.
62  virtual void ReadDataFromHDF5File(THDF5_File & HDF5_File,
63  const char * MatrixName);
64 
65  /// Write data into the HDF5 file.
66  virtual void WriteDataToHDF5File(THDF5_File & HDF5_File,
67  const char * MatrixName,
68  const size_t CompressionLevel);
69 
70  /**
71  * @brief operator [].
72  * @details operator [].
73  * @param [in] index - 1D index
74  * @return an element
75  */
76  float& operator [](const size_t& index)
77  {
78  return pMatrixData[index];
79  };
80 
81 
82  /**
83  * @brief operator [], constant version.
84  * @details operator [], constant version.
85  * @param [in] index - 1D index
86  * @return an element
87  */
88  const float& operator [](const size_t& index) const
89  {
90  return pMatrixData[index];
91  };
92 
93  /**
94  * @brief Get element from 3D matrix.
95  * @details Get element from 3D matrix.
96  * @param [in] X - X dimension
97  * @param [in] Y - Y dimension
98  * @param [in] Z - Z dimension
99  * @return an element
100  */
101  float& GetElementFrom3D(const size_t X, const size_t Y, const size_t Z)
102  {
103  return pMatrixData[Z * p2DDataSliceSize + Y * pDataRowSize + X];
104  };
105 
106 
107 protected:
108 
109  /// Default constructor is not allowed for public.
111 
112  /// Copy constructor not allowed for public.
113  TRealMatrix(const TRealMatrix& src);
114 
115  /// Operator = is not allowed for public.
116  TRealMatrix& operator = (const TRealMatrix& src);
117 
118  /// Init dimension.
119  virtual void InitDimensions(const TDimensionSizes & DimensionSizes);
120 
121 private:
122 
123  /// Number of elements to get 4MB block of data.
124  static const size_t ChunkSize_1D_4MB = 1048576; //(4MB)
125  /// Number of elements to get 1MB block of data.
126  static const size_t ChunkSize_1D_1MB = 262144; //(1MB)
127  /// Number of elements to get 256KB block of data.
128  static const size_t ChunkSize_1D_256KB = 65536; //(256KB)
129 };// end of class TRealMatrix
130 //------------------------------------------------------------------------------
131 
132 #endif /* REALMATRIXDATA_H */
133 
134 
135 
Abstract base class for float based matrices defining basic interface. Higher dimensional matrices st...
float & GetElementFrom3D(const size_t X, const size_t Y, const size_t Z)
Get element from 3D matrix.
Definition: RealMatrix.h:101
static const size_t ChunkSize_1D_1MB
Number of elements to get 1MB block of data.
Definition: RealMatrix.h:126
virtual void FreeMemory()
Memory deallocation.
virtual void WriteDataToHDF5File(THDF5_File &HDF5_File, const char *MatrixName, const size_t CompressionLevel)
Write data into the HDF5 file.
Definition: RealMatrix.cpp:114
size_t p2DDataSliceSize
Size of a 2D slab (X,Y).
static const size_t ChunkSize_1D_4MB
Number of elements to get 4MB block of data.
Definition: RealMatrix.h:124
virtual void ReadDataFromHDF5File(THDF5_File &HDF5_File, const char *MatrixName)
Read data from the HDF5 file - only from the root group.
Definition: RealMatrix.cpp:77
virtual void InitDimensions(const TDimensionSizes &DimensionSizes)
Init dimension.
Definition: RealMatrix.cpp:171
size_t pDataRowSize
Size of a 1D row in X dimension.
The header file containing the structure with 3D dimension sizes.
The class for real matrices.
Definition: RealMatrix.h:48
virtual ~TRealMatrix()
Destructor.
Definition: RealMatrix.h:56
The header file containing the base class for single precisions floating point numbers (floats) ...
static const size_t ChunkSize_1D_256KB
Number of elements to get 256KB block of data.
Definition: RealMatrix.h:128
TRealMatrix & operator=(const TRealMatrix &src)
Operator = is not allowed for public.
The class for complex matrices.
Definition: ComplexMatrix.h:64
float * pMatrixData
Raw matrix data.
float & operator[](const size_t &index)
operator [].
Definition: RealMatrix.h:76
TRealMatrix()
Default constructor is not allowed for public.
Definition: RealMatrix.h:110
Class wrapping the HDF5 routines.
Definition: HDF5_File.h:506
Structure with 4D dimension sizes (3 in space and 1 in time).