GCpp general purpose C++ library
version 1.0
|
#include <GMatrixT.hh>
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. | |
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):
Default constructor.
nr | rows number |
nc | columns number |
Constructor of a diagonal matrix with elements set to the same value.
nr | rows number |
nc | columns number |
x | data value |
Copy constructor.
m | matrix to copy |
References GMatrixT< T >::Data(), GMatrixT< T >::GetColumnsNumber(), and GMatrixT< T >::GetRowsNumber().
|
protectedvirtual |
Allocate the memory for matrix elements, and set dimensions.
nr | rows number |
nc | columns number |
|
inlinevirtual |
Function warning if matrix shall not change its dimension.
References GLogWarning().
Function warning if the matrices do not have the same dimensions.
m | matrix second operand |
References GMatrixT< T >::GetColumnsNumber(), GMatrixT< T >::GetRowsNumber(), and GLogWarning().
Referenced by GMatrix4::GMatrix4().
|
virtual |
Function warning when indexes are out of bounds.
i | checked row value |
j | checked column value |
References GGetString(), and GLogWarning().
|
virtual |
Function warning when the absolute index is out of bounds.
k | checked index value |
References GGetString(), and GLogWarning().
Function warning if the matrix is not compatible with the argument for the product (*this)*m.
m | matrix second operand |
References GMatrixT< T >::GetRowsNumber(), and GLogWarning().
Function warning if the matrix is not compatible with the argument for the product (*this)*v.
v | vector operand |
References GVectorT< T >::GetDimension(), and GLogWarning().
|
inline |
Return the data array pointer.
Referenced by GMatrix4::GMatrix4(), GMatrixT< T >::GMatrixT(), GMatrixT< T >::operator*(), GVectorT< T >::operator*(), GMatrixT< T >::operator+(), GMatrixT< T >::operator+=(), GMatrixT< T >::operator-(), GMatrixT< T >::operator-=(), GMatrixT< T >::operator/(), and GMatrixT< T >::operator=().
|
inline |
Return the data array pointer.
Return a column vector.
j | column number |
|
inline |
Return the number of columns.
Referenced by GMatrixT< T >::CheckDimensions(), GMatrixT< T >::GMatrixT(), GVectorT< T >::operator*(), GMatrixT< T >::operator*(), and GMatrixT< T >::operator=().
|
inline |
Return the total dimension (rows x columns.
|
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*().
Return a row vector.
i | row number |
|
inline |
Return the number of rows.
Referenced by GMatrixT< T >::CheckDimensions(), GMatrixT< T >::CheckProduct(), GVectorT< T >::CheckProduct(), GMatrixT< T >::GMatrixT(), and GMatrixT< T >::operator=().
Return the transposed of the current matrix, without changing it.
|
inline |
Specialisation of the function to initialise the matrix content.
|
inlinevirtual |
Function to initialise the vector content.
Referenced by GMatrix4::GMatrix4().
|
inlinevirtual |
Function to initialise all matrix elements with the same value.
x | element value |
|
inlinevirtual |
Function to initialise the matrix content with an array of data. If the array dimension must be at least the total matrix dimension.
|
inlinevirtual |
Function to initialise an element content..
|
inlinevirtual |
Return a component.
i | row number |
j | column number |
|
inlinevirtual |
Return a component.
i | row number |
j | column number |
|
virtual |
Matrices product.
m | second operand |
References GMatrixT< T >::Data(), GMatrixT< T >::GetColumnsNumber(), and GMatrixT< T >::GetIndex().
Multiplication scaling.
k | scaling factor |
Unary minus.
References GMatrixT< T >::Data().
Division scaling.
k | scaling factor |
Affectation operator.
m | matrix to copy |
References GMatrixT< T >::Data(), GMatrixT< T >::GetColumnsNumber(), and GMatrixT< T >::GetRowsNumber().
|
inlinevirtual |
Return a component from its absolute index.
k | component index |
|
inlinevirtual |
Return a component from its absolute index.
k | component index |
|
protectedvirtual |
Reset the matrix (dimensions set to 0).
Modify a matrix columns.
j | columns number |
v | columns row vector |
References GVectorT< T >::Data(), GVectorT< T >::GetDimension(), and GLogWarning().
Referenced by GMatrix4::GMatrix4().
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.
nr | rows number |
nc | columns number |
References GLogWarning().
Modify a matrix row.
i | row number |
v | new row vector |
References GVectorT< T >::Data(), GVectorT< T >::GetDimension(), and GLogWarning().
Transposition of the current matrix.