biu::Matrix< T > Class Template Reference
#include <Matrix.hh>
Inheritance diagram for biu::Matrix< T >:

Detailed Description
template<class T>
class biu::Matrix< T >
A generic matrix that allows matrix operations.
Definition at line 15 of file Matrix.hh.
Public Member Functions | |
| T & | at (const size_t r, const size_t c) |
| T | at (const size_t r, const size_t c) const |
| std::vector< T > | columnVec (const size_t col) const |
| Matrix (const Matrix< T > &mat) | |
| Matrix (const size_t r, const size_t c, const T mat[]) | |
| Matrix (const size_t r, const size_t c, const T &val) | |
| Matrix (const size_t r, const size_t c) | |
| Matrix () | |
| size_t | numColumns () const |
| size_t | numRows () const |
| std::vector< T > | operator * (const std::vector< T > &vec) const |
| Matrix< T > | operator * (const T &c) const |
| Matrix< T > | operator * (const Matrix< T > &mat) const |
| Matrix< T > & | operator *= (const T &c) |
| Matrix< T > & | operator *= (const Matrix< T > &mat) |
| bool | operator!= (const T &val) const |
| bool | operator!= (const Matrix< T > &mat) const |
| Matrix< T > | operator+ (const T &c) |
| Matrix< T > | operator+ (const Matrix< T > &mat) |
| Matrix< T > | operator- (const T &c) |
| Matrix< T > | operator- (const Matrix< T > &mat) |
| Matrix & | operator= (const T &val) |
| Matrix & | operator= (const Matrix< T > &mat) |
| bool | operator== (const T &val) const |
| bool | operator== (const Matrix< T > &mat) const |
| const T *const | operator[] (const size_t row) const |
| T *const | operator[] (const size_t row) |
| void | resize (const size_t row, const size_t col, const T &defVal) |
| void | resize (const size_t row, const size_t col) |
| ~Matrix () | |
Protected Attributes | |
| size_t | cols |
| size_t | rows |
| T ** | v |
Constructor & Destructor Documentation
| biu::Matrix< T >::Matrix | ( | ) |
creates an empty matrix of dimensions (0,0)
| biu::Matrix< T >::Matrix | ( | const size_t | r, | |
| const size_t | c | |||
| ) |
creates an unitialised matrix of given dimensions
- Parameters:
-
r the row number of the matrix c the column number of the matrix
| biu::Matrix< T >::Matrix | ( | const size_t | r, | |
| const size_t | c, | |||
| const T & | val | |||
| ) |
creates a matrix and fills all elements
- Parameters:
-
r the row number of the matrix c the column number of the matrix val the default value for the matrix entries
| biu::Matrix< T >::Matrix | ( | const size_t | r, | |
| const size_t | c, | |||
| const T | mat[] | |||
| ) |
creates a matrix that contains a copy of the given matrix
- Parameters:
-
r the row number of the matrix c the column number of the matrix mat an array containing the matrix in the form element(row,col) = mat[row*c+col] with row = (0,r] && col = (0,c]
| biu::Matrix< T >::Matrix | ( | const Matrix< T > & | mat | ) |
copy constructor including matrix resizing
- Parameters:
-
mat the matrix this matrix should be a copy of
| biu::Matrix< T >::~Matrix | ( | ) |
destruction and freeing memory
Member Function Documentation
| T& biu::Matrix< T >::at | ( | const size_t | r, | |
| const size_t | c | |||
| ) | [inline] |
direct access to element (r,c)
- Parameters:
-
r the row to access c the column to access
- Returns:
- the matrix element at position (r,c)
| T biu::Matrix< T >::at | ( | const size_t | r, | |
| const size_t | c | |||
| ) | const [inline] |
constant access to element (r,c)
- Parameters:
-
r the row to access c the column to access
- Returns:
- the matrix element at position (r,c)
| std::vector<T> biu::Matrix< T >::columnVec | ( | const size_t | col | ) | const |
access to a matrix column
- Parameters:
-
col the column to access
- Returns:
- the column vector
| size_t biu::Matrix< T >::numColumns | ( | ) | const [inline] |
number of columns
- Returns:
- column number
| size_t biu::Matrix< T >::numRows | ( | ) | const [inline] |
number of rows
- Returns:
- row number
| std::vector<T> biu::Matrix< T >::operator * | ( | const std::vector< T > & | vec | ) | const |
special case of * column number has to equal vec size
- Parameters:
-
vec the column vector to multiply with
- Returns:
- a new column vector representing (this * vec)
| Matrix<T> biu::Matrix< T >::operator * | ( | const T & | c | ) | const |
matrix * constant
- Parameters:
-
c the constant to multiply all elements with
- Returns:
- a new matrix representing (this * c)
| Matrix<T> biu::Matrix< T >::operator * | ( | const Matrix< T > & | mat | ) | const |
matrix * matrix row number have to equal column number and vice versa
- Parameters:
-
mat the matrix to multiply with
- Returns:
- a new matrix representing (this * mat)
| Matrix<T>& biu::Matrix< T >::operator *= | ( | const T & | c | ) |
matrix *= constant
- Parameters:
-
c the constant to multiply all elements with
- Returns:
- *this
| Matrix<T>& biu::Matrix< T >::operator *= | ( | const Matrix< T > & | mat | ) |
matrix *= matrix row number have to equal column number and vice versa
- Parameters:
-
mat the matrix to multiply with
- Returns:
- *this
| bool biu::Matrix< T >::operator!= | ( | const T & | val | ) | const [inline] |
test if at least one element doesnt equal val
- Parameters:
-
val the value to compare with
- Returns:
- true if at least one element are is not equal, false otherwise
| bool biu::Matrix< T >::operator!= | ( | const Matrix< T > & | mat | ) | const [inline] |
test for inequality
- Parameters:
-
mat the matrix to compare with
- Returns:
- true if dimensions or at least one element are is not equal, false otherwise
| Matrix<T> biu::Matrix< T >::operator+ | ( | const T & | c | ) |
matrix + constant
- Parameters:
-
c the constant to add to all elements
- Returns:
- a new matrix representing (this + c)
| Matrix<T> biu::Matrix< T >::operator+ | ( | const Matrix< T > & | mat | ) |
matrix + matrix row and column number have to be equal
- Parameters:
-
mat the matrix to add
- Returns:
- a new matrix representing (this + mat)
| Matrix<T> biu::Matrix< T >::operator- | ( | const T & | c | ) |
matrix - constant
- Parameters:
-
c the constant to substract from all elements
- Returns:
- a new matrix representing (this - c)
| Matrix<T> biu::Matrix< T >::operator- | ( | const Matrix< T > & | mat | ) |
matrix - matrix row and column number have to be equal
- Parameters:
-
mat the matrix to substract
- Returns:
- a new matrix representing (this - mat)
| Matrix& biu::Matrix< T >::operator= | ( | const T & | val | ) |
all elements = val
- Parameters:
-
val the new value for all matrix entries
- Returns:
- *this
| Matrix& biu::Matrix< T >::operator= | ( | const Matrix< T > & | mat | ) |
assignment including resizing
- Parameters:
-
mat the matrix this matrix should be a copy of
- Returns:
- *this
| bool biu::Matrix< T >::operator== | ( | const T & | val | ) | const [inline] |
test if all elements == val
- Parameters:
-
val the value to compare with
- Returns:
- true if all elements are equal, false otherwise
| bool biu::Matrix< T >::operator== | ( | const Matrix< T > & | mat | ) | const [inline] |
test for equality
- Parameters:
-
mat the matrix to compare with
- Returns:
- true if dimensions and all elements are equal, false otherwise
| const T* const biu::Matrix< T >::operator[] | ( | const size_t | row | ) | const [inline] |
constant access to row i
- Parameters:
-
row the row to access
- Returns:
- constant array access to the row
| T* const biu::Matrix< T >::operator[] | ( | const size_t | row | ) | [inline] |
access to row
- Parameters:
-
row the row to access
- Returns:
- array access to the row
| void biu::Matrix< T >::resize | ( | const size_t | row, | |
| const size_t | col, | |||
| const T & | defVal | |||
| ) |
Resizes the matrix. If the the dimensions are increased, the new fields are filled with the given default value
- Parameters:
-
row the new row number col the new column number defVal the default value for new matrix elements
| void biu::Matrix< T >::resize | ( | const size_t | row, | |
| const size_t | col | |||
| ) |
Resizes the matrix. If the the dimensions are increased, the new fields are not initialised.
- Parameters:
-
row the new row number col the new column number
Field Documentation
size_t biu::Matrix< T >::cols [protected] |
size_t biu::Matrix< T >::rows [protected] |
T** biu::Matrix< T >::v [protected] |
The documentation for this class was generated from the following file:
- src/biu/Matrix.hh
