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

#include <Matrix.h>

Public Member Functions

 Matrix1D ()
 
 Matrix1D (int size_x)
 
 Matrix1D (int x_size, string name)
 
 Matrix1D (const Matrix1D< T > &M)
 
 ~Matrix1D ()
 
void AllocateMemory (int size_x)
 
T & operator[] (int i)
 Return the i-th value of matrix. More...
 
T & operator[] (int i) const
 
T & operator() (int x)
 Return the x-th value of matrix. More...
 
T & Value (int x)
 Return the (x,y) value of matrix. More...
 
Matrix1D< T > & MatrixArray ()
 Return pointer to the instance of the class. More...
 
T * MatrixArrayPointer ()
 Return pointer to the instance of the class. More...
 
const Matrix1Doperator+ () const
 
const Matrix1D operator- () const
 
Matrix1Doperator= (const Matrix1D< T > &M)
 
Matrix1Doperator= (const T val)
 
Matrix1D operator* (const T Val) const
 
Matrix1D operator/ (const T Val) const
 
Matrix1D times (const Matrix1D< T > &M) const
 Arraywise multiplication (A.*B), stores result in a new matrix. More...
 
Matrix1D divide (const Matrix1D< T > &M) const
 Arraywise division (A./B), stores result in a new matrix. More...
 
dot (const Matrix1D< T > &M) const
 Dot product. More...
 
norm () const
 Norm. More...
 
void Akima_interpolation (Matrix1D< T > &old_function, Matrix1D< T > &old_grid, Matrix1D< T > &new_grid, int extrapolation_type=0, double lb=0, double ub=0)
 
void Akima_interpolation2 (Matrix1D< T > &old_function, Matrix1D< T > &old_grid, Matrix1D< T > &new_grid, int extrapolation_type=0, double lb=0, double ub=0)
 
void Interpolate (Matrix1D< T > &old_function, Matrix1D< T > &old_grid, Matrix1D< T > &new_grid)
 
void Spline (Matrix1D< T > &old_function, Matrix1D< T > &old_grid, Matrix1D< T > &new_grid, double lb, double ub, double lin_spline_coef=0, double max_second_der=0)
 
void Polint (Matrix1D< T > &old_function, Matrix1D< T > &old_grid, Matrix1D< T > &new_grid)
 
void Ratint (Matrix1D< T > &old_function, Matrix1D< T > &old_grid, Matrix1D< T > &new_grid)
 
void Polilinear (Matrix1D< T > &old_function, Matrix1D< T > &old_grid, Matrix1D< T > &new_grid, double lb, double ub)
 
void Spline2 (Matrix1D< T > &old_function, Matrix1D< T > &old_grid, Matrix1D< T > &new_grid, double lb, double ub, double lin_spline_coef=0, double max_second_der=0)
 
void writeToFile (string filename)
 
void writeToFile (string filename, Matrix1D< T > &grid_x)
 
void readFromFile (string filename)
 
void readFromFile (string filename, Matrix1D< T > &grid_x)
 

Public Attributes

T * matrix_array
 Array to keep the values. More...
 
bool initialized
 Flag, equal true if initialized. More...
 
int size_x
 size x More...
 
string name
 name of the Matrix More...
 

Detailed Description

template<typename T>
class Matrix1D< T >

Matrix 1D class

Matrixes and operations.

Definition at line 41 of file Matrix.h.

Constructor & Destructor Documentation

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

Definition at line 50 of file Matrix.h.

template<class T >
Matrix1D< T >::Matrix1D ( int  x_size)

Constructor.

Runs allocating memory function.

Parameters
x_size- size of the matrix

Definition at line 142 of file Matrix.cpp.

template<class T >
Matrix1D< T >::Matrix1D ( int  x_size,
string  name 
)

Constructor.

Runs allocating memory function and store matrix name.

Parameters
x_size- size of the matrix
name- name of the matrix

Definition at line 126 of file Matrix.cpp.

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

Constructor.

Make new matrix equal to Matrix M.

Parameters
&M- matrix M

Definition at line 157 of file Matrix.cpp.

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

Destructor. Destruct the class.

Definition at line 166 of file Matrix.cpp.

Member Function Documentation

template<class T >
void Matrix1D< T >::AllocateMemory ( int  x_size)

Allocating memory

Parameters
x_size- size x

Definition at line 176 of file Matrix.cpp.

template<class T >
T & Matrix1D< T >::operator[] ( int  i)
inline

Return the i-th value of matrix.

Operator [i], returns value of element i. If DEBUG_MODE defined, check if matrix has been initialized.

Parameters
i- number of element to return

Definition at line 192 of file Matrix.cpp.

template<class T >
T & Matrix1D< T >::operator[] ( int  i) const
inline

Operator [i], returns value of element i, version returns 'const' value, can not be later modified. If DEBUG_MODE defined, check if matrix has been initialized.

Parameters
i- number of element to return

Definition at line 209 of file Matrix.cpp.

template<class T >
T & Matrix1D< T >::operator() ( int  x)
inline

Return the x-th value of matrix.

Operator (x), returns value of element x. If DEBUG_MODE defined, check if matrix has been initialized. No dofference between [] and () operators for 1d-matrix class.

Parameters
x- number of element to return

Definition at line 227 of file Matrix.cpp.

template<typename T>
T& Matrix1D< T >::Value ( int  x)
inline

Return the (x,y) value of matrix.

Definition at line 62 of file Matrix.h.

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

Return pointer to the instance of the class.

Definition at line 63 of file Matrix.h.

template<typename T>
T* Matrix1D< T >::MatrixArrayPointer ( )
inline

Return pointer to the instance of the class.

Definition at line 64 of file Matrix.h.

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

Definition at line 67 of file Matrix.h.

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

Definition at line 68 of file Matrix.h.

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

Make matrix equal to matrix M Return the same instance of class Matrix.

Parameters
&M- matrix M

Definition at line 244 of file Matrix.cpp.

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

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

Make matrix equal to value Val. Return the same instance of class Matrix.

Parameters
Val- value val

Definition at line 272 of file Matrix.cpp.

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

Multiply a matrix to a value Val. Return new instance of class Matrix.

Parameters
Val- value Val

Definition at line 285 of file Matrix.cpp.

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

Divide a matrix to a value Val. Return new instance of class Matrix.

Parameters
Val- value Val

Definition at line 299 of file Matrix.cpp.

template<class T>
Matrix1D< T > Matrix1D< T >::times ( const Matrix1D< 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 313 of file Matrix.cpp.

References Matrix1D< T >::matrix_array.

template<class T>
Matrix1D< T > Matrix1D< T >::divide ( const Matrix1D< 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 327 of file Matrix.cpp.

References Matrix1D< T >::matrix_array.

template<class T>
T Matrix1D< T >::dot ( const Matrix1D< T > &  W) const
inline

Dot product.

Dot product

Definition at line 352 of file Matrix.cpp.

References Matrix1D< T >::size_x, and VF::T().

template<class T >
T Matrix1D< T >::norm ( ) const
inline

Norm.

Norm of vector

Definition at line 339 of file Matrix.cpp.

References VF::T().

template<class T>
void Matrix1D< T >::Akima_interpolation ( Matrix1D< T > &  old_function,
Matrix1D< T > &  old_grid,
Matrix1D< T > &  new_grid,
int  extrapolation_type = 0,
double  lb = 0,
double  ub = 0 
)

Akima interpolation

Definition at line 1755 of file Matrix.cpp.

References akima(), Matrix1D< T >::matrix_array, and Matrix1D< T >::size_x.

template<class T>
void Matrix1D< T >::Akima_interpolation2 ( Matrix1D< T > &  old_function,
Matrix1D< T > &  old_grid,
Matrix1D< T > &  new_grid,
int  extrapolation_type = 0,
double  lb = 0,
double  ub = 0 
)

Akima interpolation - second test version

Definition at line 1871 of file Matrix.cpp.

References akima2(), Matrix1D< T >::matrix_array, and Matrix1D< T >::size_x.

template<class T>
void Matrix1D< T >::Interpolate ( Matrix1D< T > &  old_function,
Matrix1D< T > &  old_grid,
Matrix1D< T > &  new_grid 
)

Linear interpolation. Runs interpolation function from Numerical Recepies.

Definition at line 1417 of file Matrix.cpp.

References Maths::Interpolation::Linear::getValue(), Matrix1D< T >::matrix_array, and Matrix1D< T >::size_x.

template<class T>
void Matrix1D< T >::Spline ( Matrix1D< T > &  old_function,
Matrix1D< T > &  old_grid,
Matrix1D< T > &  new_grid,
double  lb,
double  ub,
double  lin_spline_coef = 0,
double  max_second_der = 0 
)

Spline interpolation. Runs interpolation functions from Numerical Recepies. Treats boundary conditions separete, i.e. use boundary values on baundary conditions and extrapolation, use linear interpolation for next-to-the-boundary points. Has additional mechenism of smoothning the interpolation - makes it more linear according the parameters lin_spline_coef and max_second_der. Spline interpolation is linear + additional terms from second derivatives (look Numerical Recepies). If second derivative > max_second_der the second derivatives are multiplid by lin_spline_coef.

Parameters
&old_function- old function
&old_grid- old grid
&new_grid- new grid
lb- low boundary value
ub- upper boundary value
lin_spline_coef- coefficient to multiply the second derivatives terms (makes interpolation more smooth)
max_second_der- maximum second derivatives, all greater derivatives gonna be multiplied by lin_spline_coef
Todo:
Check the index of the last argument of the spline interpolation.

Definition at line 1458 of file Matrix.cpp.

References Matrix1D< T >::matrix_array, Matrix1D< T >::size_x, spline(), and splint().

template<class T>
void Matrix1D< T >::Polint ( Matrix1D< T > &  old_function,
Matrix1D< T > &  old_grid,
Matrix1D< T > &  new_grid 
)

polinomial Some other wired interpolation attempts.

Definition at line 1694 of file Matrix.cpp.

References err, Matrix1D< T >::matrix_array, polint(), and Matrix1D< T >::size_x.

template<class T>
void Matrix1D< T >::Ratint ( Matrix1D< T > &  old_function,
Matrix1D< T > &  old_grid,
Matrix1D< T > &  new_grid 
)

Definition at line 1710 of file Matrix.cpp.

References err, Matrix1D< T >::matrix_array, ratint(), and Matrix1D< T >::size_x.

template<class T>
void Matrix1D< T >::Polilinear ( Matrix1D< T > &  old_function,
Matrix1D< T > &  old_grid,
Matrix1D< T > &  new_grid,
double  lb,
double  ub 
)

polinomial + lin Some other wired interpolation attempts.

Definition at line 1676 of file Matrix.cpp.

References Matrix1D< T >::matrix_array, polilinear(), and Matrix1D< T >::size_x.

template<class T>
void Matrix1D< T >::Spline2 ( Matrix1D< T > &  old_function,
Matrix1D< T > &  old_grid,
Matrix1D< T > &  new_grid,
double  lb,
double  ub,
double  lin_spline_coef = 0,
double  max_second_der = 0 
)

Another spline interpolation. An attempt to make it more stable. Runs interpolation functions from Numerical Recepies. Treats boundary conditions separete, i.e. use boundary values on baundary conditions and extrapolation, use linear interpolation for next-to-the-boundary points. Has additional mechenism of smoothning the interpolation - makes it more linear according the parameters lin_spline_coef and max_second_der. Spline interpolation is linear + additional terms from second derivatives (look Numerical Recepies). If second derivative > max_second_der the second derivatives are multiplid by lin_spline_coef.

Parameters
&old_function- old function
&old_grid- old grid
&new_grid- new grid
lb- low boundary value
ub- upper boundary value
lin_spline_coef- coefficient to multiply the second derivatives terms (makes interpolation more smooth)
max_second_der- maximum second derivatives, all greater derivatives gonna be multiplied by lin_spline_coef

Definition at line 1624 of file Matrix.cpp.

References Matrix1D< T >::matrix_array, Matrix1D< T >::size_x, spline(), and splint().

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

Write matrix data to file.

Definition at line 369 of file Matrix.cpp.

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

Write matrix data to file with grid.

Definition at line 388 of file Matrix.cpp.

References Matrix1D< T >::name.

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

Read matrix data from file.

Definition at line 408 of file Matrix.cpp.

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

Read matrix data from file and check 'grid'

Todo:
All matrix readings change to readFromFile() function

Definition at line 441 of file Matrix.cpp.

References err.

Member Data Documentation

template<typename T>
T* Matrix1D< T >::matrix_array

Array to keep the values.

Definition at line 43 of file Matrix.h.

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

Flag, equal true if initialized.

Definition at line 45 of file Matrix.h.

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

size x

Definition at line 46 of file Matrix.h.

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

name of the Matrix

Definition at line 47 of file Matrix.h.


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