mbo::Matrix< _Ty, _Cols, _Rows > Class Template Reference

Matrix class. More...

#include <MboMatrix.h>

Inheritance diagram for mbo::Matrix< _Ty, _Cols, _Rows >:

Inheritance graph
{mbo::Matrix\< _Ty, _Cols, 1 \>\n|- Val\l|+ Matrix()\l+ numRows()\l+ numCols()\l+ operator()()\l+ operator+()\l+ operator-()\l+ operator=()\l+ operator+=()\l+ operator-=()\l+ operator *=()\l+ operator *=()\l+ operator/=()\l+ operator^=()\l+ Null()\l+ Null()\l+ Unit()\l+ Unit()\l+ Solve()\l+ Adj()\l+ Det()\l+ Norm()\l+ Cofactor()\l+ Cond()\l+ IsSquare()\l+ IsSingular()\l+ IsDiagonal()\l+ IsScalar()\l+ IsUnit()\l+ IsNull()\l+ IsSymmetric()\l+ IsSkewSymmetric()\l+ IsUpperTiangular()\l+ IsLowerTiangular()\l- pivot()\l}{mbo::Vector\< _Ty, _Cols \>\n||}
[legend]
Collaboration diagram for mbo::Matrix< _Ty, _Cols, _Rows >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Matrix (const Matrix< _Ty, _Cols, _Rows > &m)
size_t numRows ()
size_t numCols ()
_Ty & operator() (size_t row, size_t col) throw (MatrixException)
Matrix< _Ty, _Cols, _Rows > operator+ ()
Matrix< _Ty, _Cols, _Rows > operator- ()
Matrix< _Ty, _Cols, _Rows > & operator= (const Matrix< _Ty, _Cols, _Rows > &m)
Matrix< _Ty, _Cols, _Rows > & operator+= (const Matrix< _Ty, _Cols, _Rows > &m) throw (MatrixException)
Matrix< _Ty, _Cols, _Rows > & operator-= (const Matrix< _Ty, _Cols, _Rows > &m) throw (MatrixException)
Matrix< _Ty, _Cols, _Rows > & operator *= (const Matrix< _Ty, _Cols, _Rows > &m) throw (MatrixException)
Matrix< _Ty, _Cols, _Rows > & operator *= (const _Ty &c)
Matrix< _Ty, _Cols, _Rows > & operator/= (const _Ty &c)
Matrix< _Ty, _Cols, _Rows > & operator^= (const size_t &pow) throw (MatrixException)
void Null (const size_t &row, const size_t &col)
void Null ()
void Unit (const size_t &row)
void Unit ()
Matrix< _Ty, _Cols, _Rows > Solve (const Matrix< _Ty, _Cols, _Rows > &v) const throw (MatrixException)
Matrix< _Ty, _Cols, _Rows > Adj () throw (MatrixException)
_Ty Det () throw (MatrixException)
_Ty Norm ()
_Ty Cofactor (size_t row, size_t col) throw (MatrixException)
_Ty Cond ()
bool IsSquare ()
bool IsSingular ()
bool IsDiagonal ()
bool IsScalar ()
bool IsUnit ()
bool IsNull ()
bool IsSymmetric ()
bool IsSkewSymmetric ()
bool IsUpperTiangular ()
bool IsLowerTiangular ()
template<class _Ty, size_t _Cols, size_t _Rows>
Matrix< _Ty, _Cols, _Rows > operator- ()

Friends

Matrix< _Ty, _Cols2, _Rows1 > _Cols
bool operator== (const Matrix< _Ty, _Cols, _Rows > &m1, const Matrix< _Ty, _Cols, _Rows > &m2)
bool operator!= (const Matrix< _Ty, _Cols, _Rows > &m1, const Matrix< _Ty, _Cols, _Rows > &m2)
template<class _Ty, _Cols , _Rows >
Matrix< _Ty, _Cols, _Rows > operator+ (const Matrix< _Ty, _Cols, _Rows > &m1, const Matrix< _Ty, _Cols, _Rows > &m2) throw (MatrixException)
template<class _Ty, _Cols , _Rows >
Matrix< _Ty, _Cols, _Rows > operator- (const Matrix< _Ty, _Cols, _Rows > &m1, const Matrix< _Ty, _Cols, _Rows > &m2) throw (MatrixException)
template<class _Ty, size_t _Cols1Rows2, size_t _Rows1, size_t _Cols2>
Matrix< _Ty, _Cols2, _Rows1 > operator * (const Matrix< _Ty, _Cols1Rows2, _Rows1 > &lhs, const Matrix< _Ty, _Cols2, _Cols1Rows2 > &rhs) friend template< class _Ty
Matrix< _Ty, _Cols2, _Rows1 >
_Rows Matrix< _Ty, _Cols,
_Rows > 
operator * (const Matrix< _Ty, _Cols, _Rows > &m1, const Matrix< _Ty, _Cols, _Rows > &m2) throw (MatrixException)
template<class _Ty, _Cols , _Rows >
Matrix< _Ty, _Cols, _Rows > operator * (const Matrix< _Ty, _Cols, _Rows > &m, const T &no)
template<class _Ty, _Cols , _Rows >
Matrix< _Ty, _Cols, _Rows > operator * (const T &no, const Matrix< _Ty, _Cols, _Rows > &m)
template<class _Ty, _Cols , _Rows >
Matrix< _Ty, _Cols, _Rows > operator/ (const Matrix< _Ty, _Cols, _Rows > &m1, const Matrix< _Ty, _Cols, _Rows > &m2) throw (MatrixException)
template<class _Ty, _Cols , _Rows >
Matrix< _Ty, _Cols, _Rows > operator/ (const Matrix< _Ty, _Cols, _Rows > &m, const T &no)
template<class _Ty, _Cols , _Rows >
Matrix< _Ty, _Cols, _Rows > operator/ (const T &no, const Matrix< _Ty, _Cols, _Rows > &m) throw (MatrixException)
template<class _Ty, _Cols , _Rows >
Matrix< _Ty, _Cols, _Rows > operator~ (const Matrix< _Ty, _Cols, _Rows > &m)
template<class _Ty, _Cols , _Rows >
Matrix< _Ty, _Cols, _Rows > operator! (Matrix< _Ty, _Cols, _Rows > m) throw (MatrixException)
template<class _Ty, _Cols , _Rows >
Matrix< _Ty, _Cols, _Rows > operator^ (const Matrix< _Ty, _Cols, _Rows > &m, const size_t &pow) throw (MatrixException)
istream & operator>> (istream &i, Matrix< _Ty, _Cols, _Rows > &m)
ostream & operator<< (ostream &o, Matrix< _Ty, _Cols, _Rows > &m)


Detailed Description

template<class _Ty, size_t _Cols, size_t _Rows>
class mbo::Matrix< _Ty, _Cols, _Rows >

Matrix class.

Definition at line 68 of file MboMatrix.h.


Constructor & Destructor Documentation

template<class _Ty, size_t _Cols, size_t _Rows>
mbo::Matrix< _Ty, _Cols, _Rows >::Matrix ( const Matrix< _Ty, _Cols, _Rows > &  m  )  [inline]

Definition at line 163 of file MboMatrix.h.

00164     : Val(m.Val)
00165 {
00166 }


Member Function Documentation

template<class _Ty, size_t _Cols, size_t _Rows>
size_t mbo::Matrix< _Ty, _Cols, _Rows >::numRows (  )  [inline]

Definition at line 74 of file MboMatrix.h.

00074 { return numRows; }

template<class _Ty, size_t _Cols, size_t _Rows>
size_t mbo::Matrix< _Ty, _Cols, _Rows >::numCols (  )  [inline]

Definition at line 75 of file MboMatrix.h.

00075 { return numCols; }

template<class _Ty, size_t _Cols, size_t _Rows>
_Ty & mbo::Matrix< _Ty, _Cols, _Rows >::operator() ( size_t  row,
size_t  col 
) throw (MatrixException) [inline]

Definition at line 170 of file MboMatrix.h.

References mbo::Matrix< _Ty, _Cols, _Rows >::_Cols.

00171 {
00172     if (nRow >= _Rows || nCol >= _Cols)
00173     {
00174         throw MatrixException("Matrix<_Ty, _Cols, _Rows>::operator(): Index out of range!");
00175     }
00176     return Val[row][col];
00177 }

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows> mbo::Matrix< _Ty, _Cols, _Rows >::operator+ (  )  [inline]

Definition at line 81 of file MboMatrix.h.

00081 { return *this; }

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows> mbo::Matrix< _Ty, _Cols, _Rows >::operator- (  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix< _Ty, _Cols, _Rows > & mbo::Matrix< _Ty, _Cols, _Rows >::operator= ( const Matrix< _Ty, _Cols, _Rows > &  m  )  [inline]

Definition at line 210 of file MboMatrix.h.

References mbo::Matrix< _Ty, _Cols, _Rows >::Val.

00211 {
00212     *Val = *m.Val;
00213     return *this;
00214 }

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows>& mbo::Matrix< _Ty, _Cols, _Rows >::operator+= ( const Matrix< _Ty, _Cols, _Rows > &  m  )  throw (MatrixException)

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows>& mbo::Matrix< _Ty, _Cols, _Rows >::operator-= ( const Matrix< _Ty, _Cols, _Rows > &  m  )  throw (MatrixException)

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows>& mbo::Matrix< _Ty, _Cols, _Rows >::operator *= ( const Matrix< _Ty, _Cols, _Rows > &  m  )  throw (MatrixException)

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows>& mbo::Matrix< _Ty, _Cols, _Rows >::operator *= ( const _Ty &  c  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows>& mbo::Matrix< _Ty, _Cols, _Rows >::operator/= ( const _Ty &  c  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows>& mbo::Matrix< _Ty, _Cols, _Rows >::operator^= ( const size_t &  pow  )  throw (MatrixException)

template<class _Ty, size_t _Cols, size_t _Rows>
void mbo::Matrix< _Ty, _Cols, _Rows >::Null ( const size_t &  row,
const size_t &  col 
)

template<class _Ty, size_t _Cols, size_t _Rows>
void mbo::Matrix< _Ty, _Cols, _Rows >::Null (  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
void mbo::Matrix< _Ty, _Cols, _Rows >::Unit ( const size_t &  row  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
void mbo::Matrix< _Ty, _Cols, _Rows >::Unit (  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows> mbo::Matrix< _Ty, _Cols, _Rows >::Solve ( const Matrix< _Ty, _Cols, _Rows > &  v  )  const throw (MatrixException)

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows> mbo::Matrix< _Ty, _Cols, _Rows >::Adj (  )  throw (MatrixException)

template<class _Ty, size_t _Cols, size_t _Rows>
_Ty mbo::Matrix< _Ty, _Cols, _Rows >::Det (  )  throw (MatrixException)

template<class _Ty, size_t _Cols, size_t _Rows>
_Ty mbo::Matrix< _Ty, _Cols, _Rows >::Norm (  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
_Ty mbo::Matrix< _Ty, _Cols, _Rows >::Cofactor ( size_t  row,
size_t  col 
) throw (MatrixException)

template<class _Ty, size_t _Cols, size_t _Rows>
_Ty mbo::Matrix< _Ty, _Cols, _Rows >::Cond (  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
bool mbo::Matrix< _Ty, _Cols, _Rows >::IsSquare (  )  [inline]

Definition at line 129 of file MboMatrix.h.

00129 { return (Row == Col); }

template<class _Ty, size_t _Cols, size_t _Rows>
bool mbo::Matrix< _Ty, _Cols, _Rows >::IsSingular (  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
bool mbo::Matrix< _Ty, _Cols, _Rows >::IsDiagonal (  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
bool mbo::Matrix< _Ty, _Cols, _Rows >::IsScalar (  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
bool mbo::Matrix< _Ty, _Cols, _Rows >::IsUnit (  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
bool mbo::Matrix< _Ty, _Cols, _Rows >::IsNull (  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
bool mbo::Matrix< _Ty, _Cols, _Rows >::IsSymmetric (  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
bool mbo::Matrix< _Ty, _Cols, _Rows >::IsSkewSymmetric (  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
bool mbo::Matrix< _Ty, _Cols, _Rows >::IsUpperTiangular (  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
bool mbo::Matrix< _Ty, _Cols, _Rows >::IsLowerTiangular (  ) 

template<class _Ty, size_t _Cols, size_t _Rows>
template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows> mbo::Matrix< _Ty, _Cols, _Rows >::operator- (  )  [inline]

Definition at line 329 of file MboMatrix.h.

References mbo::Matrix< _Ty, _Cols, _Rows >::_Cols, and mbo::Matrix< _Ty, _Cols, _Rows >::Val.

00330 {
00331     Matrix<_Ty, _Cols, _Rows> ret();
00332 
00333     for (size_t i=0; i < _Rows; i++)
00334     {
00335         for (size_t j=0; j < _Cols; j++)
00336         {
00337             ret.Val[i][j] = - Val[i][j];
00338         }
00339     }
00340     return ret;
00341 }


Friends And Related Function Documentation

template<class _Ty, size_t _Cols, size_t _Rows>
friend Matrix<_Ty, _Cols2, _Rows1> _Cols [friend]

Definition at line 104 of file MboMatrix.h.

Referenced by mbo::Matrix< _Ty, _Cols, _Rows >::operator()(), operator+(), operator-(), mbo::Matrix< _Ty, _Cols, _Rows >::operator-(), mbo::operator==(), and operator~().

template<class _Ty, size_t _Cols, size_t _Rows>
bool operator== ( const Matrix< _Ty, _Cols, _Rows > &  m1,
const Matrix< _Ty, _Cols, _Rows > &  m2 
) [friend]

Definition at line 218 of file MboMatrix.h.

00219 {
00220     for (size_t i=0; i < _Rows; i++)
00221     {
00222         for (size_t j=0; j < _Cols; i++)
00223         {
00224             if (lhs1.Val[i][j] != rhs2.Val[i][j])
00225                 return false;
00226             }
00227         }
00228     }

template<class _Ty, size_t _Cols, size_t _Rows>
bool operator!= ( const Matrix< _Ty, _Cols, _Rows > &  m1,
const Matrix< _Ty, _Cols, _Rows > &  m2 
) [friend]

template<class _Ty, size_t _Cols, size_t _Rows>
template<class _Ty, _Cols , _Rows >
Matrix<_Ty, _Cols, _Rows> operator+ ( const Matrix< _Ty, _Cols, _Rows > &  m1,
const Matrix< _Ty, _Cols, _Rows > &  m2 
) throw (MatrixException) [friend]

template<class _Ty, size_t _Cols, size_t _Rows>
template<class _Ty, _Cols , _Rows >
Matrix<_Ty, _Cols, _Rows> operator- ( const Matrix< _Ty, _Cols, _Rows > &  m1,
const Matrix< _Ty, _Cols, _Rows > &  m2 
) throw (MatrixException) [friend]

template<class _Ty, size_t _Cols, size_t _Rows>
template<class _Ty, size_t _Cols1Rows2, size_t _Rows1, size_t _Cols2>
Matrix<_Ty, _Cols2, _Rows1> operator * ( const Matrix< _Ty, _Cols1Rows2, _Rows1 > &  lhs,
const Matrix< _Ty, _Cols2, _Cols1Rows2 > &  rhs 
) [friend]

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols2, _Rows1> _Rows Matrix<_Ty, _Cols, _Rows> operator * ( const Matrix< _Ty, _Cols, _Rows > &  m1,
const Matrix< _Ty, _Cols, _Rows > &  m2 
) throw (MatrixException) [friend]

Type constraints

template<class _Ty, size_t _Cols, size_t _Rows>
template<class _Ty, _Cols , _Rows >
Matrix<_Ty, _Cols, _Rows> operator * ( const Matrix< _Ty, _Cols, _Rows > &  m,
const T &  no 
) [friend]

template<class _Ty, size_t _Cols, size_t _Rows>
template<class _Ty, _Cols , _Rows >
Matrix<_Ty, _Cols, _Rows> operator * ( const T &  no,
const Matrix< _Ty, _Cols, _Rows > &  m 
) [friend]

Definition at line 106 of file MboMatrix.h.

00106 { return (m*no); }

template<class _Ty, size_t _Cols, size_t _Rows>
template<class _Ty, _Cols , _Rows >
Matrix<_Ty, _Cols, _Rows> operator/ ( const Matrix< _Ty, _Cols, _Rows > &  m1,
const Matrix< _Ty, _Cols, _Rows > &  m2 
) throw (MatrixException) [friend]

Definition at line 107 of file MboMatrix.h.

00107 { return (m1 * !m2); }

template<class _Ty, size_t _Cols, size_t _Rows>
template<class _Ty, _Cols , _Rows >
Matrix<_Ty, _Cols, _Rows> operator/ ( const Matrix< _Ty, _Cols, _Rows > &  m,
const T &  no 
) [friend]

Definition at line 108 of file MboMatrix.h.

00108 { return (m*(1/no)); }

template<class _Ty, size_t _Cols, size_t _Rows>
template<class _Ty, _Cols , _Rows >
Matrix<_Ty, _Cols, _Rows> operator/ ( const T &  no,
const Matrix< _Ty, _Cols, _Rows > &  m 
) throw (MatrixException) [friend]

Definition at line 109 of file MboMatrix.h.

00109 { return (!m * no); }

template<class _Ty, size_t _Cols, size_t _Rows>
template<class _Ty, _Cols , _Rows >
Matrix<_Ty, _Cols, _Rows> operator~ ( const Matrix< _Ty, _Cols, _Rows > &  m  )  [friend]

template<class _Ty, size_t _Cols, size_t _Rows>
template<class _Ty, _Cols , _Rows >
Matrix<_Ty, _Cols, _Rows> operator! ( Matrix< _Ty, _Cols, _Rows >  m  )  throw (MatrixException) [friend]

template<class _Ty, size_t _Cols, size_t _Rows>
template<class _Ty, _Cols , _Rows >
Matrix<_Ty, _Cols, _Rows> operator^ ( const Matrix< _Ty, _Cols, _Rows > &  m,
const size_t &  pow 
) throw (MatrixException) [friend]

template<class _Ty, size_t _Cols, size_t _Rows>
istream& operator>> ( istream &  i,
Matrix< _Ty, _Cols, _Rows > &  m 
) [friend]

Definition at line 181 of file MboMatrix.h.

00182 {
00183     for (size_t i=0; i < m.Row; i++)
00184     {
00185         for (size_t j=0; j < m.Col; j++)
00186         {
00187             in >> m.Val[i][j];
00188         }
00189     }
00190     return in;
00191 }

template<class _Ty, size_t _Cols, size_t _Rows>
ostream& operator<< ( ostream &  o,
Matrix< _Ty, _Cols, _Rows > &  m 
) [friend]

Definition at line 195 of file MboMatrix.h.

00196 {
00197     for (size_t i=0; i < m.Row; i++)
00198     {
00199         for (size_t j=0; j < m.Col; j++)
00200         {
00201             out << m.Val[i][j] << '\t';
00202         }
00203         out << endl;
00204     }
00205     return out;
00206 }


The documentation for this class was generated from the following file:
  Hosted on code.google.com  
© Marcus Börger
Generated on Fri Jan 18 21:21:12 2008 for MBO-lib by doxygen 1.5.4