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

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

#include <Matrix.h>

Public Member Functions

 Matrix4D ()
 Default constructor. Do nothing.
 
 Matrix4D (const Matrix4D< T > &M)
 
 Matrix4D (int size_w, int size_x, int size_y, int size_z)
 
 ~Matrix4D ()
 
virtual void AllocateMemory (int size_w, int size_x, int size_y, int size_z)
 
T *** operator[] (int i)
 Return the i-th pointer to 3d-array. Next [j][k][l] can be applied, so we have regular [i][j][k][l]. More...
 
T *** operator[] (int i) const
 const function to return the i-th pointer to 3d-array. Next [j][k][l] can be applied, so we have regular [i][j][k][l].
 
T & operator() (int w, int x, int y, int z)
 Return the (w,x,y,z) value of matrix. More...
 
T & Value (int w, int x, int y, int z)
 Return the (w,x,y,z) value of matrix.
 
Matrix4D< T > & MatrixArray ()
 Return pointer to the instance of the class.
 
Matrix4Doperator= (const Matrix4D< T > &M)
 
Matrix4Doperator= (const T Val)
 
const Matrix4Doperator+ () const
 unary : return the matrix
 
const Matrix4D operator- () const
 unary : return the matrix with all values multiplied by -1
 
Matrix4Doperator+= (const Matrix4D< T > &M)
 
Matrix4Doperator-= (const Matrix4D< T > &M)
 
Matrix4Doperator*= (const T Val)
 
Matrix4Doperator/= (const T Val)
 
Matrix4Doperator+= (const T Val)
 Add Val to each matrix element, stores result in the matrix it's applied to. More...
 
Matrix4Doperator-= (const T Val)
 Substract Val from each element in this matrix, stores result in the matrix it's applied to. More...
 
Matrix4Dtimes_equal (const Matrix4D< T > &M)
 Arraywise multiplication (A.*B), stores result in the matrix it's applied to. More...
 
Matrix4Ddivide_equal (const Matrix4D< T > &M)
 Arraywise division (A./B), stores result in the matrix it's applied to. More...
 
Matrix4D operator+ (const Matrix4D< T > &M) const
 
Matrix4D operator- (const Matrix4D< T > &M) const
 
Matrix4D operator* (const T Val) const
 
Matrix4D operator/ (const T Val) const
 
Matrix4D times (const Matrix4D< T > &M) const
 Arraywise multiplication (A.*B), stores result in a new matrix. More...
 
Matrix4D divide (const Matrix4D< 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, Matrix4D< T > &grid_w, Matrix4D< T > &grid_x, Matrix4D< T > &grid_y, Matrix4D< T > &grid_z)
 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 Matrix4D< T > grid_w, const Matrix4D< T > grid_x, const Matrix4D< T > grid_y, const Matrix4D< T > grid_z)
 Load matrix to a file. More...
 
virtual void writeToMatlabFile (string filename, string info="")
 Save matrix to a file. More...
 
virtual void writeToMatlabFile (string filename, Matrix4D< T > &grid_w, Matrix4D< T > &grid_x, Matrix4D< T > &grid_y, Matrix4D< T > &grid_z)
 
virtual void readFromMatlabFile (string file, int column=1)
 
virtual void readFromMatlabFile (string filename, const Matrix4D< T > grid_w, const Matrix4D< T > grid_x, const Matrix4D< T > grid_y, const Matrix4D< T > grid_z)
 
int index1d (int w, int x, int y, int z)
 Returns index of the element (x,y,z) in 1d array. More...
 
min ()
 
max ()
 
maxabs ()
 
Matrix4D< T > abs ()
 
Matrix3D< T > wSlice (int p_w) const
 
Matrix3D< T > xSlice (int p_x) const
 
Matrix3D< T > ySlice (int p_y) const
 
Matrix3D< T > zSlice (int p_z) const
 
Matrix2D< T > wxSlice (int p_w, int p_x) const
 
Matrix2D< T > wySlice (int p_w, int p_y) const
 
Matrix2D< T > wzSlice (int p_w, int p_z) const
 
Matrix2D< T > xySlice (int p_x, int p_y) const
 
Matrix2D< T > xzSlice (int p_x, int p_z) const
 
Matrix2D< T > yzSlice (int p_y, int p_z) const
 
Matrix1D< T > wxySlice (int p_w, int p_x, int p_y) const
 
Matrix1D< T > wxzSlice (int p_w, int p_x, int p_z) const
 
Matrix1D< T > wyzSlice (int p_w, int p_y, int p_z) const
 
Matrix1D< T > xyzSlice (int p_x, int p_y, int p_z) const
 

Public Attributes

bool initialized
 Flag, equal true if initialized.
 
int size_w
 size w
 
int size_x
 size x
 
int size_y
 size y
 
int size_z
 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 Matrix4D< T >

A matrix of 4 dimensions that is immutable.

Matrix 4D class

Matrixes and operations.

Constructor & Destructor Documentation

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

Constructor. Create matrix equal to Matrix M.

Parameters
&M- Matrix M.
template<class T >
Matrix4D< T >::Matrix4D ( int  w_size,
int  x_size,
int  y_size,
int  z_size 
)

Constructor. Allocate memory.

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

Destructor

Member Function Documentation

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

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

template<class T >
void Matrix4D< T >::AllocateMemory ( int  w_size,
int  x_size,
int  y_size,
int  z_size 
)
virtual

Allocating memory and filling it with zero-values.

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

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

Divide each element of the current matrix by the corresponding element of matrix M and return new matrix

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

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

Divide each element of the current matrix by the corresponding element of matrix M and return this matrix

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Multiply each element of the current matrix by Val and return this matrix

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

Add each element of the matrix by the corresponding element of matrix M and return new matrix

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

Add each element of the current matrix by the corresponding element in M and return this matrix

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

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

Add each element of the current matrix by Val and return this matrix

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

Substract each element of the matrix by the corresponding element of matrix M and return new matrix

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

Subtract each element of the current matrix by the corresponding element in M and return this matrix

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

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

Subtract each element of the current matrix by Val and return this matrix

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

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

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

Divide each element of the current matrix by Val and return this matrix

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

Makes current matrix equal to Matrix M and returns the current matrix

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

Makes every element in Matrix equal to Val and returns this matrix

template<class T >
T *** Matrix4D< T >::operator[] ( int  i)
inline

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

Operator [i], returns pointer to 3D array. Next [j][k][l] 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 Matrix4D< 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 Matrix4D< T >::readFromFile ( string  filename,
const Matrix4D< T >  grid_w,
const Matrix4D< T >  grid_x,
const Matrix4D< T >  grid_y,
const Matrix4D< 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
gridsw,x,y,z - checks grids data against the file data
template<class T >
void Matrix4D< T >::readFromMatlabFile ( string  file,
int  columnNumber = 1 
)
virtual

Function for reading from matlab file in 4-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 Matrix4D< T >::readFromMatlabFile ( string  file,
const Matrix4D< T >  grid_w,
const Matrix4D< T >  grid_x,
const Matrix4D< T >  grid_y,
const Matrix4D< T >  grid_z 
)
virtual

Function for reading from matlab file in 4-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 >
Matrix4D< T > Matrix4D< T >::times ( const Matrix4D< T > &  M) const
inline

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

Multiply each element of the matrix by the corresponding element of matrix M and return new matrix

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

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

Multiply each element of the current matrix by the corresponding element of matrix M and return this matrix

template<class T >
void Matrix4D< 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 Matrix4D< T >::writeToFile ( string  filename,
Matrix4D< T > &  grid_w,
Matrix4D< T > &  grid_x,
Matrix4D< T > &  grid_y,
Matrix4D< T > &  grid_z 
)
virtual

Save matrix to a file, including grid.

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

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

Save matrix to a file.

Write matrix to .mat file. Creates a struct for the matrix. Struct has 7 fields in including - arr time size, size1, size2, size3, size4

template<class T >
void Matrix4D< T >::writeToMatlabFile ( string  file,
Matrix4D< T > &  grid_w,
Matrix4D< T > &  grid_x,
Matrix4D< T > &  grid_y,
Matrix4D< T > &  grid_z 
)
virtual

Write matrix to file, using 4 other matrixes as a grid (simply - write all 5 matrixes to the file). Uses the createStructMatrix() function to pack all the grid dimensions into seperate variables and then combines these variables into a single matlab structure to save in .mat

template<class T >
Matrix3D< T > Matrix4D< T >::wSlice ( int  p_w) const

Take w-slice of 4d matrix turning it into 3d matrix. squeeze matrix to 3d getting all the data when the w dimension is at index p_w

Parameters
p_w- index at which to slice w dimension
template<class T >
Matrix2D< T > Matrix4D< T >::wxSlice ( int  p_w,
int  p_x 
) const

Take wx-slice of 4d matrix turning it into a 2d matrix.

Parameters
p_w- index at which to slice w dimension
p_x- index at which to slice x dimension
template<class T >
Matrix1D< T > Matrix4D< T >::wxySlice ( int  p_w,
int  p_x,
int  p_y 
) const

Take wxy-slice of 4d matrix turning it into a 1d matrix.

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

Take wxz-slice of 4d matrix turning it into a 1d matrix.

Parameters
p_w- index at which to slice w dimension
p_x- index at which to slice x dimension
p_z- index at which to slice z dimension
template<class T >
Matrix2D< T > Matrix4D< T >::wySlice ( int  p_w,
int  p_y 
) const

Take wy-slice of 4d matrix turning it into a 2d matrix.

Parameters
p_w- index at which to slice w dimension
p_y- index at which to slice y dimension
template<class T >
Matrix1D< T > Matrix4D< T >::wyzSlice ( int  p_w,
int  p_y,
int  p_z 
) const

Take wyz-slice of 4d matrix turning it into a 1d matrix.

Parameters
p_w- index at which to slice w dimension
p_y- index at which to slice y dimension
p_z- index at which to slice z dimension
template<class T >
Matrix2D< T > Matrix4D< T >::wzSlice ( int  p_w,
int  p_z 
) const

Take wz-slice of 4d matrix turning it into a 2d matrix.

Parameters
p_w- index at which to slice w dimension
p_z- index at which to slice z dimension
template<class T >
Matrix3D< T > Matrix4D< T >::xSlice ( int  p_x) const

Take x-slice of 4d matrix turining it into 3d matrix. squeeze matrix to 3d getting all the data when the x dimension is at index p_x

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

Take xy-slice of 4d matrix turning it into a 2d 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 > Matrix4D< T >::xyzSlice ( int  p_x,
int  p_y,
int  p_z 
) const

Take xyz-slice of 4d 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
p_z- index at which to slice z dimension
template<class T >
Matrix2D< T > Matrix4D< T >::xzSlice ( int  p_x,
int  p_z 
) const

Take xz-slice of 4d matrix turning it into a 2d matrix.

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

Take y-slice of 4d matrix turning it into 3d matrix. squeeze matrix to 3d getting all the data when the y dimension is at index p_y

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

Take yz-slice of 4d matrix turning it into a 2d matrix.

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

Take z-slice of 4d matrix turning it into 3d matrix. squeeze matrix to 3d getting all the data when the z dimension is at index p_z

Parameters
p_z- index at which to slice z dimension

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