kspaceFirstOrder3D-OMP  1.2
The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
RealMatrix Class Reference

The class for real matrices. More...

#include <RealMatrix.h>

Inheritance diagram for RealMatrix:
Collaboration diagram for RealMatrix:

Public Member Functions

 RealMatrix ()=delete
 Default constructor is not allowed.
 
 RealMatrix (const DimensionSizes &dimensionSizes)
 Constructor. More...
 
 RealMatrix (const RealMatrix &)=delete
 Copy constructor not allowed.
 
virtual ~RealMatrix ()
 Destructor. More...
 
RealMatrixoperator= (const RealMatrix &)
 Operator= is not allowed.
 
virtual void readData (Hdf5File &file, MatrixName &matrixName)
 Read matrix from HDF5 file. More...
 
virtual void writeData (Hdf5File &file, MatrixName &matrixName, const size_t compressionLevel)
 Write data into HDF5 file. More...
 
float & operator[] (const size_t &index)
 operator[]. More...
 
const float & operator[] (const size_t &index) const
 Operator[], constant version. More...
 
float & getElementFrom3D (const size_t x, const size_t y, const size_t z)
 Get element from 3D matrix. More...
 
const float & getElementFrom3D (const size_t x, const size_t y, const size_t z) const
 Get element from 3D matrix, const version. More...
 
- Public Member Functions inherited from BaseFloatMatrix
 BaseFloatMatrix ()
 Default constructor. More...
 
 BaseFloatMatrix (const BaseFloatMatrix &)=delete
 Copy constructor is not allowed.
 
virtual ~BaseFloatMatrix ()
 Destructor.
 
BaseFloatMatrixoperator= (const BaseFloatMatrix &)=delete
 operator= is not allowed.
 
virtual const DimensionSizesgetDimensionSizes () const
 Get dimension sizes of the matrix. More...
 
virtual size_t size () const
 Size of the matrix. More...
 
virtual size_t capacity () const
 The capacity of the matrix (this may differ from size due to padding, etc.). More...
 
virtual void copyData (const BaseFloatMatrix &src)
 Copy data from other matrix with the same size. More...
 
virtual void zeroMatrix ()
 Zero all elements of the matrix (NUMA first touch). More...
 
virtual void scalarDividedBy (const float scalar)
 Calculate matrix = scalar / matrix. More...
 
virtual float * getData ()
 Get raw data out of the class (for direct kernel access). More...
 
virtual const float * getData () const
 Get raw data out of the class (for direct kernel access), const version. More...
 
- Public Member Functions inherited from BaseMatrix
 BaseMatrix ()
 Default constructor.
 
 BaseMatrix (const BaseMatrix &)=delete
 Copy constructor is not allowed.
 
virtual ~BaseMatrix ()
 Destructor.
 
BaseMatrixoperator= (const BaseMatrix &)=delete
 Operator= is not allowed.
 

Private Member Functions

void initDimensions (const DimensionSizes &dimensionSizes)
 Init dimension. More...
 

Static Private Attributes

static constexpr size_t kChunkSize1D4MB = 1048576
 Number of elements to get 4MB block of data.
 
static constexpr size_t kChunkSize1D1MB = 262144
 Number of elements to get 1MB block of data.
 
static constexpr size_t kChunkSize1D256kB = 65536
 Number of elements to get 256KB block of data.
 

Additional Inherited Members

- Protected Member Functions inherited from BaseFloatMatrix
virtual void allocateMemory ()
 Aligned memory allocation (both on CPU and GPU). More...
 
virtual void freeMemory ()
 Memory allocation (both on CPU and GPU). More...
 
- Protected Attributes inherited from BaseFloatMatrix
size_t mSize
 Total number of used elements.
 
size_t mCapacity
 Total number of allocated elements (in terms of floats).
 
DimensionSizes mDimensionSizes
 Dimension sizes.
 
size_t mRowSize
 Size of a 1D row in X dimension.
 
size_t mSlabSize
 Size of a XY slab.
 
float * mData
 Raw matrix data.
 

Detailed Description

The class for real matrices (floats) on both CPU and GPU side.

Definition at line 47 of file RealMatrix.h.

Constructor & Destructor Documentation

◆ RealMatrix()

RealMatrix::RealMatrix ( const DimensionSizes dimensionSizes)
Parameters
[in]dimensionSizes- Dimension sizes of the matrix.

Constructor.

Definition at line 52 of file RealMatrix.cpp.

◆ ~RealMatrix()

RealMatrix::~RealMatrix ( )
virtual

Destructor.

Definition at line 63 of file RealMatrix.cpp.

Member Function Documentation

◆ getElementFrom3D() [1/2]

float& RealMatrix::getElementFrom3D ( const size_t  x,
const size_t  y,
const size_t  z 
)
inline
Parameters
[in]x- x dimension
[in]y- y dimension
[in]z- z dimension
Returns
an element

Definition at line 107 of file RealMatrix.h.

◆ getElementFrom3D() [2/2]

const float& RealMatrix::getElementFrom3D ( const size_t  x,
const size_t  y,
const size_t  z 
) const
inline
Parameters
[in]x- z dimension
[in]y- y dimension
[in]z- z dimension
Returns
an element

Definition at line 119 of file RealMatrix.h.

◆ initDimensions()

void RealMatrix::initDimensions ( const DimensionSizes dimensionSizes)
private

Set necessary dimensions and auxiliary variables.

Definition at line 147 of file RealMatrix.cpp.

◆ operator[]() [1/2]

float& RealMatrix::operator[] ( const size_t &  index)
inline
Parameters
[in]index- 1D index into the matrix.
Returns
An element of the matrix.

Definition at line 92 of file RealMatrix.h.

◆ operator[]() [2/2]

const float& RealMatrix::operator[] ( const size_t &  index) const
inline
Parameters
[in]index- 1D index into the matrix.
Returns
An element of the matrix.

Definition at line 98 of file RealMatrix.h.

◆ readData()

void RealMatrix::readData ( Hdf5File file,
MatrixName matrixName 
)
virtual

Read matrix from HDF5 file.

Parameters
[in]file- Handle to the HDF5 file
[in]matrixName- HDF5 dataset name to read from
Exceptions
ios::failure- If error occurred.

Read data data from HDF5 file (only from the root group).

Implements BaseMatrix.

Definition at line 72 of file RealMatrix.cpp.

◆ writeData()

void RealMatrix::writeData ( Hdf5File file,
MatrixName matrixName,
const size_t  compressionLevel 
)
virtual

Write data into HDF5 file.

Parameters
[in]file- Handle to the HDF5 file
[in]matrixName- HDF5 dataset name to write to
[in]compressionLevel- Compression level for the HDF5 dataset
Exceptions
ios::failure- If an error occurred.

Write data to HDF5 file (only from the root group)

Implements BaseMatrix.

Definition at line 94 of file RealMatrix.cpp.


The documentation for this class was generated from the following files: