Generic Matrix. More...

#include <rgenericmatrix.h>

Inheritance diagram for RGenericMatrix:
[legend]

Public Types

enum  tType {
  tNormal, tDiagonal, tLowerTriangular, tUpperTriangular,
  tSymmetric, tSparse, tSparseSymmetric, tMax
}
 

Public Member Functions

virtual void Add (size_t i, size_t j, double val)
 
virtual void Clear (double val=NAN, bool clean=false)
 
int Compare (const RGenericMatrix &matrix) const
 
size_t GetNbCols (void) const
 
size_t GetNbLines (void) const
 
virtual tType GetType (void) const =0
 
virtual void Init (double val)
 
virtual double operator() (size_t i, size_t j) const =0
 
virtual double & operator() (size_t i, size_t j)=0
 
RGenericMatrixoperator= (const RGenericMatrix &matrix)
 
template<class S >
void Print (S &stream, const RString &name, const char *format="%E", size_t colsize=12) const
 
 RGenericMatrix (size_t size)
 
 RGenericMatrix (size_t lines, size_t cols)
 
 RGenericMatrix (const RGenericMatrix &matrix)
 
virtual void VerifySize (size_t newlines, size_t newcols, bool fill=false, double val=NAN)=0
 
virtual ~RGenericMatrix (void)
 

Protected Attributes

size_t NbCols
 
size_t NbLines
 

Detailed Description

Generic Matrix.

The RGenericMatrix class provides a representation for a generic matrix. It provides several operator acting on generic matrices. The operators are based on the operator(i,j) and are not optimized. If possible, these operators should be specialized in inheriting classes for performance purposes.

Member Enumeration Documentation

enum tType

Type of a matrix.

Enumerator
tNormal 

Normal matrix.

tDiagonal 

Diagonal matrix.

tLowerTriangular 

Lower triangular matrix.

tUpperTriangular 

Upper triangular matrix.

tSymmetric 

Symmetric matrix.

tSparse 

Sparse matrix.

tSparseSymmetric 

Sparse symmetric matrix.

tMax 

Ascending ordered sparse matrix.

Constructor & Destructor Documentation

RGenericMatrix ( size_t  size)

Construct a square matrix of a given size.

Parameters
sizeSize of the matrix.
RGenericMatrix ( size_t  lines,
size_t  cols 
)

Construct a matrix (L,C).

Parameters
linesNumber of lines.
colsNumber of columns.
RGenericMatrix ( const RGenericMatrix matrix)

Construct a matrix from another one.

Parameters
matrixMatrix.
virtual ~RGenericMatrix ( void  )
virtual

Destruct the matrix.

Member Function Documentation

int Compare ( const RGenericMatrix matrix) const

Compare method used by RContainer.

Parameters
matrixMatrix to compare with.
Returns
always -1.
virtual void Clear ( double  val = NAN,
bool  clean = false 
)
virtual

Clear the matrix. By default, it initialize the elements with Init.

Parameters
valValue eventually used to assign to the elements.
cleanClean eventually the memory.

Reimplemented in RMaxMatrix, and RSparseMatrix.

virtual void Init ( double  val)
virtual

Initialize the matrix with a given value. It uses the operator(i,j) to initialize the different elements.

Parameters
valValue to assign.

Reimplemented in RMatrix, RMaxMatrix, and RSparseMatrix.

virtual void VerifySize ( size_t  newlines,
size_t  newcols,
bool  fill = false,
double  val = NAN 
)
pure virtual

Verify if the matrix has a given size, and increase them if necessary.

Parameters
newlinesNew line number.
newcolsNew column number.
fillElements must be filled with a value.
valValue used eventually to fill the elements created.

Implemented in RMatrix, RMaxMatrix, RSparseMatrix, and RLowerTriangularMatrix.

virtual tType GetType ( void  ) const
pure virtual

Get the type of the matrix.

Implemented in RMatrix, RMaxMatrix, RSparseMatrix, RLowerTriangularMatrix, RSymmetricMatrix, and RSparseSymmetricMatrix.

size_t GetNbLines ( void  ) const

Get the number of lines in the matrix.

size_t GetNbCols ( void  ) const

Get the number of columns in the matrix.

virtual double operator() ( size_t  i,
size_t  j 
) const
pure virtual

Return a specific element of the matrix (const version).

Parameters
iLine number of the element.
jColumn number of the element.

Implemented in RMatrix, RMaxMatrix, RSparseMatrix, RLowerTriangularMatrix, RSparseSymmetricMatrix, and RSymmetricMatrix.

virtual double& operator() ( size_t  i,
size_t  j 
)
pure virtual

Return a specific element of the matrix (const version).

Parameters
iLine number of the element.
jColumn number of the element.

Implemented in RMatrix, RMaxMatrix, RSparseMatrix, RLowerTriangularMatrix, RSparseSymmetricMatrix, and RSymmetricMatrix.

virtual void Add ( size_t  i,
size_t  j,
double  val 
)
virtual

Add a value associated to a given index into the matrix. By default, it calles the operator(size_t,size_t) method

Parameters
iLine number of the element.
jColumn number of the element.
valValue to add.

Reimplemented in RMaxMatrix.

RGenericMatrix& operator= ( const RGenericMatrix matrix)

Assign operator.

Parameters
matrixMatrix.
void Print ( S &  stream,
const RString name,
const char *  format = "%E",
size_t  colsize = 12 
) const

Print the content of the matrix.

Template Parameters
SStream class that implements the << operator.
Parameters
streamStream.
nameName of the matrix.
formatFormat used to print the number. By default, it is "%E".
colsizeSize of a column. By default, it is 12.

Member Data Documentation

size_t NbLines
protected

Number of lines.

size_t NbCols
protected

Number of columns.