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

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

#include <Matrix.h>

Public Member Functions

 Matrix1D (int size_q1, string name="f")
 
 Matrix1D (const Matrix1D< T > &M)
 
 ~Matrix1D ()
 
virtual void AllocateMemory (int size_q1)
 
T & operator[] (int i)
 Return the i-th value of matrix. More...
 
T & operator[] (int i) const
 const function to return the i-th value of matrix More...
 
T & operator() (int q1)
 Return the x-th value of matrix. More...
 
T & Value (int q1)
 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 the matrix.
 
const Matrix1D operator- () const
 Return the matrix with all values multiplied by -1.
 
Matrix1Doperator= (const Matrix1D< T > &M)
 
Matrix1Doperator= (const T val)
 
Matrix1Doperator+= (const Matrix1D< T > &M)
 
Matrix1Doperator-= (const Matrix1D< T > &M)
 
Matrix1Doperator*= (const T Val)
 
Matrix1Doperator/= (const T Val)
 
Matrix1Doperator+= (const T Val)
 Add the Val to each matrix element, stores result in the matrix it's applied to.
 
Matrix1Doperator-= (const T Val)
 Substract the Val from each matrix element, stores result in the matrix it's applied to.
 
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.
 
norm () const
 Norm. More...
 
virtual void writeToFile (string filename)
 
virtual void writeToFile (string filename, Matrix1D< T > &grid_q1)
 
virtual void readFromFile (string filename)
 
virtual void readFromFile (string filename, const Matrix1D< T > grid_q1)
 
virtual void readFromMatlabFile (string filename, int columnNumber=1)
 
virtual void readFromMatlabFile (string filename, const Matrix1D< T > grid_q1)
 
min ()
 
max ()
 
maxabs ()
 
Matrix1D< T > abs ()
 

Public Attributes

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

Detailed Description

template<typename T>
class Matrix1D< T >

A matrix of 1 dimensions that is immutable.

Matrix 1D class

Matrixes and operations.

Constructor & Destructor Documentation

template<class T >
Matrix1D< T >::Matrix1D ( int  size_q1,
string  name = "f" 
)

Constructor.

Runs allocating memory function and store matrix name.

Parameters
size_q1- size of the matrix
name- name of the matrix
template<class T >
Matrix1D< T >::Matrix1D ( const Matrix1D< T > &  M)

Constructor.

Make new matrix equal to Matrix M.

Parameters
&M- matrix M
template<class T >
Matrix1D< T >::~Matrix1D ( )

Destructor. Destruct the class.

Member Function Documentation

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

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

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

Allocating memory

Parameters
size_q1- size x
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.
template<class T >
T Matrix1D< T >::max ( )

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

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

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

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

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

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

Norm.

Norm of vector

template<class T >
T & Matrix1D< T >::operator() ( int  i1)
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
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
template<class T >
Matrix1D< T > & Matrix1D< T >::operator*= ( const T  Val)
inline

Multiplication to a value. Result is stored into applied matrix (left hand side matrix)

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

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

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

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

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.#define DEBUG_MODE

Parameters
Val- value Val
template<class T >
Matrix1D< T > & Matrix1D< T >::operator/= ( const T  Val)
inline

Division by a value. Result is stored into applied matrix (left hand side matrix)

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
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
template<class T >
T & Matrix1D< T >::operator[] ( int  i1)
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
template<class T >
T & Matrix1D< T >::operator[] ( int  i1) const
inline

const function to return the i-th value of matrix

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
template<class T >
void Matrix1D< T >::readFromFile ( string  filename)
virtual

Read matrix data from file.

template<class T >
void Matrix1D< T >::readFromFile ( string  filename,
const Matrix1D< T >  grid_q1 
)
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
grid_q1- checks grid data against the file data
template<class T >
void Matrix1D< T >::readFromMatlabFile ( string  file,
int  columnNumber = 1 
)
virtual

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

Function for reading from matlab file in 1-dimension 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 >
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.
template<class T >
void Matrix1D< T >::writeToFile ( string  filename)
virtual

Write matrix data to file.

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

Write matrix data to file with grid.


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