VERB_code_2.3
Matrix1D< T > Class Template Reference

one dimensional matrix class More...

#include <Matrix.h>

Public Member Functions

 Matrix1D (int x_size)
 
 Matrix1D (int x_size, string name)
 
 Matrix1D (const Matrix1D< T > &M)
 
 ~Matrix1D ()
 
void AllocateMemory (int x_size)
 
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.
 
Matrix1D< T > & MatrixArray ()
 Return pointer to the instance of the class.
 
T * MatrixArrayPointer ()
 Return pointer to the instance of the class.
 
const Matrix1Doperator+ () const
 Return itself as positive version of values.
 
const Matrix1D operator- () const
 Return negative version of values.
 
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)
 rational
 
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.
 
bool initialized
 Flag, equal true if initialized.
 
int size_x
 size x
 
string name
 name of the Matrix
 

Detailed Description

template<typename T>
class Matrix1D< T >

one dimensional matrix class

Matrixes and operations.

Definition at line 41 of file Matrix.h.

Constructor & Destructor Documentation

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

Constructor.

Runs allocating memory function.

Parameters
x_size- size of the matrix

Definition at line 139 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 123 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 154 of file Matrix.cpp.

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

Destructor. Destruct the class.

Definition at line 163 of file Matrix.cpp.

Member Function Documentation

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

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

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

Allocating memory

Parameters
x_size- size x

Definition at line 173 of file Matrix.cpp.

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

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

Dot product.

Dot product

Definition at line 349 of file Matrix.cpp.

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

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

Norm.

Norm of vector

Definition at line 336 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 224 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 282 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 296 of file Matrix.cpp.

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

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 269 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 189 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 206 of file Matrix.cpp.

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

polynomial + linear Some other weird interpolation attempts.

Definition at line 1673 of file Matrix.cpp.

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

polynomial Some other weird interpolation attempts.

Definition at line 1691 of file Matrix.cpp.

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

Read matrix data from file.

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

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 Recipies. Treats boundary conditions separate, i.e. use boundary values on boundary conditions and extrapolation, use linear interpolation for next-to-the-boundary points. Has additional mechanism of smoothening the interpolation - makes it more linear according to the parameters lin_spline_coef and max_second_der. Spline interpolation is linear + additional terms from second derivatives (look Numerical Recipies). If second derivative > max_second_der the second derivatives are multiplied 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 1455 of file Matrix.cpp.

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

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

Write matrix data to file.

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


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