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

#include <Matrix.h>

Public Member Functions

 Matrix2D ()
 
 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]. More...
 
T * operator[] (int i) const
 
T & operator() (int x, int y)
 Return the (x,y)-th value of matrix. More...
 
T & Value (int x, int y)
 Return the (x,y) value of matrix. More...
 
Matrix2D< T > & MatrixArray ()
 Return pointer to the instance of the class. More...
 
const Matrix2Doperator+ () const
 
const Matrix2D operator- () const
 
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. More...
 
int size_x
 
int size_y
 size x, size_y More...
 
string name
 name of the Matrix More...
 

Private Attributes

T ** matrix_array
 

Detailed Description

template<typename T>
class Matrix2D< T >

Matrix 2D class

Matrixes and operations.

Definition at line 132 of file Matrix.h.

Constructor & Destructor Documentation

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

Definition at line 143 of file Matrix.h.

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 507 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 494 of file Matrix.cpp.

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

Destructor.

Definition at line 516 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 527 of file Matrix.cpp.

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

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

Definition at line 152 of file Matrix.h.

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

Definition at line 153 of file Matrix.h.

template<typename T>
T& Matrix2D< T >::operator() ( int  x,
int  y 
)
inline

Return the (x,y)-th value of matrix.

Definition at line 154 of file Matrix.h.

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

Return the (x,y) value of matrix.

Definition at line 155 of file Matrix.h.

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

Return pointer to the instance of the class.

Definition at line 156 of file Matrix.h.

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

Definition at line 159 of file Matrix.h.

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

Definition at line 160 of file Matrix.h.

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 544 of file Matrix.cpp.

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

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 578 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 597 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 612 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 642 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 627 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 657 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 1900 of file Matrix.cpp.

References Linear2D(), Matrix2D< T >::size_x, and Matrix2D< T >::size_y.

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

Returns corresponding index of 1d array

Definition at line 670 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 685 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 708 of file Matrix.cpp.

References Matrix2D< T >::name.

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

Read matrix data from file.

Definition at line 727 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 762 of file Matrix.cpp.

References err.

Member Data Documentation

template<typename T>
T** Matrix2D< 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. Also, all rows saved in the memory one after anouther as a big array. So Matrix[x+x_size*y] can be also used.

Definition at line 136 of file Matrix.h.

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

Flag, equal true if initialized.

Definition at line 138 of file Matrix.h.

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

Definition at line 139 of file Matrix.h.

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

size x, size_y

Definition at line 139 of file Matrix.h.

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

name of the Matrix

Definition at line 140 of file Matrix.h.


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