Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

FD::Matrix< T > Class Template Reference

#include <Matrix.h>

Collaboration diagram for FD::Matrix< T >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef T basicType
 You can always get the type of the Matrix by using typename Matrix<T>::basicType.

Public Member Functions

 Matrix ()
 Default constructor, will initialize Matrix dimensions to (0,0).
 Matrix (const Matrix &mat, bool transpose=false)
 Matrix (int _rows, int _cols)
virtual ~Matrix ()
 Destructor delete matrix data.
void resize (int _rows, int _cols)
T * operator[] (int i)
const T * operator[] (int i) const
T & operator() (int i, int j)
const T & operator() (int i, int j) const
int nrows () const
 returns the number of rows
int ncols () const
 returns the number of cols
void transpose ()
 transpose the matrix (i,j) becomes (j,i), cols = rows, rows = cols.
void printOn (std::ostream &out) const
void readFrom (std::istream &in=std::cin)
int size () const
virtual size_t msize () const
 return matrix size
virtual bool mempty () const
 return true if matrix empty
virtual void serialize (std::ostream &out) const
virtual void unserialize (std::istream &in)
virtual ObjectRef getIndex (int _row, int _col)
virtual void setIndex (int _row, int _col, ObjectRef val)
virtual ObjectRef clone ()
 clone default implementation
template<>
ObjectRef clone ()

Static Public Member Functions

static std::string GetClassName ()
 returns the class name

Protected Attributes

int rows
 number of rows in the Matrix
int cols
 number of cols in the Matrix
T * data

Detailed Description

template<class T>
class FD::Matrix< T >

Matrix class (template). Registered Matrices are : Matrix<bool>, Matrix<int>, Matrix<float>, Matrix<double>, Matrix<complex<float>>, Matrix<complex<double>>, Matrix<ObjectRef>.

Author:
Jean-Marc Valin (initial implementation)

Dominic Letourneau (added I/O capabilities)

Date:
18/02/2004


Constructor & Destructor Documentation

template<class T>
FD::Matrix< T >::Matrix const Matrix< T > &  mat,
bool  transpose = false
[inline]
 

Copy constructor

Parameters:
mat The matrix to copy
transpose transpose matrix if true, defaults to false

template<class T>
FD::Matrix< T >::Matrix int  _rows,
int  _cols
[inline]
 

Constructor with _rows and _cols

Parameters:
_rows number of rows in the matrix
_cols number of cols in the matrix


Member Function Documentation

template<class T>
ObjectRef FD::Matrix< T >::clone  )  [inline, virtual]
 

clone default implementation

Clone the matrix and return an identical copy (deep copy)

template<class T>
ObjectRef FD::Matrix< T >::getIndex int  _row,
int  _col
[inline, virtual]
 

Returns an element (in an ObjectRef) of the matrix

Parameters:
_row the row of the element
_col the col of the element
Returns:
ObjectRef the newly created Object

template<class T>
const T& FD::Matrix< T >::operator() int  i,
int  j
const [inline]
 

operator(i,j) returns the element at row i, col j.

Parameters:
i the row number
j the col number
Returns:
T The element at position (i,j)

template<class T>
T& FD::Matrix< T >::operator() int  i,
int  j
[inline]
 

operator(i,j) returns the element at row i, col j.

Parameters:
i the row number
j the col number
Returns:
T The element at position (i,j)

template<class T>
const T* FD::Matrix< T >::operator[] int  i  )  const [inline]
 

operator[] returns the data pointer at a determined row.

Parameters:
i the row number
Returns:
T* The data pointer to the first element of the row i

template<class T>
T* FD::Matrix< T >::operator[] int  i  )  [inline]
 

operator[] returns the data pointer at a determined row.

Parameters:
i the row number
Returns:
T* The data pointer to the first element of the row i

template<class T>
void FD::Matrix< T >::printOn std::ostream &  out  )  const [inline]
 

Formatted Matrix output in the FlowDesigner Format.
Format : <Matrix<T> <rows nrows > <cols ncols > <data element(0,0) element(0,1) ... element(rows-1,cols-1)> >

Parameters:
out the output stream

template<class T>
void FD::Matrix< T >::readFrom std::istream &  in = std::cin  )  [inline]
 

Formatted Matrix input in the FlowDesigner Format.
Format : <Matrix<T> <rows nrows > <cols ncols > <data element(0,0) element(0,1) ... element(rows-1,cols-1)> >

Parameters:
in the input stream

template<class T>
void FD::Matrix< T >::resize int  _rows,
int  _cols
[inline]
 

Resize a matrix (keeps elements already inserted into the Matrix). Elements out of range in the new matrix are discarded.

Parameters:
_rows new number of rows of the matrix
_cols new number of cols of the matrix

template<class T>
void FD::Matrix< T >::serialize std::ostream &  out  )  const [inline, virtual]
 

Binary Matrix output in the FlowDesigner Format.
Format : {Matrix<T> |rows;cols;element(0,0);element(0,1) ... element(rows-1,cols-1)}

Parameters:
out the output stream

template<class T>
void FD::Matrix< T >::setIndex int  _row,
int  _col,
ObjectRef  val
[inline, virtual]
 

Sets an element (in an ObjectRef) of the matrix

Parameters:
_row the row of the element
_col the col of the element
val the new value of the element

template<class T>
int FD::Matrix< T >::size  )  const [inline]
 

Returns the size of the matrix

Returns:
int size (cols * rows)

template<class T>
void FD::Matrix< T >::unserialize std::istream &  in  )  [inline, virtual]
 

Binary Matrix input in the FlowDesigner Format.
Format : {Matrix<T> |rows;cols;element(0,0);element(0,1) ... element(rows-1,cols-1)}

Parameters:
in the input stream


The documentation for this class was generated from the following file:
Generated on Wed Oct 5 14:29:27 2005 for FlowDesigner by  doxygen 1.4.4