| kspaceFirstOrder3D-CUDA 1.1 The CUDA/C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IndexMatrix.h
Go to the documentation of this file.
1 /**
2 * @file IndexMatrix.h
3 *
4 * @author Jiri Jaros \n
5 * Faculty of Information Technology \n
6 * Brno University of Technology \n
7 * jarosjir@fit.vutbr.cz
8 *
9 * @brief The header file containing the class for 64b integer matrices.
10 *
11 * @version kspaceFirstOrder3D 3.4
12 *
13 * @date 26 July 2011, 15:16 (created) \n
14 * 29 July 2016, 16:54 (revised)
15 *
16 * @section License
17 * This file is part of the C++ extension of the k-Wave Toolbox
18 * (http://www.k-wave.org).\n Copyright (C) 2016 Jiri Jaros and Bradley Treeby.
19 *
20 * This file is part of the k-Wave. k-Wave is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU Lesser General Public License as published by the Free Software
22 * Foundation, either version 3 of the License, or (at your option) any later version.
23 *
24 * k-Wave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
25 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
26 * General Public License for more details.
27 *
28 * You should have received a copy of the GNU Lesser General Public License along with k-Wave.
29 * If not, see http://www.gnu.org/licenses/.
30 */
31
32 #ifndef INDEX_MATRIX_H
33 #define INDEX_MATRIX_H
34
35 #include <MatrixClasses/BaseIndexMatrix.h>
36 #include <Utils/DimensionSizes.h>
37
38 /**
39 * @class TIndexMatrix
40 * @brief The class for 64b unsigned integers (indices). It is used for sensor_mask_index or
41 * sensor_corners_mask to get the address of sampled voxels.
42 *
43 * @details The class for 64b unsigned integers (indices). It is used for sensor_mask_index or
44 * sensor_corners_mask to get the address of sampled voxels. Stores data both GPU and CPU side.
45 */
46 class TIndexMatrix : public TBaseIndexMatrix
47 {
48 public:
49 /// Constructor allocating memory.
50 TIndexMatrix(const TDimensionSizes& dimensionSizes);
51
52 /// Destructor.
53 virtual ~TIndexMatrix();
54
55 /// Read data from the HDF5 file.
56 virtual void ReadDataFromHDF5File(THDF5_File& file,
57 TMatrixName& matrixName);
58 /// Write data into the HDF5 file.
59 virtual void WriteDataToHDF5File(THDF5_File& file,
60 TMatrixName& matrixName,
61 const size_t compressionLevel);
62
63 /**
64 * @brief Operator [].
65 * @details Operator [].
66 * @param [in] index - 1D index into the matrix
67 * @return Value of the index
68 */
69 inline size_t& operator[](const size_t& index)
70 {
71 return hostData[index];
72 };
73
74 /**
75 * @brief Operator [], constant version
76 * @details Operator [], constant version
77 * @param [in] index - 1D index into the matrix
78 * @return Value of the index
79 */
80 inline const size_t& operator[](const size_t& index) const
81 {
82 return hostData[index];
83 };
84
85 /// Get the top left corner of the index-th cuboid.
86 TDimensionSizes GetTopLeftCorner(const size_t& index) const;
87 /// Get the bottom right corner of the index-th cuboid
88 TDimensionSizes GetBottomRightCorner(const size_t& index) const;
89
90 /// Recompute indices MATALAB->C++.
91 void RecomputeIndicesToCPP();
92 /// Recompute indices C++ -> MATLAB.
93 void RecomputeIndicesToMatlab();
94
95 /// Get the total number of elements to be sampled within all cuboids.
96 size_t GetTotalNumberOfElementsInAllCuboids() const;
97
98 protected:
99 /// Default constructor not allowed for public.
100 TIndexMatrix() {};
101 /// Copy constructor not allowed for public.
102 TIndexMatrix(const TIndexMatrix& src);
103 /// Operator = not allowed for public.
104 TIndexMatrix& operator = (const TIndexMatrix& src);
105
106 private:
107 /// Number of elements to get 4MB block of data.
108 static const size_t CHUNK_SIZE_1D_4MB = 1048576; //(4MB)
109 /// Number of elements to get 1MB block of data.
110 static const size_t CHUNK_SIZE_1D_1MB = 262144; //(1MB)
111 /// Number of elements to get 256KB block of data.
112 static const size_t CHUNK_SIZE_1D_256KB = 65536; //(256KB)
113
114 };// end of TIndexMatrix
115 //--------------------------------------------------------------------------------------------------
116 #endif /* INDEX_MATRIX_H */
117
TIndexMatrix::GetTotalNumberOfElementsInAllCuboids
size_t GetTotalNumberOfElementsInAllCuboids() const
Get the total number of elements to be sampled within all cuboids.
Definition: IndexMatrix.cpp:217
TIndexMatrix::GetBottomRightCorner
TDimensionSizes GetBottomRightCorner(const size_t &index) const
Get the bottom right corner of the index-th cuboid.
Definition: IndexMatrix.cpp:175
TIndexMatrix::WriteDataToHDF5File
virtual void WriteDataToHDF5File(THDF5_File &file, TMatrixName &matrixName, const size_t compressionLevel)
Write data into the HDF5 file.
Definition: IndexMatrix.cpp:107
TMatrixName
const std::string TMatrixName
Datatype for matrix names.
Definition: MatrixNames.h:45
TIndexMatrix::RecomputeIndicesToMatlab
void RecomputeIndicesToMatlab()
Recompute indices C++ -> MATLAB.
Definition: IndexMatrix.cpp:202
TIndexMatrix::TIndexMatrix
TIndexMatrix()
Default constructor not allowed for public.
Definition: IndexMatrix.h:100
TIndexMatrix::~TIndexMatrix
virtual ~TIndexMatrix()
Destructor.
Definition: IndexMatrix.cpp:67
TIndexMatrix::operator[]
const size_t & operator[](const size_t &index) const
Operator [], constant version.
Definition: IndexMatrix.h:80
TIndexMatrix::ReadDataFromHDF5File
virtual void ReadDataFromHDF5File(THDF5_File &file, TMatrixName &matrixName)
Read data from the HDF5 file.
Definition: IndexMatrix.cpp:81
TIndexMatrix::GetTopLeftCorner
TDimensionSizes GetTopLeftCorner(const size_t &index) const
Get the top left corner of the index-th cuboid.
Definition: IndexMatrix.cpp:158
TBaseIndexMatrix::dimensionSizes
struct TDimensionSizes dimensionSizes
Dimension sizes.
Definition: BaseIndexMatrix.h:127
DimensionSizes.h
The header file containing the structure with 3D dimension sizes.
TBaseIndexMatrix::hostData
size_t * hostData
Raw CPU matrix data.
Definition: BaseIndexMatrix.h:135
TIndexMatrix::operator[]
size_t & operator[](const size_t &index)
Operator [].
Definition: IndexMatrix.h:69
TBaseIndexMatrix
Abstract base class for index based matrices defining basic interface. Higher dimensional matrices st...
Definition: BaseIndexMatrix.h:49
TIndexMatrix::RecomputeIndicesToCPP
void RecomputeIndicesToCPP()
Recompute indices MATALAB->C++.
Definition: IndexMatrix.cpp:189
TIndexMatrix
The class for 64b unsigned integers (indices). It is used for sensor_mask_index or sensor_corners_mas...
Definition: IndexMatrix.h:46
TIndexMatrix::operator=
TIndexMatrix & operator=(const TIndexMatrix &src)
Operator = not allowed for public.
TIndexMatrix::CHUNK_SIZE_1D_4MB
static const size_t CHUNK_SIZE_1D_4MB
Number of elements to get 4MB block of data.
Definition: IndexMatrix.h:108
BaseIndexMatrix.h
The header file containing the base class for 64b-wide integers implemented as size_t datatype...
TIndexMatrix::CHUNK_SIZE_1D_1MB
static const size_t CHUNK_SIZE_1D_1MB
Number of elements to get 1MB block of data.
Definition: IndexMatrix.h:110
THDF5_File
Class wrapping the HDF5 routines.
Definition: HDF5_File.h:500
TDimensionSizes
Structure with 4D dimension sizes (3 in space and 1 in time).
Definition: DimensionSizes.h:66
TIndexMatrix::CHUNK_SIZE_1D_256KB
static const size_t CHUNK_SIZE_1D_256KB
Number of elements to get 256KB block of data.
Definition: IndexMatrix.h:112