TMatrix< TRing > Class Template Reference
[Algebra objectsVectors and Matrices]

Template matrix. Supports rank and kernel computations over a finite field (naive implementation, very slow - use FFPACK Matrices for faster computation) Matrix size is shrinked to 'int'. Data layout is row-by-row. More...

#include <TMatrix.h>

Collaboration diagram for TMatrix< TRing >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef TRing::ElementType TNum
typedef TRing::ElementType ElementType
typedef TRing RingType

Public Member Functions

virtual ~TMatrix ()
template<class TRing >
 TMatrix (string matrixStr, const TRing *_ring, std::string _name)
 create a matrix from a string matrixStr with elements in _ring
Constructors

 TMatrix (unsigned int rowNum, unsigned int colNum, const TRing *_ring, std::string name="nonameMatrix")
 create an ' rowNum x colNum '-matrix with elements in _ring
 TMatrix (const TMatrix &mat)
template<class _istream >
 TMatrix (const TRing *_ring, _istream &sstream, std::string _name="")
 create a matrix from stream with elements in _ring
 TMatrix (std::string strMatrix, const TRing *_ring, std::string _name="nonameMatrix")
template<class TemplateMatrix >
 TMatrix (const TemplateMatrix &mat, const TRing *_ring)
 template copy constructor
 TMatrix (unsigned int _zeilen, unsigned int _spalten, const TRing *_ring, TVector< TRing > &vec, std::string _name="")
init

void fillZero ()
 fills Matrix with TNum::Zero
void randomInit (long *_pRandomSeed)
 Init all entries with random TMatrix::ring elements.
_randomSeed has to point to a seed number, which is used (and updated) by ran2() random generator.
Only implemented for scalar entries ( TMatrix::ring->getEpsPrecision()==0 ).
properties

size_t getSize () const
unsigned int getColNum () const
unsigned int getRowNum () const
std::string getName () const
void setName (std::string _name)
const TRing * getRing () const
safety

void checkBounds (unsigned int _row, unsigned int _col) const
data access

void setVal (const unsigned int _row, const unsigned int _col, const TNum z)
TNum getVal (const unsigned int _row, const unsigned int _col) const
const TNumgetConstValRef (const unsigned int _row, const unsigned int _col) const
TNumgetValRef (const unsigned int _row, const unsigned int _col)
TNumgetValAddr (const unsigned int _row, const unsigned int _col)
TNumgetRowRef (unsigned int _row)
extract data

TNumgetRow (unsigned int _row) const
 returs a copy of the requested _row (0-based counting)
TNumgetCol (unsigned int _col) const
 returs a copy of the requested column _col (0-based counting)
TVector< TRing > * convertToVector () const
TVector< TRing > * getRowAsVector (unsigned int _row) const
 returs a copy of the requested _row (0-based counting)
TVector< TRing > * getColAsVector (unsigned int _col) const
 returs a copy of the requested column _col (0-based counting)
TNumgetDiag () const
 returns the diagonal entries as a TRing::ElementType-array for squared matrices
TVector< TRing > * getTrace () const
 returns the diagonal entries as a TVector for squared matrices
operators

bool isZero () const
 are all entries equals to zero ( NTum::Zero )?
bool isNotZero () const
bool isIdentity () const
bool operator== (const TMatrix &mat) const
 comparison
TMatrixoperator* (const TMatrix &mat) const
 matrix multiplication
TMatrixoperator| (const TMatrix &mat) const
TMatrixoperator= (const TMatrix &mat)
 assignment
TVector< TRing > * operator* (TVector< TRing > &vec) const
 vector multiplication
TMatrixgetSubMatrix (unsigned int firstrow, unsigned int firstcol, unsigned int lastrow, unsigned int lastcol) const
compute property

unsigned int getRank () const
unsigned int getRank (bool inplace)
 Compute matrix rank (operate in TRing TMatrix::ring) .
Row renumbering ( TMatrix::pcolumn ) and matrix data ( TMatrix::data ) is changed, when performed inplace
TMatrixgetKernel () const
TMatrixgetRowEchelonForm () const
TMatrixgetRowBasis () const
 todo: Zeilenbasis als Spalten oder als Zeilen ausgeben?
vector< bool > getLeadingVariables ()
vector< bool > getFreeVariables ()
TVector< TRing > * solveLGS (TVector< TRing > &rightHandSide)
 solve LGS funktioniert nicht einfach so, die RowEchelonForm-Umformungen müssen auch für die Rechte Seite durchgeführt werden.
convert

TMatrixgetTransposed () const
TMatrixtransposeInPlace ()
BlockMatrix< TRing > * getBlocked (unsigned int rowBlockSize, unsigned int colBlockSize) const
 converts the matrix to a block-organized one.
IO

void printInMacaulayStyle (std::ostream &os, bool assignment=false) const
 output Matrix in Macaulay style
void printValue (std::ostream &os) const
void printValueInMacaulayStyle (std::ostream &os) const

Protected Member Functions

void init ()
template<class _istream >
void createFromStream (_istream &dataStream)
size_t getDataPos (unsigned int row, unsigned int col) const
 computes the position of an element a(row , col ) in the TMatrix::data array

Protected Attributes

unsigned int rows_m
 number of rows_m
unsigned int cols_m
 number of columns
const TRing * ring
 pointer to an object with operations on TRing elements TMatrix::TNum .
TNumdata
 matrix data, row-by-row layout
string name
 matrix name
TNum ** pcolumn
 row renumbering; is changed by inplace rank computation ( getRank(bool) )

Detailed Description

template<class TRing>
class TMatrix< TRing >

Note:
template typedef is not supported by gcc 4.1.2

Definition at line 53 of file TMatrix.h.


Member Typedef Documentation

template<class TRing>
typedef TRing::ElementType TMatrix< TRing >::ElementType

Definition at line 57 of file TMatrix.h.

template<class TRing>
typedef TRing TMatrix< TRing >::RingType

Definition at line 58 of file TMatrix.h.

template<class TRing>
typedef TRing::ElementType TMatrix< TRing >::TNum

Definition at line 56 of file TMatrix.h.


Constructor & Destructor Documentation

template<class TRing >
TMatrix< TRing >::TMatrix ( unsigned int  rowNum,
unsigned int  colNum,
const TRing *  _ring,
std::string  name = "nonameMatrix" 
) [inline]

Definition at line 36 of file TMatrix.cpp.

References TMatrix< TRing >::fillZero(), and TMatrix< TRing >::init().

Here is the call graph for this function:

template<class TRing >
TMatrix< TRing >::TMatrix ( const TMatrix< TRing > &  mat  )  [inline]

Definition at line 211 of file TMatrix.cpp.

References TMatrix< TRing >::cols_m, TMatrix< TRing >::data, TMatrix< TRing >::init(), and TMatrix< TRing >::rows_m.

Here is the call graph for this function:

template<class TRing >
template<class _istream >
TMatrix< TRing >::TMatrix ( const TRing *  _ring,
_istream &  sstream,
std::string  _name = "" 
) [inline]

Definition at line 203 of file TMatrix.cpp.

References TMatrix< TRing >::createFromStream().

Here is the call graph for this function:

template<class TRing>
TMatrix< TRing >::TMatrix ( std::string  strMatrix,
const TRing *  _ring,
std::string  _name = "nonameMatrix" 
)
template<class TRing >
template<class TemplateMatrix >
TMatrix< TRing >::TMatrix ( const TemplateMatrix &  mat,
const TRing *  _ring 
) [inline]

/

Todo:
was passiert mit einem int nach einer Multiplikation ? / wird dieser bei Bedarf in ein 'long' umgewandelt, oder gibt es ein Überlauf? ->nehme an, es gibt einen Ueberlauf / Ist bei aktuell auftretenden Matrixgroessen aber nicht kritisch.
Parameters:
mat unblockedmatrix, with Interface getVal(i,j), getName(), getColNum(), getRowNum()
_ring all entries will be elements in _ring

Definition at line 80 of file TMatrix.cpp.

References TMatrix< TRing >::cols_m, TMatrix< TRing >::data, TMatrix< TRing >::getDataPos(), TMatrix< TRing >::init(), TMatrix< TRing >::ring, and TMatrix< TRing >::rows_m.

Here is the call graph for this function:

template<class TRing >
TMatrix< TRing >::TMatrix ( unsigned int  _zeilen,
unsigned int  _spalten,
const TRing *  _ring,
TVector< TRing > &  vec,
std::string  _name = "" 
) [inline]
template<class TRing >
TMatrix< TRing >::~TMatrix (  )  [inline, virtual]

Definition at line 227 of file TMatrix.cpp.

References TMatrix< TRing >::data, and TMatrix< TRing >::pcolumn.

template<class TRing>
template<class TRing >
TMatrix< TRing >::TMatrix ( string  matrixStr,
const TRing *  _ring,
std::string  _name 
) [inline]

Definition at line 190 of file TMatrix.cpp.

References TMatrix< TRing >::createFromStream().

Here is the call graph for this function:


Member Function Documentation

template<class TRing >
void TMatrix< TRing >::checkBounds ( unsigned int  _row,
unsigned int  _col 
) const [inline]
template<class TRing >
TVector< TRing > * TMatrix< TRing >::convertToVector (  )  const [inline]

Definition at line 248 of file TMatrix.cpp.

References TMatrix< TRing >::data, TMatrix< TRing >::getSize(), TMatrix< TRing >::name, TMatrix< TRing >::ring, and TVector< TRing >::setVal().

Here is the call graph for this function:

template<class TRing >
template<class _istream >
void TMatrix< TRing >::createFromStream ( _istream &  dataStream  )  [inline, protected]
template<class TRing >
void TMatrix< TRing >::fillZero (  )  [inline]
template<class TRing >
BlockMatrix< TRing > * TMatrix< TRing >::getBlocked ( unsigned int  rowBlockSize,
unsigned int  colBlockSize 
) const [inline]
template<class TRing >
TRing::ElementType * TMatrix< TRing >::getCol ( unsigned int  _col  )  const [inline]

Definition at line 663 of file TMatrix.cpp.

References TMatrix< TRing >::cols_m, TMatrix< TRing >::data, TMatrix< TRing >::getDataPos(), and TMatrix< TRing >::rows_m.

Here is the call graph for this function:

template<class TRing >
TVector< TRing > * TMatrix< TRing >::getColAsVector ( unsigned int  _col  )  const [inline]
template<class TRing>
unsigned int TMatrix< TRing >::getColNum (  )  const [inline]
template<class TRing >
const TRing::ElementType & TMatrix< TRing >::getConstValRef ( const unsigned int  _row,
const unsigned int  _col 
) const [inline]

Definition at line 330 of file TMatrix.cpp.

References TMatrix< TRing >::checkBounds(), TMatrix< TRing >::data, and TMatrix< TRing >::getDataPos().

Here is the call graph for this function:

template<class TRing>
size_t TMatrix< TRing >::getDataPos ( unsigned int  row,
unsigned int  col 
) const [inline, protected]
template<class TRing >
TRing::ElementType * TMatrix< TRing >::getDiag (  )  const [inline]

Definition at line 709 of file TMatrix.cpp.

References TMatrix< TRing >::cols_m, TMatrix< TRing >::data, TMatrix< TRing >::getDataPos(), and TMatrix< TRing >::rows_m.

Here is the call graph for this function:

template<class TRing >
vector< bool > TMatrix< TRing >::getFreeVariables (  )  [inline]

Definition at line 735 of file TMatrix.cpp.

References TMatrix< TRing >::cols_m, TMatrix< TRing >::isZero(), TMatrix< TRing >::pcolumn, and TMatrix< TRing >::rows_m.

Referenced by TMatrix< TRing >::getKernel().

Here is the call graph for this function:

template<class TRing >
TMatrix< TRing > * TMatrix< TRing >::getKernel (  )  const [inline]
template<class TRing >
vector< bool > TMatrix< TRing >::getLeadingVariables (  )  [inline]

Definition at line 765 of file TMatrix.cpp.

References TMatrix< TRing >::cols_m, TMatrix< TRing >::isZero(), TMatrix< TRing >::pcolumn, and TMatrix< TRing >::rows_m.

Here is the call graph for this function:

template<class TRing>
std::string TMatrix< TRing >::getName (  )  const [inline]

Definition at line 114 of file TMatrix.h.

References TMatrix< TRing >::name.

template<class TRing >
unsigned int TMatrix< TRing >::getRank ( bool  inplace  )  [inline]
template<class TRing >
unsigned int TMatrix< TRing >::getRank (  )  const [inline]

Definition at line 897 of file TMatrix.cpp.

References TMatrix< TRing >::getRank().

Referenced by TMatrix< TRing >::getKernel(), TMatrix< TRing >::getRank(), TMatrix< TRing >::getRowBasis(), and TMatrix< TRing >::getRowEchelonForm().

Here is the call graph for this function:

template<class TRing>
const TRing* TMatrix< TRing >::getRing (  )  const [inline]
template<class TRing >
TRing::ElementType * TMatrix< TRing >::getRow ( unsigned int  _row  )  const [inline]

Definition at line 674 of file TMatrix.cpp.

References TMatrix< TRing >::cols_m, TMatrix< TRing >::data, TMatrix< TRing >::getDataPos(), and TMatrix< TRing >::rows_m.

Here is the call graph for this function:

template<class TRing >
TVector< TRing > * TMatrix< TRing >::getRowAsVector ( unsigned int  _row  )  const [inline]
template<class TRing >
TMatrix< TRing > * TMatrix< TRing >::getRowBasis (  )  const [inline]
template<class TRing >
TMatrix< TRing > * TMatrix< TRing >::getRowEchelonForm (  )  const [inline]

Definition at line 907 of file TMatrix.cpp.

References TMatrix< TRing >::getRank().

Referenced by TMatrix< TRing >::getRowBasis().

Here is the call graph for this function:

template<class TRing>
unsigned int TMatrix< TRing >::getRowNum (  )  const [inline]
template<class TRing >
TRing::ElementType & TMatrix< TRing >::getRowRef ( unsigned int  _row  )  [inline]

Definition at line 358 of file TMatrix.cpp.

References TMatrix< TRing >::data, TMatrix< TRing >::getDataPos(), and TMatrix< TRing >::rows_m.

Here is the call graph for this function:

template<class TRing >
size_t TMatrix< TRing >::getSize (  )  const [inline]
template<class TRing >
TMatrix< TRing > * TMatrix< TRing >::getSubMatrix ( unsigned int  firstrow,
unsigned int  firstcol,
unsigned int  lastrow,
unsigned int  lastcol 
) const [inline]

Definition at line 423 of file TMatrix.cpp.

References TMatrix< TRing >::cols_m, TMatrix< TRing >::getVal(), TMatrix< TRing >::ring, TMatrix< TRing >::rows_m, and TMatrix< TRing >::setVal().

Here is the call graph for this function:

template<class TRing >
TVector< TRing > * TMatrix< TRing >::getTrace (  )  const [inline]
template<class TRing >
TMatrix< TRing > * TMatrix< TRing >::getTransposed (  )  const [inline]
template<class TRing >
TRing::ElementType TMatrix< TRing >::getVal ( const unsigned int  _row,
const unsigned int  _col 
) const [inline]
template<class TRing >
TRing::ElementType * TMatrix< TRing >::getValAddr ( const unsigned int  _row,
const unsigned int  _col 
) [inline]

Definition at line 349 of file TMatrix.cpp.

References TMatrix< TRing >::checkBounds(), TMatrix< TRing >::data, and TMatrix< TRing >::getDataPos().

Here is the call graph for this function:

template<class TRing >
TRing::ElementType & TMatrix< TRing >::getValRef ( const unsigned int  _row,
const unsigned int  _col 
) [inline]

Definition at line 340 of file TMatrix.cpp.

References TMatrix< TRing >::checkBounds(), TMatrix< TRing >::data, and TMatrix< TRing >::getDataPos().

Here is the call graph for this function:

template<class TRing >
void TMatrix< TRing >::init (  )  [inline, protected]
template<class TRing >
bool TMatrix< TRing >::isIdentity (  )  const [inline]

Definition at line 488 of file TMatrix.cpp.

References TMatrix< TRing >::cols_m, TMatrix< TRing >::getVal(), and TMatrix< TRing >::rows_m.

Here is the call graph for this function:

template<class TRing >
bool TMatrix< TRing >::isNotZero (  )  const [inline]
template<class TRing >
bool TMatrix< TRing >::isZero (  )  const [inline]
template<class TRing >
TVector< TRing > * TMatrix< TRing >::operator* ( TVector< TRing > &  vec  )  const [inline]
template<class TRing >
TMatrix< TRing > * TMatrix< TRing >::operator* ( const TMatrix< TRing > &  mat  )  const [inline]

Definition at line 373 of file TMatrix.cpp.

References TMatrix< TRing >::cols_m, TMatrix< TRing >::getVal(), TMatrix< TRing >::ring, TMatrix< TRing >::rows_m, and TMatrix< TRing >::setVal().

Here is the call graph for this function:

template<class TRing >
TMatrix< TRing > & TMatrix< TRing >::operator= ( const TMatrix< TRing > &  mat  )  [inline]
template<class TRing >
bool TMatrix< TRing >::operator== ( const TMatrix< TRing > &  mat  )  const [inline]

Definition at line 470 of file TMatrix.cpp.

References TMatrix< TRing >::cols_m, TMatrix< TRing >::getColNum(), TMatrix< TRing >::getRowNum(), TMatrix< TRing >::getVal(), and TMatrix< TRing >::rows_m.

Here is the call graph for this function:

template<class TRing >
TMatrix< TRing > * TMatrix< TRing >::operator| ( const TMatrix< TRing > &  mat  )  const [inline]
template<class TRing >
void TMatrix< TRing >::printInMacaulayStyle ( std::ostream &  os,
bool  bAssignment = false 
) const [inline]
Todo:
das ist wohl sowas wie ein decorator. print assignment/declaration in Macaulay style

Definition at line 1130 of file TMatrix.cpp.

References TMatrix< TRing >::name, and TMatrix< TRing >::printValueInMacaulayStyle().

Here is the call graph for this function:

template<class TRing >
void TMatrix< TRing >::printValue ( std::ostream &  os  )  const [inline]
template<class TRing >
void TMatrix< TRing >::printValueInMacaulayStyle ( std::ostream &  os  )  const [inline]

Definition at line 1111 of file TMatrix.cpp.

References TMatrix< TRing >::getTransposed(), TMatrix< TRing >::printValue(), and TMatrix< TRing >::rows_m.

Referenced by TMatrix< TRing >::printInMacaulayStyle().

Here is the call graph for this function:

template<class TRing >
void TMatrix< TRing >::randomInit ( long *  _pRandomSeed  )  [inline]

Definition at line 296 of file TMatrix.cpp.

References TMatrix< TRing >::cols_m, TMatrix< TRing >::data, random(), TMatrix< TRing >::ring, and TMatrix< TRing >::rows_m.

Here is the call graph for this function:

template<class TRing>
void TMatrix< TRing >::setName ( std::string  _name  )  [inline]

Definition at line 115 of file TMatrix.h.

References TMatrix< TRing >::name.

Referenced by TMatrix< TRing >::getRowBasis().

template<class TRing >
void TMatrix< TRing >::setVal ( const unsigned int  _row,
const unsigned int  _col,
const TNum  z 
) [inline]
template<class TRing >
TVector< TRing > * TMatrix< TRing >::solveLGS ( TVector< TRing > &  rightHandSide  )  [inline]

Definition at line 919 of file TMatrix.cpp.

template<class TRing >
TMatrix< TRing > & TMatrix< TRing >::transposeInPlace (  )  [inline]

Definition at line 603 of file TMatrix.cpp.

References TMatrix< TRing >::cols_m, TMatrix< TRing >::data, TMatrix< TRing >::getDataPos(), TMatrix< TRing >::pcolumn, and TMatrix< TRing >::rows_m.

Here is the call graph for this function:


Member Data Documentation

template<class TRing>
unsigned int TMatrix< TRing >::cols_m [protected]
template<class TRing>
TNum* TMatrix< TRing >::data [protected]
template<class TRing>
string TMatrix< TRing >::name [protected]
template<class TRing>
TNum** TMatrix< TRing >::pcolumn [protected]
template<class TRing>
const TRing* TMatrix< TRing >::ring [protected]
template<class TRing>
unsigned int TMatrix< TRing >::rows_m [protected]

The documentation for this class was generated from the following files:
Generated on Tue Nov 23 13:10:53 2010 for centerfocus by  doxygen 1.6.3