GCpp general purpose C++ library  version 1.0
GMatrixT< T > Class Template Reference

#include <GMatrixT.hh>

Inheritance diagram for GMatrixT< T >:
GMatrix4

Public Member Functions

 GMatrixT (size_t nr=1, size_t nc=1)
 
 GMatrixT (size_t nr, size_t nc, const T &x)
 
 GMatrixT (const GMatrixT< T > &m)
 
GMatrixT< T > & operator= (const GMatrixT< T > &m)
 
virtual ~GMatrixT ()
 
virtual void InitElement (size_t i)
 
virtual void InitData ()
 
virtual void InitData (const T x)
 
virtual void InitData (const T x[])
 
virtual bool CheckIndex (size_t i, size_t j) const
 
virtual bool CheckIndex (size_t k) const
 
virtual bool CheckDimensions (const GMatrixT< T > &m) const
 
virtual bool CheckProduct (const GMatrixT< T > &m) const
 
virtual bool CheckProduct (const GVectorT< T > &v) const
 
virtual bool CheckDimChange () const
 
size_t GetRowsNumber () const
 
size_t GetColumnsNumber () const
 
size_t GetDimension () const
 
size_t SetDimension (size_t nr, size_t nc)
 
const T * Data () const
 
T * Data ()
 
size_t GetIndex (size_t i, size_t j) const
 
virtual const T & operator() (size_t i, size_t j) const
 
virtual T & operator() (size_t i, size_t j)
 
GVectorT< T > GetRow (size_t i)
 
GVectorT< T > GetColumn (size_t j)
 
virtual const T & operator[] (size_t k) const
 
virtual T & operator[] (size_t k)
 
virtual void SetRow (size_t i, const GVectorT< T > &v)
 
virtual void SetColumn (size_t j, const GVectorT< T > &v)
 
virtual GMatrixT< T > operator+ (const GMatrixT< T > &m) const
 
virtual GMatrixT< T > operator- (const GMatrixT< T > &m) const
 
virtual GMatrixT< T > operator* (const T k) const
 
virtual GMatrixT< T > operator/ (const T k) const
 
virtual GMatrixT< T > & operator+= (const GMatrixT< T > &m)
 
virtual GMatrixT< T > & operator-= (const GMatrixT< T > &m)
 
virtual GMatrixT< T > & operator*= (const T k)
 
virtual GMatrixT< T > & operator/= (const T k)
 
virtual GMatrixT< T > operator- () const
 
virtual GMatrixT< T > operator* (const GMatrixT< T > &m) const
 
virtual GVectorT< T > operator* (const GVectorT< T > &v) const
 
virtual GMatrixT< T > & Transpose ()
 
virtual GMatrixT< T > GetTransposed () const
 
template<>
void InitData ()
 

Protected Member Functions

virtual T * Allocate (size_t nr, size_t nc)
 
virtual void Reset ()
 

Protected Attributes

bool change_dim
 Indicates if dimensions can be changed.
 
size_t nb_row
 Rows number.
 
size_t nb_col
 Columns number.
 
size_t dimension
 Total dimension.
 
T * element
 Elements array.
 

Detailed Description

template<typename T>
class GMatrixT< T >

Template class defining a matrix for numerical types

The basic matrix operations are defined, with the assumption that the standard algebaric operation of the template class are defined.

For effective instantiation of a class, the following functions should be specialised (see file GMatrixD.hh):

  • (none)
Note
  • the initialisation functions InitElement and InitData clear the elements memory with 0; if elements initialisation requires more sophisticated actions, due to class type, the template class must be derived.

Constructor & Destructor Documentation

template<typename T >
GMatrixT< T >::GMatrixT ( size_t  nr = 1,
size_t  nc = 1 
)

Default constructor.

Parameters
nrrows number
nccolumns number
template<typename T >
GMatrixT< T >::GMatrixT ( size_t  nr,
size_t  nc,
const T &  x 
)

Constructor of a diagonal matrix with elements set to the same value.

Parameters
nrrows number
nccolumns number
xdata value
template<typename T >
GMatrixT< T >::GMatrixT ( const GMatrixT< T > &  m)

Copy constructor.

Parameters
mmatrix to copy

References GMatrixT< T >::Data(), GMatrixT< T >::GetColumnsNumber(), and GMatrixT< T >::GetRowsNumber().

template<typename T >
GMatrixT< T >::~GMatrixT ( )
inlinevirtual

Destructor.

Member Function Documentation

template<typename T >
T * GMatrixT< T >::Allocate ( size_t  nr,
size_t  nc 
)
protectedvirtual

Allocate the memory for matrix elements, and set dimensions.

Parameters
nrrows number
nccolumns number
template<typename T >
bool GMatrixT< T >::CheckDimChange ( ) const
inlinevirtual

Function warning if matrix shall not change its dimension.

References GLogWarning().

template<typename T >
bool GMatrixT< T >::CheckDimensions ( const GMatrixT< T > &  m) const
virtual

Function warning if the matrices do not have the same dimensions.

Parameters
mmatrix second operand

References GMatrixT< T >::GetColumnsNumber(), GMatrixT< T >::GetRowsNumber(), and GLogWarning().

Referenced by GMatrix4::GMatrix4().

template<typename T >
bool GMatrixT< T >::CheckIndex ( size_t  i,
size_t  j 
) const
virtual

Function warning when indexes are out of bounds.

Parameters
ichecked row value
jchecked column value

References GGetString(), and GLogWarning().

template<typename T >
bool GMatrixT< T >::CheckIndex ( size_t  k) const
virtual

Function warning when the absolute index is out of bounds.

Parameters
kchecked index value

References GGetString(), and GLogWarning().

template<typename T >
bool GMatrixT< T >::CheckProduct ( const GMatrixT< T > &  m) const
virtual

Function warning if the matrix is not compatible with the argument for the product (*this)*m.

Parameters
mmatrix second operand

References GMatrixT< T >::GetRowsNumber(), and GLogWarning().

template<typename T >
bool GMatrixT< T >::CheckProduct ( const GVectorT< T > &  v) const
virtual

Function warning if the matrix is not compatible with the argument for the product (*this)*v.

Parameters
vvector operand

References GVectorT< T >::GetDimension(), and GLogWarning().

template<typename T >
T * GMatrixT< T >::Data ( )
inline

Return the data array pointer.

template<typename T >
GVectorT< T > GMatrixT< T >::GetColumn ( size_t  j)

Return a column vector.

Parameters
jcolumn number
template<typename T >
size_t GMatrixT< T >::GetColumnsNumber ( ) const
inline
template<typename T >
size_t GMatrixT< T >::GetDimension ( ) const
inline

Return the total dimension (rows x columns.

template<typename T >
size_t GMatrixT< T >::GetIndex ( size_t  i,
size_t  j 
) const
inline

Return the element index in the array corresponding to row and column numbers.

Referenced by GMatrix4::GMatrix4(), GVectorT< T >::operator*(), and GMatrixT< T >::operator*().

template<typename T >
GVectorT< T > GMatrixT< T >::GetRow ( size_t  i)

Return a row vector.

Parameters
irow number
template<typename T >
size_t GMatrixT< T >::GetRowsNumber ( ) const
inline
template<typename T >
GMatrixT< T > GMatrixT< T >::GetTransposed ( ) const
virtual

Return the transposed of the current matrix, without changing it.

template<>
void GMatrixT< double >::InitData ( )
inline

Specialisation of the function to initialise the matrix content.

template<typename T >
void GMatrixT< T >::InitData ( )
inlinevirtual

Function to initialise the vector content.

Referenced by GMatrix4::GMatrix4().

template<typename T >
void GMatrixT< T >::InitData ( const T  x)
inlinevirtual

Function to initialise all matrix elements with the same value.

Parameters
xelement value
template<typename T >
void GMatrixT< T >::InitData ( const T  x[])
inlinevirtual

Function to initialise the matrix content with an array of data. If the array dimension must be at least the total matrix dimension.

template<typename T >
void GMatrixT< T >::InitElement ( size_t  i)
inlinevirtual

Function to initialise an element content..

template<typename T >
const T & GMatrixT< T >::operator() ( size_t  i,
size_t  j 
) const
inlinevirtual

Return a component.

Parameters
irow number
jcolumn number
template<typename T >
T & GMatrixT< T >::operator() ( size_t  i,
size_t  j 
)
inlinevirtual

Return a component.

Parameters
irow number
jcolumn number
template<typename T >
GMatrixT< T > GMatrixT< T >::operator* ( const T  k) const
virtual

Multiplication scaling.

Parameters
kscaling factor

References GMatrixT< T >::Data().

template<typename T >
GMatrixT< T > GMatrixT< T >::operator* ( const GMatrixT< T > &  m) const
virtual

Matrices product.

Parameters
msecond operand

References GMatrixT< T >::Data(), GMatrixT< T >::GetColumnsNumber(), and GMatrixT< T >::GetIndex().

template<typename T >
GVectorT< T > GMatrixT< T >::operator* ( const GVectorT< T > &  v) const
virtual

Product of the matrix with a vector.

Parameters
vsecond operand

References GVectorT< T >::Data().

template<typename T >
GMatrixT< T > & GMatrixT< T >::operator*= ( const T  k)
virtual

Multiplication scaling.

Parameters
kscaling factor
template<typename T >
GMatrixT< T > GMatrixT< T >::operator+ ( const GMatrixT< T > &  m) const
virtual

Matrix addition.

Parameters
msecond operand

References GMatrixT< T >::Data().

template<typename T >
GMatrixT< T > & GMatrixT< T >::operator+= ( const GMatrixT< T > &  m)
virtual

Matrix addition.

Parameters
msecond operand

References GMatrixT< T >::Data().

template<typename T >
GMatrixT< T > GMatrixT< T >::operator- ( const GMatrixT< T > &  m) const
virtual

Matrix subtraction.

Parameters
msecond operand

References GMatrixT< T >::Data().

template<typename T >
GMatrixT< T > GMatrixT< T >::operator- ( ) const
virtual

Unary minus.

References GMatrixT< T >::Data().

template<typename T >
GMatrixT< T > & GMatrixT< T >::operator-= ( const GMatrixT< T > &  m)
virtual

Matrix subtraction.

Parameters
msecond operand

References GMatrixT< T >::Data().

template<typename T >
GMatrixT< T > GMatrixT< T >::operator/ ( const T  k) const
virtual

Division scaling.

Parameters
kscaling factor

References GMatrixT< T >::Data().

template<typename T >
GMatrixT< T > & GMatrixT< T >::operator/= ( const T  k)
virtual

Division scaling.

Parameters
kscaling factor
template<typename T >
GMatrixT< T > & GMatrixT< T >::operator= ( const GMatrixT< T > &  m)

Affectation operator.

Parameters
mmatrix to copy

References GMatrixT< T >::Data(), GMatrixT< T >::GetColumnsNumber(), and GMatrixT< T >::GetRowsNumber().

template<typename T >
const T & GMatrixT< T >::operator[] ( size_t  k) const
inlinevirtual

Return a component from its absolute index.

Parameters
kcomponent index
template<typename T >
T & GMatrixT< T >::operator[] ( size_t  k)
inlinevirtual

Return a component from its absolute index.

Parameters
kcomponent index
template<typename T >
void GMatrixT< T >::Reset ( )
protectedvirtual

Reset the matrix (dimensions set to 0).

template<typename T >
void GMatrixT< T >::SetColumn ( size_t  j,
const GVectorT< T > &  v 
)
virtual

Modify a matrix columns.

Parameters
jcolumns number
vcolumns row vector

References GVectorT< T >::Data(), GVectorT< T >::GetDimension(), and GLogWarning().

Referenced by GMatrix4::GMatrix4().

template<typename T >
size_t GMatrixT< T >::SetDimension ( size_t  nr,
size_t  nc 
)

Sets new rows and columns numbers. The previous data are conserved for the common part of previous and new dimensions. The function returns the total matrix dimension.

Parameters
nrrows number
nccolumns number

References GLogWarning().

template<typename T >
void GMatrixT< T >::SetRow ( size_t  i,
const GVectorT< T > &  v 
)
virtual

Modify a matrix row.

Parameters
irow number
vnew row vector

References GVectorT< T >::Data(), GVectorT< T >::GetDimension(), and GLogWarning().

template<typename T >
GMatrixT< T > & GMatrixT< T >::Transpose ( )
virtual

Transposition of the current matrix.


The documentation for this class was generated from the following files: