Rosetta Utilities  2015.09
Public Member Functions | Private Attributes | List of all members
numeric::MathMatrix< T > Class Template Reference

#include <MathMatrix.hh>

Public Member Functions

 MathMatrix ()
 default constructor More...
 
 MathMatrix (const Size NUMBER_ROWS, const Size NUMBER_COLS, const T &FILL_VALUE=T(0))
 construct from dimension and possible filler More...
 
 MathMatrix (const Size NUMBER_ROWS, const Size NUMBER_COLS, const T *DATA)
 construct from dimension and pointer to data More...
 
 MathMatrix (const MathMatrix< T > &MATRIX)
 copy constructor from Matrix More...
 
MathMatrix< T > * Clone () const
 Clone function. More...
 
 ~MathMatrix ()
 destructor More...
 
Size get_number_rows () const
 get number of rows More...
 
Size get_number_cols () const
 get number of columns More...
 
Size get_number_elements () const
 number of elements More...
 
Size size () const
 number of elements More...
 
const T * begin () const
 pointer to First Element More...
 
T * begin ()
 pointer to First Element More...
 
const T * end () const
 pointer to end of range More...
 
T * end ()
 pointer to end of range More...
 
MathVector< T > get_row (const Size ROW) const
 
MathVector< T > get_col (const Size COL) const
 
bool is_square () const
 is matrix a square matrix More...
 
bool is_diagonal () const
 is matrix a diagonal matrix More...
 
bool is_tri_diagonal () const
 is matrix a tridiagonal matrix More...
 
bool same_dimensions (const MathMatrix< T > &MATRIX_LHS, const MathMatrix< T > &MATRIX_RHS)
 check dimension agreement of two Matrices More...
 
bool inverse_dimensions (const MathMatrix< T > &MATRIX_LHS, const MathMatrix< T > &MATRIX_RHS)
 check inverse dimension agreement of two Matrices comapre number ros of lhs with number cols of rhs and number cols of lhs with number rows of rhs More...
 
bool multiplication_dimension (const MathMatrix< T > &MATRIX_LHS, const MathMatrix< T > &MATRIX_RHS)
 check dimensions for multiplication A*B compare number cols of lhs with number rows of rhs More...
 
MathMatrix< T > & set_zero ()
 
MathMatrix< T > transpose (const MathMatrix< T > &MATRIX)
 
MathMatrix< T > & inverse ()
 
MathMatrix< T > & transpose ()
 
MathMatrix< T > & inverse_rectangular_matrix ()
 
MathMatrix< T > inverse_square_matrix ()
 invert small square matrices exactly More...
 
MathMatrix< T > & inverse_diagonal_matrix ()
 
MathMatrix< T > & inverse_tridiagonal_matrix ()
 
MathMatrix< T > & set_unit ()
 
Size pivot (const Size ROW)
 
MathMatrix< T > & replace_row (const Size ROW, const MathVector< T > &VECTOR)
 
MathMatrix< T > & replace_col (const Size COL, const MathVector< T > &VECTOR)
 
MathMatrix< T > & swap_rows (const Size ROW_A, const Size ROW_B)
 
MathMatrix< T > & swap_cols (const Size COL_A, const Size COL_B)
 
bool IsValidPosition (const Size ROW, const Size COL) const
 
T & operator() (const Size ROW, const Size COL)
 return reference to changeable element ( ROW, COL) More...
 
const T & operator() (const Size ROW, const Size COL) const
 return reference to const element ( ROW, COL) More...
 
MathMatrix< T > & operator= (const MathMatrix< T > &MATRIX)
 assignment from Matrix More...
 
MathMatrix< T > & operator= (const T &VALUE)
 assignment from value More...
 
T * operator[] (const Size ROW)
 C-style data access with [] gives a pointer on a ROW. More...
 
const T * operator[] (const Size ROW) const
 C-style data access with [] gives a pointer on a ROW. More...
 
MathMatrix< T > & operator*= (const MathMatrix< T > &MATRIX)
 operator *= Matrix More...
 
MathMatrix< T > & operator*= (const MathVector< T > &VECTOR)
 operator *= VectorBase More...
 

Private Attributes

Size NumberRows_
 
Size NumberCols_
 
Size size_
 
T * data_
 

Constructor & Destructor Documentation

template<typename T>
numeric::MathMatrix< T >::MathMatrix ( )
inline

default constructor

template<typename T>
numeric::MathMatrix< T >::MathMatrix ( const Size  NUMBER_ROWS,
const Size  NUMBER_COLS,
const T &  FILL_VALUE = T( 0) 
)
inlineexplicit

construct from dimension and possible filler

Parameters
NUMBER_ROWSnumber of rows in matrix
NUMBER_COLSnumber of cols in matrix
FILL_VALUEassign every element to that value
template<typename T>
numeric::MathMatrix< T >::MathMatrix ( const Size  NUMBER_ROWS,
const Size  NUMBER_COLS,
const T *  DATA 
)
inline

construct from dimension and pointer to data

Parameters
NUMBER_ROWSnumber of rows in matrix
NUMBER_COLSnumber of cols in matrix
DATApointer to field of data
template<typename T>
numeric::MathMatrix< T >::MathMatrix ( const MathMatrix< T > &  MATRIX)
inline

copy constructor from Matrix

Parameters
MATRIXmatrix to be copied from
template<typename T>
numeric::MathMatrix< T >::~MathMatrix ( )
inline

destructor

Member Function Documentation

template<typename T>
const T* numeric::MathMatrix< T >::begin ( ) const
inline

pointer to First Element

Returns
const pointer to first element in range containing all elements of Matrix

Referenced by numeric::operator!=(), numeric::operator*=(), numeric::operator+=(), numeric::operator-=(), numeric::operator/=(), and numeric::operator==().

template<typename T>
T* numeric::MathMatrix< T >::begin ( )
inline

pointer to First Element

Returns
pointer to first element in range containing all elements of Matrix
template<typename T>
MathMatrix< T>* numeric::MathMatrix< T >::Clone ( ) const
inline

Clone function.

Returns
pointer to new MatrixInterface< T>
template<typename T>
const T* numeric::MathMatrix< T >::end ( ) const
inline

pointer to end of range

Returns
const pointer to address one after last element in Matrix

Referenced by numeric::operator!=(), numeric::operator*=(), numeric::operator+=(), numeric::operator-=(), numeric::operator/=(), and numeric::operator==().

template<typename T>
T* numeric::MathMatrix< T >::end ( )
inline

pointer to end of range

Returns
pointer to address one after last element in Matrix
template<typename T>
MathVector< T> numeric::MathMatrix< T >::get_col ( const Size  COL) const
inline
Returns
Col of Matrix

Referenced by numeric::interpolation::spline::BicubicSpline::train().

template<typename T>
Size numeric::MathMatrix< T >::get_number_cols ( ) const
inline
template<typename T>
Size numeric::MathMatrix< T >::get_number_elements ( ) const
inline

number of elements

Returns
total number of elements in matrix

Referenced by numeric::MathMatrix< Real >::is_diagonal().

template<typename T>
Size numeric::MathMatrix< T >::get_number_rows ( ) const
inline
template<typename T>
MathVector< T> numeric::MathMatrix< T >::get_row ( const Size  ROW) const
inline
Returns
Row of Matrix

Referenced by numeric::interpolation::spline::BicubicSpline::train().

template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::inverse ( )
inline
template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::inverse_diagonal_matrix ( )
inline
template<typename T>
bool numeric::MathMatrix< T >::inverse_dimensions ( const MathMatrix< T > &  MATRIX_LHS,
const MathMatrix< T > &  MATRIX_RHS 
)
inline

check inverse dimension agreement of two Matrices comapre number ros of lhs with number cols of rhs and number cols of lhs with number rows of rhs

Parameters
MATRIX_LHSrhs matrix
MATRIX_RHSlhs matrix
Returns
true if number rows with cols and cols with rows agree between both Matrices
template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::inverse_rectangular_matrix ( )
inline
Returns
invert rectangular matrices exactly

Referenced by numeric::MathMatrix< Real >::inverse().

template<typename T>
MathMatrix< T> numeric::MathMatrix< T >::inverse_square_matrix ( )
inline
template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::inverse_tridiagonal_matrix ( )
inline
Returns
this algorithm was found on this page: http://www.csit.fsu.edu/~burkardt/math2071/math2071.html invert tridiagonal matrix for all diagonal elements

Referenced by numeric::MathMatrix< Real >::inverse_square_matrix().

template<typename T>
bool numeric::MathMatrix< T >::is_diagonal ( ) const
inline

is matrix a diagonal matrix

Returns
true if all but the elements in the diagonal are 0

Referenced by numeric::MathMatrix< Real >::inverse_square_matrix().

template<typename T>
bool numeric::MathMatrix< T >::is_square ( ) const
inline

is matrix a square matrix

Returns
true if number of cols and rows are idnetical

Referenced by numeric::MathMatrix< Real >::inverse(), numeric::MathMatrix< Real >::is_diagonal(), and numeric::MathMatrix< Real >::is_tri_diagonal().

template<typename T>
bool numeric::MathMatrix< T >::is_tri_diagonal ( ) const
inline

is matrix a tridiagonal matrix

Returns
if diagonal and adjecent diagonals are filled and the rest is 0

Referenced by numeric::MathMatrix< Real >::inverse_square_matrix().

template<typename T>
bool numeric::MathMatrix< T >::IsValidPosition ( const Size  ROW,
const Size  COL 
) const
inline
template<typename T>
bool numeric::MathMatrix< T >::multiplication_dimension ( const MathMatrix< T > &  MATRIX_LHS,
const MathMatrix< T > &  MATRIX_RHS 
)
inline

check dimensions for multiplication A*B compare number cols of lhs with number rows of rhs

Parameters
MATRIX_LHSrhs matrix
MATRIX_RHSlhs matrix
Returns
true if number cols rhs and number cols lhs agree
template<typename T>
T& numeric::MathMatrix< T >::operator() ( const Size  ROW,
const Size  COL 
)
inline

return reference to changeable element ( ROW, COL)

Parameters
ROWthe row number, starting with 0
COLthe col number, starting with 0
Returns
changable reference to the element defined bey ROW and COL number

Referenced by numeric::MathMatrix< Real >::get_col(), numeric::MathMatrix< Real >::inverse_diagonal_matrix(), numeric::MathMatrix< Real >::inverse_square_matrix(), numeric::MathMatrix< Real >::inverse_tridiagonal_matrix(), numeric::MathMatrix< Real >::operator*=(), numeric::MathMatrix< Real >::replace_col(), and numeric::MathMatrix< Real >::transpose().

template<typename T>
const T& numeric::MathMatrix< T >::operator() ( const Size  ROW,
const Size  COL 
) const
inline

return reference to const element ( ROW, COL)

Parameters
ROWthe row number, starting with 0
COLthe col number, starting with 0
Returns
const element defined bey ROW and COL number
template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::operator*= ( const MathMatrix< T > &  MATRIX)
inline

operator *= Matrix

template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::operator*= ( const MathVector< T > &  VECTOR)
inline

operator *= VectorBase

template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::operator= ( const MathMatrix< T > &  MATRIX)
inline

assignment from Matrix

Parameters
MATRIXthe matrix used as source
Returns
reference to this Matrix
template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::operator= ( const T &  VALUE)
inline

assignment from value

Parameters
VALUEall elements are set to that value
Returns
reference to this assigned Matrix
template<typename T>
T* numeric::MathMatrix< T >::operator[] ( const Size  ROW)
inline

C-style data access with [] gives a pointer on a ROW.

Referenced by numeric::MathMatrix< Real >::get_row(), and numeric::MathMatrix< Real >::operator*=().

template<typename T>
const T* numeric::MathMatrix< T >::operator[] ( const Size  ROW) const
inline

C-style data access with [] gives a pointer on a ROW.

template<typename T>
Size numeric::MathMatrix< T >::pivot ( const Size  ROW)
inline
Returns
private helper function for computing the determinante / inverting a square matrix

Referenced by numeric::MathMatrix< Real >::inverse_square_matrix().

template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::replace_col ( const Size  COL,
const MathVector< T > &  VECTOR 
)
inline
Returns
copies elements of argument VECTOR into this object at position (COL)

Referenced by numeric::interpolation::spline::BicubicSpline::train().

template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::replace_row ( const Size  ROW,
const MathVector< T > &  VECTOR 
)
inline
Returns
copies elements of argument VECTOR into this object at position (ROW)

Referenced by numeric::interpolation::spline::BicubicSpline::train().

template<typename T>
bool numeric::MathMatrix< T >::same_dimensions ( const MathMatrix< T > &  MATRIX_LHS,
const MathMatrix< T > &  MATRIX_RHS 
)
inline

check dimension agreement of two Matrices

Parameters
MATRIX_LHSrhs matrix
MATRIX_RHSlhs matrix
Returns
true if number rows and cols are the same between both Matrices
template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::set_unit ( )
inline
Returns
set all elements in matrix to T( 0) but diagonal elements to T( 1)

Referenced by numeric::MathMatrix< Real >::inverse_square_matrix().

template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::set_zero ( )
inline
template<typename T>
Size numeric::MathMatrix< T >::size ( ) const
inline

number of elements

Returns
total number of elements in matrix

Referenced by numeric::operator-(), and numeric::operator/().

template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::swap_cols ( const Size  COL_A,
const Size  COL_B 
)
inline
Returns
swap columns COL_A and COL_B
template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::swap_rows ( const Size  ROW_A,
const Size  ROW_B 
)
inline
template<typename T>
MathMatrix< T> numeric::MathMatrix< T >::transpose ( const MathMatrix< T > &  MATRIX)
inline
Returns
Transposed of Matrix

Referenced by numeric::MathMatrix< Real >::inverse_rectangular_matrix().

template<typename T>
MathMatrix< T>& numeric::MathMatrix< T >::transpose ( )
inline

Member Data Documentation

template<typename T>
T* numeric::MathMatrix< T >::data_
private
template<typename T>
Size numeric::MathMatrix< T >::NumberCols_
private
template<typename T>
Size numeric::MathMatrix< T >::NumberRows_
private
template<typename T>
Size numeric::MathMatrix< T >::size_
private

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