VERB4D
Public Member Functions | Public Attributes | List of all members
Matrix3D< T > Class Template Reference

A matrix of 3 dimensions that is immutable. More...

#include <Matrix.h>

Public Member Functions

 Matrix3D ()
 Default constructor. Do nothing.
 
 Matrix3D (const Matrix3D< T > &M)
 
 Matrix3D (int size_q1, int size_q2, int size_q3)
 
 ~Matrix3D ()
 
virtual void AllocateMemory (int size_q1, int size_q2, int size_q3)
 
T ** operator[] (int i)
 Return the i-th pointer to 2d-array. Next [j][k] can be applied, so we have regular [i][j][k]. More...
 
T ** operator[] (int i) const
 const function to return the i-th pointer to 2d-array. Next [j][k] can be applied, so we have regular [i][j][k].
 
T & operator() (int q1, int q2, int q3)
 Return the (x,y,z) value of matrix. More...
 
T & Value (int q1, int q2, int q3)
 Return the (x,y,z) value of matrix.
 
Matrix3D< T > & MatrixArray ()
 Return pointer to the instance of the class.
 
Matrix3Doperator= (const Matrix3D< T > &M)
 
Matrix3Doperator= (const T Val)
 
const Matrix3Doperator+ () const
 unary : return the matrix
 
const Matrix3D operator- () const
 unary : return the matrix with all values multiplied by -1
 
Matrix3Doperator+= (const Matrix3D< T > &M)
 
Matrix3Doperator-= (const Matrix3D< T > &M)
 
Matrix3Doperator*= (const T Val)
 
Matrix3Doperator/= (const T Val)
 
Matrix3Doperator+= (const T Val)
 Add the Val to each matrix element, stores result in the matrix it's applied to. More...
 
Matrix3Doperator-= (const T Val)
 Substract the Val from each matrix element, stores result in the matrix it's applied to. More...
 
Matrix3Dtimes_equal (const Matrix3D< T > &M)
 Arraywise multiplication (A.*B), stores result in the matrix it's applied to. More...
 
Matrix3Ddivide_equal (const Matrix3D< T > &M)
 Arraywise division (A./B), stores result in the matrix it's applied to. More...
 
Matrix3D operator+ (const Matrix3D< T > &M) const
 
Matrix3D operator- (const Matrix3D< T > &M) const
 
Matrix3D operator* (const T Val) const
 
Matrix3D operator/ (const T Val) const
 
Matrix3D times (const Matrix3D< T > &M) const
 Arraywise multiplication (A.*B), stores result in a new matrix. More...
 
Matrix3D divide (const Matrix3D< T > &M) const
 Arraywise division (A./B), stores result in a new matrix. More...
 
virtual void writeToFile (string filename, string info="")
 Save matrix to a file. More...
 
virtual void writeToFile (string filename, Matrix3D< T > &grid_q1, Matrix3D< T > &grid_q2, Matrix3D< T > &grid_q3)
 Save matrix to a file, including grid. More...
 
virtual void readFromFile (string filename, int column=1)
 Load matrix from a file. More...
 
virtual void readFromFile (string filename, const Matrix3D< T > grid_q1, const Matrix3D< T > grid_q2, const Matrix3D< T > grid_q3)
 Load matrix to a file. More...
 
virtual void readFromMatlabFile (string filename, int column=1)
 
virtual void readFromMatlabFile (string filename, const Matrix3D< T > grid_q1, const Matrix3D< T > grid_q2, const Matrix3D< T > grid_q3)
 
int index1d (int q1, int q2, int q3)
 Returns index of the element (x,y,z) in 1d array. More...
 
min ()
 
max ()
 
maxabs ()
 
Matrix3D< T > abs ()
 
Matrix2D< T > xSlice (int p_q1) const
 
Matrix2D< T > ySlice (int p_q2) const
 
Matrix2D< T > zSlice (int p_q3) const
 
Matrix1D< T > xySlice (int p_i1, int p_i2) const
 
Matrix1D< T > yzSlice (int p_i2, int p_i3) const
 
Matrix1D< T > xzSlice (int p_i1, int p_i3) const
 

Public Attributes

bool initialized
 Flag, equal true if initialized.
 
int size_q1
 size x
 
int size_q2
 size y
 
int size_q3
 size z
 
string name
 name of the Matrix
 
string change_ind
 Variables useful for tracking of changes (time of change can be stored here)
 

Detailed Description

template<typename T>
class Matrix3D< T >

A matrix of 3 dimensions that is immutable.

Matrix 3D class

Matrixes and operations.

Constructor & Destructor Documentation

template<class T >
Matrix3D< T >::Matrix3D ( const Matrix3D< T > &  M)

Constructor. Create matrix equal to Matrix M.

Parameters
&M- Matrix M.
template<class T >
Matrix3D< T >::Matrix3D ( int  size_q1,
int  size_q2,
int  size_q3 
)

Constructor. Allocate memory.

template<class T >
Matrix3D< T >::~Matrix3D ( )

Destructor

Member Function Documentation

template<class T >
Matrix3D< T > Matrix3D< T >::abs ( )

Return absolute value of the 3d matrix. Changes every element to a positive value with the same magnitude

template<class T >
void Matrix3D< T >::AllocateMemory ( int  size_q1,
int  size_q2,
int  size_q3 
)
virtual

Allocating memory and filling it with zero-values.

template<class T >
Matrix3D< T > Matrix3D< T >::divide ( const Matrix3D< T > &  M) const
inline

Arraywise division (A./B), stores result in a new matrix.

Divide each element of the matrix to corresponds element of matrix M.

template<class T >
Matrix3D< T > & Matrix3D< T >::divide_equal ( const Matrix3D< T > &  M)
inline

Arraywise division (A./B), stores result in the matrix it's applied to.

Division of each element of one matrices to the element of another. Result is stored into applied matrix (left hand side matrix)

template<class T >
int Matrix3D< T >::index1d ( int  x,
int  y,
int  z 
)
inline

Returns index of the element (x,y,z) in 1d array.

Returns corresponding index of 3d matrix if represented as a 1d array

Parameters
x,y,z- index of element in every dimension for the 3d matrix
template<class T >
T Matrix3D< T >::max ( )

Return maximum value of the 3d matrix. Default value seet to 0

template<class T >
T Matrix3D< T >::maxabs ( )

Return absolute maximum value of the 3d matrix. Default value set to 0

template<class T >
T Matrix3D< T >::min ( )

Return minimum value of the 3d matrix. Default value set to 1e99

template<class T >
T & Matrix3D< T >::operator() ( int  x,
int  y,
int  z 
)
inline

Return the (x,y,z) value of matrix.

Operator (x, y, z), returns value of element [i1][i2][i3]. If DEBUG_MODE defined, check if matrix has been initialized.

template<class T >
Matrix3D< T > Matrix3D< T >::operator* ( const T  Val) const
inline

Multiply each element of the matrix to Val, save result to a new matrix.

template<class T >
Matrix3D< T > & Matrix3D< T >::operator*= ( const T  Val)
inline

Multiplication to a value. Result is stored into applied matrix (left hand side matrix)

template<class T >
Matrix3D< T > Matrix3D< T >::operator+ ( const Matrix3D< T > &  M) const
inline

Add each element of the matrix to corresponds element of matrix M.

template<class T >
Matrix3D< T > & Matrix3D< T >::operator+= ( const Matrix3D< T > &  M)
inline

Matrix summation, result is stored into applied matrix (left hand side matrix)

template<class T >
Matrix3D< T > & Matrix3D< T >::operator+= ( const T  Val)
inline

Add the Val to each matrix element, stores result in the matrix it's applied to.

Summation with a value. Result is stored into applied matrix (left hand side matrix)

template<class T >
Matrix3D< T > Matrix3D< T >::operator- ( const Matrix3D< T > &  M) const
inline

Substract each element of the matrix to corresponds element of matrix M.

template<class T >
Matrix3D< T > & Matrix3D< T >::operator-= ( const Matrix3D< T > &  M)
inline

Matrix subtraction, result is stored into applied matrix (left hand side matrix)

template<class T >
Matrix3D< T > & Matrix3D< T >::operator-= ( const T  Val)
inline

Substract the Val from each matrix element, stores result in the matrix it's applied to.

Subtraction of a value. Result is stored into applied matrix (left hand side matrix)

template<class T >
Matrix3D< T > Matrix3D< T >::operator/ ( const T  Val) const
inline

Divide each element of the matrix to Val, save result to a new matrix.

template<class T >
Matrix3D< T > & Matrix3D< T >::operator/= ( const T  Val)
inline

Division by a value. Result is stored into applied matrix (left hand side matrix)

template<class T >
Matrix3D< T > & Matrix3D< T >::operator= ( const Matrix3D< T > &  M)
inline

Makes matrix equal to Matrix M.

Parameters
&M- Matrix M.
template<class T >
Matrix3D< T > & Matrix3D< T >::operator= ( const T  Val)
inline

Makes 3D matrix from 2D matrix. The 3rd dimension makes equal to 1. Makes Matrix equal to value Val.

template<class T >
T ** Matrix3D< T >::operator[] ( int  i1)
inline

Return the i-th pointer to 2d-array. Next [j][k] can be applied, so we have regular [i][j][k].

Operator [i1], returns pointer to 2D array. Next [i2][k] can be applied to return value. If DEBUG_MODE defined, check if matrix has been initialized.

Parameters
i- number of element to return
template<class T >
void Matrix3D< T >::readFromFile ( string  filename,
int  read_column = 1 
)
virtual

Load matrix from a file.

Read matrix data from file with grid, by column

Overloaded readFromFile function

Parameters
filename- file to read grids from
read_column- read up to this column from file
template<class T >
void Matrix3D< T >::readFromFile ( string  filename,
const Matrix3D< T >  grid_x,
const Matrix3D< T >  grid_y,
const Matrix3D< T >  grid_z 
)
virtual

Load matrix to a file.

Read matrix data from file with grid, Checks if the matrix data in the file is the same as the grids that were sent in with error < 1e-8, if not within error range will signal error and exit

Overloaded readFromFile function

Parameters
filename- file to read grids from
gridsx,y,z - checks grids data against the file data
template<class T >
void Matrix3D< T >::readFromMatlabFile ( string  file,
int  columnNumber = 1 
)
virtual

Function for reading from matlab file in 3-dimensions Will check the variables, order them in (P, R/L, V, K, Val) format and then set matrix_array to be the variable with the corresponding column number This is the same as the readFromFile() function although only compatible with .mat files instead of .plt or other text files

template<class T >
void Matrix3D< T >::readFromMatlabFile ( string  file,
const Matrix3D< T >  grid_x,
const Matrix3D< T >  grid_y,
const Matrix3D< T >  grid_z 
)
virtual

Function for reading from matlab file in 3-dimensions Will check the variables in the order they are saved in matlab, thus (P R V K Var) should be the standard The variables will be checked against the input grid parameters in order to make sure the right variables/values are being loaded This is the same as the readFromFile() function although only compatible with .mat files instead of .plt or other text files

template<class T >
Matrix3D< T > Matrix3D< T >::times ( const Matrix3D< T > &  M) const
inline

Arraywise multiplication (A.*B), stores result in a new matrix.

Multiply each element of the matrix to corresponds element of matrix M.

template<class T >
Matrix3D< T > & Matrix3D< T >::times_equal ( const Matrix3D< T > &  M)
inline

Arraywise multiplication (A.*B), stores result in the matrix it's applied to.

Multiplication between each element of the matrices (not a matrix multiplication). Result is stored into applied matrix (left hand side matrix)

template<class T >
void Matrix3D< T >::writeToFile ( string  filename,
string  info = "" 
)
virtual

Save matrix to a file.

Write matrix to file. File has two header lines.

template<class T >
void Matrix3D< T >::writeToFile ( string  filename,
Matrix3D< T > &  grid_x,
Matrix3D< T > &  grid_y,
Matrix3D< T > &  grid_z 
)
virtual

Save matrix to a file, including grid.

Write matrix to file, using 3 other matrixes as a grid (simply - write all 4 matrixes to the file). File has two header lines.

template<class T >
Matrix2D< T > Matrix3D< T >::xSlice ( int  p_x) const

Take x-slice of 3d matrix turning it into a 2d matrix.

Parameters
p_x- index at which to slice x dimension
template<class T >
Matrix1D< T > Matrix3D< T >::xySlice ( int  p_x,
int  p_y 
) const

Take xy-slice of 3d matrix turning it into a 1d matrix.

Parameters
p_x- index at which to slice x dimension
p_y- index at which to slice y dimension
template<class T >
Matrix1D< T > Matrix3D< T >::xzSlice ( int  p_x,
int  p_z 
) const

Take xz-slice of 3d matrix turning it into a 1d matrix.

Parameters
p_x- index at which to slice x dimension
p_z- index at which to slice z dimension
template<class T >
Matrix2D< T > Matrix3D< T >::ySlice ( int  p_y) const

Take y-slice of 3d matrix turning it into a 2d matrix.

Parameters
p_y- index at which to slice y dimension
template<class T >
Matrix1D< T > Matrix3D< T >::yzSlice ( int  p_y,
int  p_z 
) const

Take yz-slice of 3d matrix turning it into a 1d matrix.

Parameters
p_y- index at which to slice y dimension
p_z- index at which to slice z dimension
template<class T >
Matrix2D< T > Matrix3D< T >::zSlice ( int  p_z) const

Take z-slice of 3d matrix turning it into a 2d matrix.

Parameters
p_z- index at which to slice z dimension

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