Generated on Tue Dec 16 12:50:07 2008 for BIU-2.2.0 by doxygen 1.5.1

biu::Matrix< T > Class Template Reference

#include <Matrix.hh>

Inheritance diagram for biu::Matrix< T >:

Inheritance graph
[legend]

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)
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)
Matrixoperator= (const T &val)
Matrixoperator= (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

template<class T>
biu::Matrix< T >::Matrix (  ) 

creates an empty matrix of dimensions (0,0)

template<class T>
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

template<class T>
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

template<class T>
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]

template<class T>
biu::Matrix< T >::Matrix ( const Matrix< T > &  mat  ) 

copy constructor including matrix resizing

Parameters:
mat the matrix this matrix should be a copy of

template<class T>
biu::Matrix< T >::~Matrix (  ) 

destruction and freeing memory


Member Function Documentation

template<class T>
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)

template<class T>
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)

template<class T>
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

template<class T>
size_t biu::Matrix< T >::numColumns (  )  const [inline]

number of columns

Returns:
column number

template<class T>
size_t biu::Matrix< T >::numRows (  )  const [inline]

number of rows

Returns:
row number

template<class T>
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)

template<class T>
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)

template<class T>
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)

template<class T>
Matrix<T>& biu::Matrix< T >::operator *= ( const T &  c  ) 

matrix *= constant

Parameters:
c the constant to multiply all elements with
Returns:
*this

template<class T>
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

template<class T>
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

template<class T>
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

template<class T>
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)

template<class T>
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)

template<class T>
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)

template<class T>
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)

template<class T>
Matrix& biu::Matrix< T >::operator= ( const T &  val  ) 

all elements = val

Parameters:
val the new value for all matrix entries
Returns:
*this

template<class T>
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

template<class T>
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

template<class T>
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

template<class T>
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

template<class T>
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

template<class T>
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

template<class T>
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

template<class T>
size_t biu::Matrix< T >::cols [protected]

matrix dimensions = number of columns

Definition at line 20 of file Matrix.hh.

template<class T>
size_t biu::Matrix< T >::rows [protected]

matrix dimensions = number of rows

Definition at line 18 of file Matrix.hh.

template<class T>
T** biu::Matrix< T >::v [protected]

the data store

Definition at line 22 of file Matrix.hh.


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