VERB_code_2.2  2
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
Matrix3D< T > Class Template Reference

#include <Matrix.h>

Public Member Functions

 Matrix3D ()
 Default constructor. Do nothing. More...
 
 Matrix3D (const Matrix3D< T > &M)
 
 Matrix3D (int size_x, int size_y, int size_z)
 
 ~Matrix3D ()
 
void AllocateMemory (int size_x, int size_y, int size_z)
 
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
 
T & operator() (int x, int y, int z)
 Return the (x,y,z) value of matrix. More...
 
T & Value (int x, int y, int z)
 Return the (x,y,z) value of matrix. More...
 
Matrix3D< T > & MatrixArray ()
 Return pointer to the instance of the class. More...
 
Matrix3Doperator= (const Matrix3D< T > &M)
 
Matrix3Doperator= (const T Val)
 
const Matrix3Doperator+ () const
 
const Matrix3D operator- () const
 
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...
 
void writeToFile (string filename)
 Save matrix to a file. More...
 
void writeToFile (string filename, Matrix3D< T > &grid_x, Matrix3D< T > &grid_y, Matrix3D< T > &grid_z)
 Save matrix to a file, including grid. More...
 
void readFromFile (string filename)
 Load matrix from a file. More...
 
void readFromFile (string filename, Matrix3D< T > &grid_x, Matrix3D< T > &grid_y, Matrix3D< T > &grid_z)
 Load matrix to a file. More...
 
int index1d (int x, int y, int z)
 Returns index of the element (x,y,z) in 1d array. More...
 
max ()
 
maxabs ()
 
Matrix3D< T > abs ()
 
Matrix2D< T > xSlice (int p_x) const
 
Matrix2D< T > ySlice (int p_y) const
 
Matrix2D< T > zSlice (int p_z) const
 

Public Attributes

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

Private Attributes

T * plane_array
 Plane array of values. All rows saved in the memory one after anouther as a big array. More...
 
T *** matrix_array
 Matrix array (array of links to other arrays). Final likns pointed to the memory addresses of the plane array. Matrix[x][y] can be used. More...
 

Detailed Description

template<typename T>
class Matrix3D< T >

Matrix 3D class

Matrixes and operations.

Definition at line 212 of file Matrix.h.

Constructor & Destructor Documentation

template<typename T>
Matrix3D< T >::Matrix3D ( )
inline

Default constructor. Do nothing.

Definition at line 225 of file Matrix.h.

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

Constructor. Create matrix equal to Matrix M.

Parameters
&M- Matrix M.

Definition at line 826 of file Matrix.cpp.

template<class T>
Matrix3D< T >::Matrix3D ( int  x_size,
int  y_size,
int  z_size 
)

Constructor. Allocate memory.

Definition at line 813 of file Matrix.cpp.

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

Destructor

Definition at line 835 of file Matrix.cpp.

Member Function Documentation

template<class T >
void Matrix3D< T >::AllocateMemory ( int  x_size,
int  y_size,
int  z_size 
)

Allocating memory and filling it with zero-values.

Definition at line 844 of file Matrix.cpp.

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

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

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

Parameters
i- number of element to return

Definition at line 867 of file Matrix.cpp.

template<typename T>
T** Matrix3D< T >::operator[] ( int  i) const
inline

Definition at line 234 of file Matrix.h.

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 [x][y][z]. If DEBUG_MODE defined, check if matrix has been initialized.

Definition at line 883 of file Matrix.cpp.

template<typename T>
T& Matrix3D< T >::Value ( int  x,
int  y,
int  z 
)
inline

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

Definition at line 236 of file Matrix.h.

template<typename T>
Matrix3D<T>& Matrix3D< T >::MatrixArray ( )
inline

Return pointer to the instance of the class.

Definition at line 237 of file Matrix.h.

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

Makes matrix equal to Matrix M.

Parameters
&M- Matrix M.

Definition at line 902 of file Matrix.cpp.

References Matrix3D< T >::initialized, Matrix3D< T >::matrix_array, Matrix3D< T >::name, Matrix3D< T >::size_x, Matrix3D< T >::size_y, Matrix3D< T >::size_z, and VF::T().

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.

Definition at line 961 of file Matrix.cpp.

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

Definition at line 245 of file Matrix.h.

template<typename T>
const Matrix3D Matrix3D< T >::operator- ( ) const
inline

Definition at line 246 of file Matrix.h.

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)

Definition at line 975 of file Matrix.cpp.

References Matrix3D< T >::matrix_array.

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)

Definition at line 988 of file Matrix.cpp.

References Matrix3D< T >::matrix_array.

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)

Definition at line 1001 of file Matrix.cpp.

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)

Definition at line 1014 of file Matrix.cpp.

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)

Definition at line 1027 of file Matrix.cpp.

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)

Definition at line 1040 of file Matrix.cpp.

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)

Definition at line 1053 of file Matrix.cpp.

References Matrix3D< T >::matrix_array.

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)

Definition at line 1066 of file Matrix.cpp.

References Matrix3D< T >::matrix_array.

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.

Definition at line 1079 of file Matrix.cpp.

References Matrix3D< T >::matrix_array.

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.

Definition at line 1093 of file Matrix.cpp.

References Matrix3D< T >::matrix_array.

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.

Definition at line 1108 of file Matrix.cpp.

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.

Definition at line 1123 of file Matrix.cpp.

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.

Definition at line 1137 of file Matrix.cpp.

References Matrix3D< T >::matrix_array.

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.

Definition at line 1151 of file Matrix.cpp.

References Matrix3D< T >::matrix_array.

template<class T >
void Matrix3D< T >::writeToFile ( string  filename)

Save matrix to a file.

Write matrix to file. File has two header lines.

Definition at line 1167 of file Matrix.cpp.

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

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.

Definition at line 1188 of file Matrix.cpp.

References Matrix3D< T >::name.

template<class T >
void Matrix3D< T >::readFromFile ( string  filename)

Load matrix from a file.

Read matrix data from file.

Definition at line 1211 of file Matrix.cpp.

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

Load matrix to a file.

Read matrix data from file with grid

Definition at line 1249 of file Matrix.cpp.

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 1d array

Definition at line 1299 of file Matrix.cpp.

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

Return maximum value of the matrix.

Definition at line 1308 of file Matrix.cpp.

References VF::T().

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

Return absolute maximum value of the matrix.

Definition at line 1325 of file Matrix.cpp.

References VF::T().

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

Return absolute value of the matrix.

Definition at line 1342 of file Matrix.cpp.

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

Make x-slice of 3d matrix - 2d matrix.

Definition at line 1360 of file Matrix.cpp.

References Matrix2D< T >::name.

template<class T >
Matrix2D< T > Matrix3D< T >::ySlice ( int  p_y) const

Make y-slice of 3d matrix - 2d matrix.

Definition at line 1376 of file Matrix.cpp.

References Matrix2D< T >::name.

template<class T >
Matrix2D< T > Matrix3D< T >::zSlice ( int  p_z) const

Make z-slice of 3d matrix - 2d matrix.

Definition at line 1392 of file Matrix.cpp.

References Matrix2D< T >::name.

Member Data Documentation

template<typename T>
T* Matrix3D< T >::plane_array
private

Plane array of values. All rows saved in the memory one after anouther as a big array.

Definition at line 215 of file Matrix.h.

template<typename T>
T*** Matrix3D< T >::matrix_array
private

Matrix array (array of links to other arrays). Final likns pointed to the memory addresses of the plane array. Matrix[x][y] can be used.

Definition at line 217 of file Matrix.h.

template<typename T>
bool Matrix3D< T >::initialized

Flag, equal true if initialized.

Definition at line 219 of file Matrix.h.

template<typename T>
int Matrix3D< T >::size_x

Definition at line 220 of file Matrix.h.

template<typename T>
int Matrix3D< T >::size_y

Definition at line 220 of file Matrix.h.

template<typename T>
int Matrix3D< T >::size_z

size x, size y, size z

Definition at line 220 of file Matrix.h.

template<typename T>
string Matrix3D< T >::name

name of the Matrix

Definition at line 221 of file Matrix.h.

template<typename T>
string Matrix3D< T >::change_ind

Variables useful for tracking of changes (time of change can be stored here)

Definition at line 282 of file Matrix.h.


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