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

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

#include <Matrix.h>

Public Member Functions

 Matrix2D (const Matrix2D< T > &M)
 
 Matrix2D (int size_q1, int size_q2)
 
 ~Matrix2D ()
 
virtual void AllocateMemory (int size_q1, int size_q2)
 
T * operator[] (int i)
 Return the i-th pointer to 1d-array. Next [j] can be applied, so we have regular [i][j].
 
T * operator[] (int i) const
 const function to return the i-th pointer to 1d-array. Next [j] can be applied, so we have regular [i][j].
 
T & operator() (int q1, int q2)
 Return the (x,y)-th value of matrix.
 
T & Value (int q1, int q2)
 Return the (x,y) value of matrix.
 
Matrix2D< T > & MatrixArray ()
 Return pointer to the instance of the class.
 
const Matrix2Doperator+ () const
 unary : return the matrix
 
const Matrix2D operator- () const
 unary : return the matrix with all values multiplied by -1
 
Matrix2Doperator= (const Matrix2D< T > &M)
 
Matrix2Doperator= (const T val)
 
Matrix2Doperator+= (const Matrix2D< T > &M)
 
Matrix2Doperator-= (const Matrix2D< T > &M)
 
Matrix2Doperator*= (const T Val)
 
Matrix2D operator* (const T Val) const
 
Matrix2D operator/ (const T Val) const
 
Matrix2D times (const Matrix2D< T > &M) const
 Arraywise multiplication (A.*B), stores result in a new matrix. More...
 
Matrix2D divide (const Matrix2D< T > &M) const
 Arraywise division (A./B), stores result in a new matrix. More...
 
int index1d (int q1, int q2) const
 
max ()
 
maxabs ()
 
min ()
 
Matrix2D< T > abs ()
 
Matrix2D max_of (T val)
 
virtual void writeToFile (string filename)
 
virtual void writeToFile (string filename, Matrix2D< T > &grid_q1, Matrix2D< T > &grid_q2)
 
virtual void readFromFile (string filename, int column=1)
 
virtual void readFromFile (string filename, const Matrix2D< T > grid_q1, const Matrix2D< T > grid_q2)
 
virtual void readFromMatlabFile (string filename, int column=1)
 
virtual void readFromMatlabFile (string filename, const Matrix2D< T > grid_q1, const Matrix2D< T > grid_q2)
 
Matrix1D< T > xSlice (int p_q1) const
 
Matrix1D< T > ySlice (int p_q2) const
 

Public Attributes

bool initialized
 Flag, equal true if initialized.
 
int size_q1
 size x
 
int size_q2
 size_y
 
string name
 name of the Matrix
 

Detailed Description

template<typename T>
class Matrix2D< T >

A matrix of 2 dimensions that is immutable.

Matrix 2D class

Matrixes and operations.

Constructor & Destructor Documentation

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

Constructor. Create new matrix from the Matrix M.

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

Constructor. Allocate memory.

Parameters
size_q1- x size
size_q2- y size
template<class T >
Matrix2D< T >::~Matrix2D ( )

Destructor.

Member Function Documentation

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

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

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

Allocate memory.

Parameters
size_q1- x size
size_q2- y size
template<class T >
Matrix2D< T > Matrix2D< T >::divide ( const Matrix2D< T > &  M) const
inline

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

Divide all values of matrix to values of matrix M.

Parameters
&M- matrix M.
template<class T >
int Matrix2D< T >::index1d ( int  x,
int  y 
) const
inline

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

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

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

template<class T >
Matrix2D< T > Matrix2D< T >::max_of ( val)

Divide all values of matrix to value Val.

Parameters
val- value to divide.
template<class T >
T Matrix2D< T >::maxabs ( )

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

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

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

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

Multiply matrix to Val.

Parameters
Val- value Val.
template<class T >
Matrix2D< T > & Matrix2D< T >::operator*= ( const T  Val)
inline

Multiplication to a value. Result is stored into the left hand side matrix

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

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

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

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

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

Divide matrix to Val.

Parameters
Val- value Val.
template<class T >
Matrix2D< T > & Matrix2D< T >::operator= ( const Matrix2D< T > &  M)

Make matrix equal to Matrix M.

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

Make matrix equal to value Val.

Parameters
val- value Val.
template<class T >
void Matrix2D< T >::readFromFile ( string  filename,
int  read_column = 1 
)
virtual

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 Matrix2D< T >::readFromFile ( string  filename,
const Matrix2D< T >  grid_x,
const Matrix2D< T >  grid_y 
)
virtual

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 - checks grids data against the file data
template<class T >
void Matrix2D< T >::readFromMatlabFile ( string  file,
int  columnNumber = 1 
)
virtual

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

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

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

Multiply all values of matrix to values of matrix M.

Parameters
&M- matrix M.
template<class T >
void Matrix2D< T >::writeToFile ( string  filename)
virtual

Writes the matrix to a file. File has two header lines.

Parameters
filename- file name
template<class T >
void Matrix2D< T >::writeToFile ( string  filename,
Matrix2D< T > &  grid_x,
Matrix2D< T > &  grid_y 
)
virtual

Write the matrix to a file using other two matrixes as a grid. Simply that means - write all three matrixes to a file.

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

Make x-slice of 2d matrix = 1d matrix.

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

Make y-slice of 2d matrix = 1d matrix.


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