kspaceFirstOrder3D-OMP  1.2
The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
BaseFloatMatrix.h
Go to the documentation of this file.
1 /**
2  * @file BaseFloatMatrix.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 base class for single precisions floating point numbers (floats).
10  *
11  * @version kspaceFirstOrder3D 2.16
12  *
13  * @date 11 July 2011, 12:13 (created) \n
14  * 04 September 2017, 11:02 (revised)
15  *
16  * @copyright Copyright (C) 2017 Jiri Jaros and Bradley Treeby.
17  *
18  * This file is part of the C++ extension of the [k-Wave Toolbox](http://www.k-wave.org).
19  *
20  * This file is part of the k-Wave. k-Wave is free software: you can redistribute it and/or modify it under the terms
21  * of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the
22  * 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 the implied
25  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
26  * 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/](http://www.gnu.org/licenses/).
30  */
31 
32 
33 #ifndef BASE_FLOAT_MATRIX_H
34 #define BASE_FLOAT_MATRIX_H
35 
37 #include <Utils/DimensionSizes.h>
38 
39 /**
40  * @class BaseFloatMatrix
41  * @brief Abstract base class for float based matrices defining basic interface. Higher dimensional
42  * matrices stored as 1D arrays, row-major order.
43  *
44  * @details Abstract base class for float based matrices defining basic interface. Higher dimensional matrices stored
45  * as 1D arrays, row-major order. The I/O is done via HDF5 files.
46  */
48 {
49  public:
50 
51  /// Default constructor.
53  /// Copy constructor is not allowed.
54  BaseFloatMatrix(const BaseFloatMatrix&) = delete;
55  /// Destructor.
56  virtual ~BaseFloatMatrix() {};
57 
58  /// operator= is not allowed.
59  BaseFloatMatrix& operator=(const BaseFloatMatrix&) = delete;
60 
61  /**
62  * @brief Get dimension sizes of the matrix.
63  * @return Dimension sizes of the matrix.
64  */
65  virtual const DimensionSizes& getDimensionSizes() const { return mDimensionSizes; };
66  /**
67  * @brief Size of the matrix.
68  * @return Number of elements.
69  */
70  virtual size_t size() const { return mSize; };
71  /**
72  * @brief The capacity of the matrix (this may differ from size due to padding, etc.).
73  * @return Capacity of the currently allocated storage.
74  */
75  virtual size_t capacity() const { return mCapacity; };
76 
77  /**
78  * @brief Copy data from other matrix with the same size.
79  * @param [in] src - Matrix to copy data in.
80  */
81  virtual void copyData(const BaseFloatMatrix& src);
82 
83  /// Zero all elements of the matrix (NUMA first touch).
84  virtual void zeroMatrix();
85 
86  /**
87  * @brief Calculate matrix = scalar / matrix.
88  * @param [in] scalar - Scalar constant
89  */
90  virtual void scalarDividedBy(const float scalar);
91 
92  /**
93  * @brief Get raw data out of the class (for direct kernel access).
94  * @return Mutable matrix data
95  */
96  virtual float* getData() { return mData; };
97 
98  /**
99  * @brief Get raw data out of the class (for direct kernel access), const version.
100  * @return Immutable matrix data.
101  */
102  virtual const float* getData() const { return mData; };
103 
104  protected:
105 
106  /**
107  * @brief Aligned memory allocation (both on CPU and GPU).
108  * @throw std::bad_alloc - If there's not enough memory.
109  */
110  virtual void allocateMemory();
111  /// Memory allocation (both on CPU and GPU).
112  virtual void freeMemory();
113 
114  /// Total number of used elements.
115  size_t mSize;
116  /// Total number of allocated elements (in terms of floats).
117  size_t mCapacity;
118 
119  /// Dimension sizes.
121 
122  /// Size of a 1D row in X dimension.
123  size_t mRowSize;
124  /// Size of a XY slab.
125  size_t mSlabSize;
126 
127  /// Raw matrix data.
128  float* mData;
129 
130  private:
131 
132 };//end of BaseFloatMatrix
133 //----------------------------------------------------------------------------------------------------------------------
134 
135 #endif /* BASE_FLOAT_MATRIX_H */
size_t mRowSize
Size of a 1D row in X dimension.
virtual void allocateMemory()
Aligned memory allocation (both on CPU and GPU).
virtual size_t capacity() const
The capacity of the matrix (this may differ from size due to padding, etc.).
BaseFloatMatrix()
Default constructor.
virtual size_t size() const
Size of the matrix.
float * mData
Raw matrix data.
DimensionSizes mDimensionSizes
Dimension sizes.
BaseFloatMatrix & operator=(const BaseFloatMatrix &)=delete
operator= is not allowed.
Abstract base class. The common ancestor defining the common interface and allowing derived classes t...
Definition: BaseMatrix.h:48
virtual ~BaseFloatMatrix()
Destructor.
virtual void copyData(const BaseFloatMatrix &src)
Copy data from other matrix with the same size.
Structure with 4D dimension sizes (3 in space and 1 in time).
The header file containing the structure with 3D dimension sizes.
virtual void freeMemory()
Memory allocation (both on CPU and GPU).
virtual float * getData()
Get raw data out of the class (for direct kernel access).
size_t mSize
Total number of used elements.
virtual const float * getData() const
Get raw data out of the class (for direct kernel access), const version.
virtual void scalarDividedBy(const float scalar)
Calculate matrix = scalar / matrix.
size_t mSlabSize
Size of a XY slab.
virtual const DimensionSizes & getDimensionSizes() const
Get dimension sizes of the matrix.
virtual void zeroMatrix()
Zero all elements of the matrix (NUMA first touch).
The header file of the common ancestor of all matrix classes. A pure abstract class.
size_t mCapacity
Total number of allocated elements (in terms of floats).
Abstract base class for float based matrices defining basic interface. Higher dimensional matrices st...