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

Class implementing 3D and 1D Real-To-Complex and Complex-To-Real transforms using FFTW interface. More...

#include <FftwComplexMatrix.h>

Inheritance diagram for FftwComplexMatrix:
Collaboration diagram for FftwComplexMatrix:

Public Member Functions

 FftwComplexMatrix ()=delete
 Default constructor not allowed for public.
 
 FftwComplexMatrix (const DimensionSizes &dimensionSizes)
 Constructor, inherited from ComplexMatrix. More...
 
 FftwComplexMatrix (const FftwComplexMatrix &src)=delete
 Copy constructor not allowed for public.
 
virtual ~FftwComplexMatrix ()
 Destructor. More...
 
FftwComplexMatrixoperator= (const FftwComplexMatrix &src)
 Operator = not allowed for public.
 
void createR2CFftPlan3D (RealMatrix &inMatrix)
 Create FFTW plan for 3D Real-to-Complex. More...
 
void createC2RFftPlan3D (RealMatrix &outMatrix)
 Create FFTW plan for 3D Complex-to-Real. More...
 
void createR2CFftPlan1DX (RealMatrix &inMatrix)
 Create an FFTW plan for 1D Real-to-Complex in the x dimension. More...
 
void createR2CFftPlan1DY (RealMatrix &inMatrix)
 Create an FFTW plan for 1D Real-to-Complex in the y dimension. More...
 
void createR2CFftPlan1DZ (RealMatrix &inMatrix)
 Create an FFTW plan for 1D Real-to-Complex in the z dimension. More...
 
void createC2RFftPlan1DX (RealMatrix &outMatrix)
 Create FFTW plan for Complex-to-Real in the x dimension. More...
 
void createC2RFftPlan1DY (RealMatrix &outMatrix)
 Create FFTW plan for Complex-to-Real in the y dimension. More...
 
void createC2RFftPlan1DZ (RealMatrix &outMatrix)
 Create FFTW plan for Complex-to-Real in the z dimension. More...
 
void computeR2CFft3D (RealMatrix &inMatrix)
 Compute forward out-of-place 3D Real-to-Complex FFT. More...
 
void computeC2RFft3D (RealMatrix &outMatrix)
 Compute forward out-of-place 3D Complex-to-Real FFT. More...
 
void computeR2CFft1DX (RealMatrix &inMatrix)
 Compute 1D out-of-place Real-to-Complex FFT in the x dimension. More...
 
void computeR2CFft1DY (RealMatrix &inMatrix)
 Compute 1D out-of-place Real-to-Complex FFT in the y dimension. More...
 
void computeR2CFft1DZ (RealMatrix &inMatrix)
 Compute 1D out-of-place Real-to-Complex FFT in the z dimension. More...
 
void computeC2RFft1DX (RealMatrix &outMatrix)
 Compute 1D out-of-place Complex-to-Real FFT in the x dimension. More...
 
void computeC2RFft1DY (RealMatrix &outMatrix)
 Compute 1D out-of-place Complex-to-Real FFT in the y dimension. More...
 
void computeC2RFft1DZ (RealMatrix &outMatrix)
 Compute 1D out-of-place Complex-to-Real FFT in the z dimension. More...
 
- Public Member Functions inherited from ComplexMatrix
 ComplexMatrix ()=delete
 Default constructor not allowed.
 
 ComplexMatrix (const DimensionSizes &dimensionSizes)
 Constructor. More...
 
 ComplexMatrix (const ComplexMatrix &)=delete
 Copy constructor not allowed.
 
virtual ~ComplexMatrix ()
 Destructor. More...
 
ComplexMatrixoperator= (const ComplexMatrix &)
 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...
 
virtual FloatComplexgetComplexData ()
 Get raw complex data out of the class (for direct kernel access). More...
 
virtual const FloatComplexgetComplexData () const
 Get raw complex data out of the class (for direct kernel access). More...
 
FloatComplexoperator[] (const size_t &index)
 Operator []. More...
 
const FloatComplexoperator[] (const size_t &index) const
 Operator [], constant version. More...
 
FloatComplexGetElementFrom3D (const size_t x, const size_t y, const size_t z)
 Get element from 3D matrix. More...
 
const FloatComplexGetElementFrom3D (const size_t x, const size_t y, const size_t z) const
 Get element from 3D matrix, constant 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.
 

Static Public Member Functions

static void exportWisdom ()
 Export wisdom to the file. More...
 
static void importWisdom ()
 Import wisdom from the file. More...
 
static void deleteStoredWisdom ()
 Destroy wisdom in the file (delete it). More...
 

Protected Member Functions

virtual void allocateMemory ()
 Allocate memory for the FFTW matrix. More...
 
virtual void freeMemory ()
 Free memory of the FFTW matrix. More...
 

Static Protected Member Functions

static std::string getWisdomFileName ()
 

Protected Attributes

fftwf_plan mR2CFftPlan3D
 FFTW plan for the 3D Real-to-Complex transform.
 
fftwf_plan mC2RFftPlan3D
 FFTW plan for the 3D Complex-to-Real transform.
 
fftwf_plan mR2CFftPlan1DX
 FFTW plan for the 1D Real-to-Complex transform in the x dimension.
 
fftwf_plan mR2CFftPlan1DY
 FFTW plan for the 3D Real-to-Complex transform in the y dimension.
 
fftwf_plan mR2CFftPlan1DZ
 FFTW plan for the 3D Real-to-Complex transform in the z dimension.
 
fftwf_plan mC2RFftPlan1DX
 FFTW plan for the 3D Complex-to-Real transform in the x dimension.
 
fftwf_plan mC2RFftPlan1DY
 FFTW plan for the 3D Complex-to-Real transform in the y dimension.
 
fftwf_plan mC2RFftPlan1DZ
 FFTW plan for the 3Z Complex-to-Real transform in the z dimension.
 
- 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.
 

Static Protected Attributes

static const unsigned kFftMeasureFlag = FFTW_MEASURE
 FFTW plan flag.
 
static const std::string kFftWisdomFileExtension = "FFTW_Wisdom"
 The file extension for FFTW wisdom.
 

Detailed Description

Class implementing 3D and 1D Real-To-Complex and Complex-To-Real transforms using FFTW interface.

Definition at line 46 of file FftwComplexMatrix.h.

Constructor & Destructor Documentation

◆ FftwComplexMatrix()

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

Constructor.

Definition at line 54 of file FftwComplexMatrix.cpp.

◆ ~FftwComplexMatrix()

FftwComplexMatrix::~FftwComplexMatrix ( )
virtual

Destructor.

Definition at line 66 of file FftwComplexMatrix.cpp.

Member Function Documentation

◆ allocateMemory()

void FftwComplexMatrix::allocateMemory ( )
protectedvirtual

Allocate Memory using fftwf_malloc function to ensure correct alignment.

Reimplemented from BaseFloatMatrix.

Definition at line 785 of file FftwComplexMatrix.cpp.

◆ computeC2RFft1DX()

void FftwComplexMatrix::computeC2RFft1DX ( RealMatrix outMatrix)

There are two versions of this routine for GCC+FFTW and ICPC + MKL, otherwise it will not build! The FFTW version processes the whole matrix at one while the MKL slab by slab.

Parameters
[out]outMatrix- Output matrix
Exceptions
std::runtime_error- If the plan is not valid.

Compute 1D out-of-place Complex-to-Real FFT in the x dimension.

Definition at line 644 of file FftwComplexMatrix.cpp.

◆ computeC2RFft1DY()

void FftwComplexMatrix::computeC2RFft1DY ( RealMatrix outMatrix)

There are two versions of this routine for GCC+FFTW and ICPC + MKL, otherwise it will not build! The FFTW version processes the whole matrix at one while the MKL slab by slab.

Parameters
[out]outMatrix- Output matrix
Exceptions
std::runtime_error- If the plan is not valid.

Compute 1D out-of-place Complex-to-Real FFT in the y dimension.

Definition at line 676 of file FftwComplexMatrix.cpp.

◆ computeC2RFft1DZ()

void FftwComplexMatrix::computeC2RFft1DZ ( RealMatrix outMatrix)

There are two versions of this routine for GCC+FFTW and ICPC + MKL, otherwise it will not build! The FFTW version processes the whole matrix at one while the MKL slab by slab.

Parameters
[out]outMatrixOutput matrix
Exceptions
std::runtime_error- If the plan is not valid.

Compute 1D out-of-place Complex-to-Real FFT in the Z dimension

Definition at line 708 of file FftwComplexMatrix.cpp.

◆ computeC2RFft3D()

void FftwComplexMatrix::computeC2RFft3D ( RealMatrix outMatrix)
Parameters
[out]outMatrix- Output of the inverse FFT.
Exceptions
std::runtime_error- If the plan is not valid.

Compute inverse out-of-place 3D Complex to Real FFT.

Definition at line 532 of file FftwComplexMatrix.cpp.

◆ computeR2CFft1DX()

void FftwComplexMatrix::computeR2CFft1DX ( RealMatrix inMatrix)

There are two versions of this routine for GCC+FFTW and ICPC + MKL, otherwise it will not build! The FFTW version processes the whole matrix at one while the MKL slab by slab.

Parameters
[in]inMatrix- Input matrix
Exceptions
std::runtime_error- If the plan is not valid.

Compute 1D out-of-place Real-to-Complex FFT in the x dimension.

Definition at line 548 of file FftwComplexMatrix.cpp.

◆ computeR2CFft1DY()

void FftwComplexMatrix::computeR2CFft1DY ( RealMatrix inMatrix)

There are two versions of this routine for GCC+FFTW and ICPC + MKL, otherwise it will not build! The FFTW version processes the whole matrix at one while the MKL slab by slab.

Parameters
[in]inMatrix- Input matrix
Exceptions
std::runtime_error- If the plan is not valid.

Compute 1D out-of-place Real-to-Complex FFT in the Y dimension.

Definition at line 580 of file FftwComplexMatrix.cpp.

◆ computeR2CFft1DZ()

void FftwComplexMatrix::computeR2CFft1DZ ( RealMatrix inMatrix)

There are two versions of this routine for GCC+FFTW and ICPC + MKL, otherwise it will not build! The FFTW version processes the whole matrix at one while the MKL slab by slab.

Parameters
[in]inMatrix- Input matrix
Exceptions
std::runtime_error- If the plan is not valid.

Compute 1D out-of-place Real-to-Complex FFT in the z dimension.

Definition at line 612 of file FftwComplexMatrix.cpp.

◆ computeR2CFft3D()

void FftwComplexMatrix::computeR2CFft3D ( RealMatrix inMatrix)
Parameters
[in]inMatrix- Input data for the forward FFT.
Exceptions
std::runtime_error- If the plan is not valid.

Computer forward out-of place 3D Real-to-Complex FFT.

Definition at line 516 of file FftwComplexMatrix.cpp.

◆ createC2RFftPlan1DX()

void FftwComplexMatrix::createC2RFftPlan1DX ( RealMatrix outMatrix)

There are two versions of this routine for GCC+FFTW and ICPC + MKL, otherwise it will not build!
The FFTW version processes the whole matrix at one while the MKL slab by slab.

Parameters
[in,out]outMatrix- RealMatrix of which to create the plan.
Exceptions
std::runtime_error- If the plan can't be created.
Warning
Unless FFTW_ESTIMATE flag is specified, the content of the outMatrix is destroyed!

Create FFTW plan for Complex-to-Real in the x dimension.

Definition at line 328 of file FftwComplexMatrix.cpp.

◆ createC2RFftPlan1DY()

void FftwComplexMatrix::createC2RFftPlan1DY ( RealMatrix outMatrix)

There are two versions of this routine for GCC+FFTW and ICPC + MKL, otherwise it will not build!
The FFTW version processes the whole matrix at one while the MKL slab by slab.

Parameters
[in,out]outMatrix- RealMatrix of which to create the plan.
Exceptions
std::runtime_error- If the plan can't be created.
Warning
Unless FFTW_ESTIMATE flag is specified, the content of the outMatrix is destroyed!

Create FFTW plan for Complex-to-Real in the y dimension.

Definition at line 391 of file FftwComplexMatrix.cpp.

◆ createC2RFftPlan1DZ()

void FftwComplexMatrix::createC2RFftPlan1DZ ( RealMatrix outMatrix)

There are two versions of this routine for GCC+FFTW and ICPC + MKL, otherwise it will not build!
The FFTW version processes the whole matrix at one while the MKL slab by slab.

Parameters
[in,out]outMatrix- RealMatrix of which to create the plan.
Exceptions
std::runtime_error- If the plan can't be created.
Warning
Unless FFTW_ESTIMATE flag is specified, the content of the outMatrix is destroyed!

Create FFTW plan for Complex-to-Real in the z dimension.

Definition at line 454 of file FftwComplexMatrix.cpp.

◆ createC2RFftPlan3D()

void FftwComplexMatrix::createC2RFftPlan3D ( RealMatrix outMatrix)
Parameters
[in]outMatrix- Output matrix serving as scratch place for planning.
Exceptions
std::runtime_error- If the plan can't be created.
Warning
Unless FFTW_ESTIMATE flag is specified, the content of the outMatrix is destroyed!

Create an FFTW plan for 3D Complex-to-Real.

Definition at line 120 of file FftwComplexMatrix.cpp.

◆ createR2CFftPlan1DX()

void FftwComplexMatrix::createR2CFftPlan1DX ( RealMatrix inMatrix)

There are two versions of this routine for GCC+FFTW and ICPC + MKL, otherwise it will not build!
The FFTW version processes the whole matrix at one while the MKL slab by slab.

Parameters
[in,out]inMatrix- RealMatrix of which to create the plan.
Exceptions
std::runtime_error- If the plan can't be created.
Warning
Unless FFTW_ESTIMATE flag is specified, the content of the inMatrix is destroyed!

Create an FFTW plan for 1D Real-to-Complex in the x dimension.

Definition at line 139 of file FftwComplexMatrix.cpp.

◆ createR2CFftPlan1DY()

void FftwComplexMatrix::createR2CFftPlan1DY ( RealMatrix inMatrix)

There are two versions of this routine for GCC+FFTW and ICPC + MKL, otherwise it will not build!
The FFTW version processes the whole matrix at one while the MKL slab by slab

Parameters
[in,out]inMatrix- RealMatrix of which to create the plan.
Exceptions
std::runtime_error- If the plan can't be created.
Warning
Unless FFTW_ESTIMATE flag is specified, the content of the inMatrix is destroyed!
The FFTW matrix must be able to store 2 * (nx * (ny /2 + 1) * nz) elements - possibly more than reduced dims!

Create an FFTW plan for 1D Real-to-Complex in the y dimension.

Definition at line 203 of file FftwComplexMatrix.cpp.

◆ createR2CFftPlan1DZ()

void FftwComplexMatrix::createR2CFftPlan1DZ ( RealMatrix inMatrix)

There are two versions of this routine for GCC+FFTW and ICPC + MKL, otherwise it will not build!
The FFTW version processes the whole matrix at one while the MKL slab by slab

Parameters
[in,out]inMatrix- RealMatrix of which to create the plan.
Exceptions
std::runtime_error- If the plan can't be created.
Warning
Unless FFTW_ESTIMATE flag is specified, the content of the inMatrix is destroyed!
The FFTW matrix must be able to store 2 * (nx * by * (nz / 2 + 1)) elements - possibly more than reduced dims!

Create an FFTW plan for 1D Real-to-Complex in the z dimension.

Definition at line 266 of file FftwComplexMatrix.cpp.

◆ createR2CFftPlan3D()

void FftwComplexMatrix::createR2CFftPlan3D ( RealMatrix inMatrix)
Parameters
[in]inMatrix- Input matrix serving as scratch place for planning.
Exceptions
std::runtime_error- If the plan can't be created.
Warning
Unless FFTW_ESTIMATE flag is specified, the content of the inMatrix is destroyed!

Create an FFTW plan for 3D Real-to-Complex.

Definition at line 101 of file FftwComplexMatrix.cpp.

◆ deleteStoredWisdom()

void FftwComplexMatrix::deleteStoredWisdom ( )
static

Delete stored wisdom (delete the file).

Definition at line 771 of file FftwComplexMatrix.cpp.

◆ exportWisdom()

void FftwComplexMatrix::exportWisdom ( )
static
Warning
This routine is supported only while compiling with the GNU C++ compiler.

Export wisdom to the file.

Definition at line 740 of file FftwComplexMatrix.cpp.

◆ freeMemory()

void FftwComplexMatrix::freeMemory ( )
protectedvirtual

Free memory using fftwf_free.

Reimplemented from BaseFloatMatrix.

Definition at line 807 of file FftwComplexMatrix.cpp.

◆ getWisdomFileName()

std::string FftwComplexMatrix::getWisdomFileName ( )
staticprotected

Get Wisdom file name (derive it form the checkpoint filename).

Returns
the filename for wisdom.

Get Wisdom file name (derive it form the checkpoint filename).

Definition at line 817 of file FftwComplexMatrix.cpp.

◆ importWisdom()

void FftwComplexMatrix::importWisdom ( )
static
Warning
This routine is supported only while compiling with the GNU C++ compiler.

Import wisdom from the file.

Definition at line 755 of file FftwComplexMatrix.cpp.


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