VERB_code_2.3
Matrix2D< T > Class Template Reference

two dimensional matrix class More...

#include <Matrix.h>

Public Member Functions

 Matrix2D (const Matrix2D< T > &M)
 
 Matrix2D (int size_x, int size_y)
 
 ~Matrix2D ()
 
void AllocateMemory (int size_x, int size_y)
 
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
 Return the i-th pointer to 1d-array as const.
 
T & operator() (int x, int y)
 Return the (x,y)-th value of matrix.
 
T & Value (int x, int y)
 Return the (x,y) value of matrix.
 
Matrix2D< T > & MatrixArray ()
 Return pointer to the instance of the class.
 
const Matrix2Doperator+ () const
 Return itself as positive version of values.
 
const Matrix2D operator- () const
 Return negative version of values.
 
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...
 
Matrix2D max_of (T val)
 
void Interpolate (Matrix2D< T > &old_function, Matrix2D< T > &old_grid_x, Matrix2D< T > &old_grid_y, Matrix2D< T > &new_grid_x, Matrix2D< T > &new_grid_y)
 
int index1d (int x, int y) const
 
void writeToFile (string filename)
 
void writeToFile (string filename, Matrix2D< T > &grid_x, Matrix2D< T > &grid_y)
 
void readFromFile (string filename)
 
void readFromFile (string filename, Matrix2D< T > &grid_x, Matrix2D< T > &grid_y)
 

Public Attributes

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

Detailed Description

template<typename T>
class Matrix2D< T >

two dimensional matrix class

Matrixes and operations.

Definition at line 132 of file Matrix.h.

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

Definition at line 504 of file Matrix.cpp.

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

Constructor. Allocate memory.

Parameters
x_size- x size
y_size- y size

Definition at line 491 of file Matrix.cpp.

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

Destructor.

Definition at line 513 of file Matrix.cpp.

Member Function Documentation

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

Allocate memory.

Parameters
x_size- x size
y_size- y size

Definition at line 524 of file Matrix.cpp.

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.

Definition at line 624 of file Matrix.cpp.

template<class T >
int Matrix2D< T >::index1d ( int  x,
int  y 
) const
inline

Returns corresponding index of 1d array

Definition at line 667 of file Matrix.cpp.

template<class T>
void Matrix2D< T >::Interpolate ( Matrix2D< T > &  old_function,
Matrix2D< T > &  old_grid_x,
Matrix2D< T > &  old_grid_y,
Matrix2D< T > &  new_grid_x,
Matrix2D< T > &  new_grid_y 
)

Linear 2D interpolation.

Not sure if it is working.

Definition at line 1897 of file Matrix.cpp.

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

Divide all values of matrix to value Val.

Parameters
val- value to divide.

Definition at line 654 of file Matrix.cpp.

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

Multiply matrix to Val.

Parameters
Val- value Val.

Definition at line 594 of file Matrix.cpp.

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

Divide matrix to Val.

Parameters
Val- value Val.

Definition at line 609 of file Matrix.cpp.

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

Make matrix equal to Matrix M.

Parameters
&M- Matrix M.

Definition at line 541 of file Matrix.cpp.

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

Make matrix equal to value Val.

Parameters
val- value Val.

Definition at line 575 of file Matrix.cpp.

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

Read matrix data from file.

Definition at line 724 of file Matrix.cpp.

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

Read matrix data from file and check grid

Definition at line 759 of file Matrix.cpp.

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.

Definition at line 639 of file Matrix.cpp.

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

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

Todo:
Change the name 'writeToFile' in Matrix classes to 'write' or something.
Parameters
filename- file name

Definition at line 682 of file Matrix.cpp.

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

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

Definition at line 705 of file Matrix.cpp.


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