MboMatrix.h File Reference

template class Matrix More...

#include <exception>

Include dependency graph for MboMatrix.h:

Go to the source code of this file.

Namespaces

namespace  mbo

Classes

class  mbo::MatrixException
 Matrix exception class. More...
class  mbo::Matrix< _Ty, _Cols, _Rows >
 Matrix class. More...
class  mbo::Vector< _Ty, _Cols >

Defines

#define max(a, b)   (((a) > (b)) ? (a) : (b))
#define min(a, b)   (((a) < (b)) ? (a) : (b))

Functions

template<class _Ty, size_t _Cols, size_t _Rows>
istream & mbo::operator>> (istream &in, Matrix< _Ty, _Cols, _Rows > &m)
template<class _Ty, size_t _Cols, size_t _Rows>
ostream & mbo::operator<< (ostream &out, Matrix< _Ty, _Cols, _Rows > &m)
template<class _Ty, size_t _Cols, size_t _Rows>
bool mbo::operator== (const Matrix< _Ty, _Cols, _Rows > &lhs, const Matrix< _Ty, _Cols, _Rows > &rhs)
template<class _Ty, size_t _Cols, size_t _Rows>
bool operator!= (const Matrix< _Ty, _Cols, _Rows > &lhs, const Matrix< _Ty, _Cols, _Rows > &rhs)
template<class _Ty, size_t _Cols, size_t _Rows>
Matrix< _Ty, _Cols, _Rows > operator+ (const Matrix< _Ty, _Cols, _Rows > &lhs, const Matrix< _Ty, _Cols, _Rows > &rhs)
template<class _Ty, size_t _Cols, size_t _Rows>
Matrix< _Ty, _Cols, _Rows > operator- (const Matrix< _Ty, _Cols, _Rows > &lhs, const Matrix< _Ty, _Cols, _Rows > &rhs)
template<class _Ty, size_t _Cols, size_t _Rows>
Matrix< _Ty, _Cols, _Rows > operator * (const Matrix< _Ty, _Cols, _Rows > &lhs, const _Ty &c)
template<class _Ty, size_t _Cols1Rows2, size_t _Rows1, size_t _Cols2>
Matrix< _Ty, _Cols, _Rows > operator * (const Matrix< _Ty, _Cols1Rows2, _Rows1 > &lhs, const Matrix< _Ty, _Cols2, _Cols1Rows2 > &rhs)
template<class _Ty, size_t _Cols, size_t _Rows>
Matrix< _Ty, _Cols, _Rows > operator^ (const Matrix< _Ty, _Cols, _Rows > &lhs, const size_t &rhs)
template<class _Ty, size_t _Cols, size_t _Rows>
Matrix< _Ty, _Cols, _Rows > operator~ (const Matrix< _Ty, _Cols, _Rows > &rhs)
template<class _Ty, size_t _Cols, size_t _Rows>
Matrix< _Ty, _Cols, _Rows > operator! (Matrix< _Ty, _Cols, _Rows > rhs)

Variables

return mbo::true


Detailed Description

template class Matrix

Author:
Marcus Boerger
Version:
0.1
Date:
15.08.2006.
Note:
This file is distributed under the LGPL license GNU Lesser General Public License, version 2.1.

Definition in file MboMatrix.h.


Define Documentation

#define max ( a,
 )     (((a) > (b)) ? (a) : (b))

Definition at line 43 of file MboMatrix.h.

Referenced by mbo::StrFromColor().

#define min ( a,
 )     (((a) < (b)) ? (a) : (b))

Definition at line 44 of file MboMatrix.h.

Referenced by mbo::reallocator< __ValueType >::reallocate(), mbo::TDependentValues< _Ty, _Count, _Min, _Max, _Step >::SetValue(), and mbo::StrFromColor().


Function Documentation

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

Definition at line 395 of file MboMatrix.h.

00396 {
00397     Matrix<_Ty, _Cols2, _Rows1> ret();
00398 
00399     for (size_t i=0; i < _Rows1; i++)
00400     {
00401         for (size_t j=0; j < _Cols2; j++)
00402         {
00403             ret.Val[i][j] = _Ty(0);
00404             for (size_t k=0; k < _Cols1Rows2; k++)
00405             {
00406                 ret.Val[i][j] += lhs.Val[i][k] * rhs[k][j];
00407             }
00408         }
00409     }
00410     return ret;
00411 }

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows> operator * ( const Matrix< _Ty, _Cols, _Rows > &  lhs,
const _Ty &  c 
) [inline]

Definition at line 378 of file MboMatrix.h.

Referenced by mbo::TStaticArray< __ValueType, __MaxSize, __Allocator >::iterator::operator->(), and mbo::TDynamicArray< __ValueType, __Allocator, __MinSize, __Append >::iterator::operator->().

00379 {
00380     Matrix<_Ty, _Cols, _Rows> ret();
00381 
00382     for (size_t i=0; i < m.Row; i++)
00383     {
00384         for (size_t j=0; j < m.Col; j++)
00385         {
00386             ret.Val[i][j] = lhs.Val[i][j] * c;
00387         }
00388     }
00389     return ret;
00390 }

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows> operator! ( Matrix< _Ty, _Cols, _Rows >  rhs  )  [inline]

Definition at line 449 of file MboMatrix.h.

00450 {xxx
00451     size_t i,j,k;
00452     T a1,a2,*rowptr;
00453 
00454     Matrix<_Ty, _Cols, _Rows> temp(m.Row,m.Col);
00455 
00456     temp.Unit();
00457     for (k=0; k < m.Row; k++)
00458     {
00459         int indx = m.pivot(k);
00460         if (indx == -1)
00461         throw MatrixException("Matrix<_Ty, _Cols, _Rows>::operator!: Inversion of a singular Matrix");
00462 
00463         if (indx != 0)
00464         {
00465             rowptr = temp.Val[k];
00466             temp.Val[k] = temp.Val[indx];
00467             temp.Val[indx] = rowptr;
00468         }
00469         a1 = m.Val[k][k];
00470         for (j=0; j < m.Row; j++)
00471         {
00472             m.Val[k][j] /= a1;
00473             temp.Val[k][j] /= a1;
00474         }
00475         for (i=0; i < m.Row; i++)
00476         if (i != k)
00477         {
00478             a2 = m.Val[i][k];
00479             for (j=0; j < m.Row; j++)
00480             {
00481                 m.Val[i][j] -= a2 * m.Val[k][j];
00482                 temp.Val[i][j] -= a2 * temp.Val[k][j];
00483             }
00484         }
00485     }
00486     return temp;
00487 }

template<class _Ty, size_t _Cols, size_t _Rows>
bool operator!= ( const Matrix< _Ty, _Cols, _Rows > &  lhs,
const Matrix< _Ty, _Cols, _Rows > &  rhs 
) [inline]

Definition at line 234 of file MboMatrix.h.

00235 {
00236     return !(lhs == rhs);
00237 }

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows> operator+ ( const Matrix< _Ty, _Cols, _Rows > &  lhs,
const Matrix< _Ty, _Cols, _Rows > &  rhs 
) [inline]

Definition at line 345 of file MboMatrix.h.

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

00346 {
00347     Matrix<_Ty, _Cols, _Rows>  ret();
00348 
00349     for (size_t i=0; i < _Rows; i++)
00350     {
00351         for (size_t j=0; j < _Cols; j++)
00352         {
00353             ret.Val[i][j] = lhs.Val[i][j] + rhs.Val[i][j];
00354         }
00355     }
00356     return ret;
00357 }

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows> operator- ( const Matrix< _Ty, _Cols, _Rows > &  lhs,
const Matrix< _Ty, _Cols, _Rows > &  rhs 
) [inline]

Definition at line 361 of file MboMatrix.h.

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

00362 {
00363     Matrix<_Ty, _Cols, _Rows> ret();
00364 
00365     for (size_t i=0; i < _Rows; i++)
00366     {
00367         for (size_t j=0; j < _Cols; j++)
00368         {
00369             ret.Val[i][j] = lhs.Val[i][j] - rhs.Val[i][j];
00370         }
00371     }
00372     return ret;
00373 }

template<class _Ty, size_t _Cols, size_t _Rows>
Matrix<_Ty, _Cols, _Rows> operator^ ( const Matrix< _Ty, _Cols, _Rows > &  lhs,
const size_t &  rhs 
) [inline]

Definition at line 415 of file MboMatrix.h.

00416 {
00417     assert(rhs > 0); // need matrix E to begin with?
00418 
00419     Matrix<_Ty, _Cols, _Rows> temp(m);
00420 
00421     for (size_t i=2; i <= pow; i++)
00422     {
00423         ret = ret * lhs;
00424     }
00425 
00426     return ret;
00427 }

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

Definition at line 432 of file MboMatrix.h.

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

00433 {
00434     Matrix<_Ty, _Cols, _Rows> ret();
00435 
00436     for (size_t i=0; i < _Rows; i++)
00437     {
00438         for (size_t j=0; j < _Cols; j++)
00439         {
00440             ret.Val[i][j] = rhs.Val[j][i];
00441         }
00442     }
00443     return ret;
00444 }


  Hosted on code.google.com  
© Marcus Börger
Generated on Fri Jan 18 21:21:08 2008 for MBO-lib by doxygen 1.5.4