Abstract non Polymorphyc Matrix:
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines
Classes | Functions
Mx Namespace Reference

Chirrisquitica matrix by adolf.nosp@m.o@di.nosp@m.-mare.nosp@m..com. More...

Classes

class  Matrix_BASE
 This is the base template for the implementaciones of the chirrisquitica matrix. More...
class  Matrix_Dense
 This is a very chirrisquitica matrix that can change size dinamically. More...
class  Matrix_List_ColVal
 Private class used to implement the list of values for each row. More...
class  Matrix_List
 Chirrisquitica matrix stored as a sparse matrix implemented with lists. More...
class  Matrix_Sparse
 Chirrisquitica matrix stored as a sparse matrix. More...

Functions

template<class MAT >
bool check_ok_Matrix (const MAT &M)
 Generic verification of the class invariant check_ok().
template<class MAT >
unsigned count_Matrix (const MAT &M)
 Default implementation for Matrix_BASE<E>::count()
template<class MAT >
void clear_Matrix (MAT &M)
 Default implementation for Matrix_BASE<E>::clear()
template<class MAT >
bool equals_Matrix (const MAT &A, const MAT &B)
 Default implementation for Matrix_BASE<E>::operator==()
template<class MAT >
void add_Matrix (MAT &Res, const MAT &M)
 Default implementation for operator+( Matrix_BASE<E>&, Matrix_BASE<E> )
template<class MAT >
void substract_Matrix (MAT &Res, const MAT &M)
 Default implementation for operator-( Matrix_BASE<E>&, Matrix_BASE<E> )
template<class MAT >
void multiply_Matrix (MAT &Res, const MAT &A, const MAT &B)
 Calculates the multiplication A * B and stores the result in "Res".
template<class MAT >
MAT::reference at_Matrix (MAT &M, unsigned i, unsigned j)
 Default implementation for Matrix_BASE<E>::at()
template<class MAT >
MAT::const_reference at_Matrix (const MAT &M, unsigned i, unsigned j)
 Default implementation for Matrix_BASE<E>::at() const.
template<class MAT >
MAT operator+ (const Matrix_BASE< typename MAT::value_type > &A, const MAT &B)
 A+B
template<class MAT >
MAT operator- (const Matrix_BASE< typename MAT::value_type > &A, const MAT &B)
 A-B
template<class MAT >
MAT operator* (const Matrix_BASE< typename MAT::value_type > &A, const MAT &B)
 Res=A*B
template<class MAT >
bool operator== (const Matrix_BASE< typename MAT::value_type > &A, const MAT &B)
 ¿¿¿ (A == B) ???
template<class MAT >
bool operator!= (const Matrix_BASE< typename MAT::value_type > &A, const MAT &B)
 ¿¿¿ (A != B) ???
template<class MAT >
bool isSquare (const MAT &M)
 Returns "true" if matrix M[][] is square.
template<class MAT >
bool isDiagonal (const MAT &M)
 Returns "true" if matrix M[][] is diagonal.
template<class MAT >
bool isScalar (const MAT &M)
 Returns "true" if matrix M[][] is scalar.
template<class MAT >
bool isUnit (const MAT &M)
 Returns "true" if matrix M[][] is a unit matrix.
template<class MAT >
void setUnit (const MAT &M, unsigned n)
 Transforms M[][] into a identity matrix of size n x n.
template<class MAT >
bool isNull (const MAT &M)
 Returns "true" if matrix M[][] is null.
template<class MAT >
bool isSymmetric (const MAT &M)
 Returns "true" if matrix M[][] is symetric.
template<class MAT >
bool isUpperTiangular (const MAT &M)
 Returns "true" if matrix M[][] is upper triangular.
template<class MAT >
bool isLowerTiangular (const MAT &M)
 Returns "true" if matrix M[][] is lower triangular.
template<class T >
bool check_ok (const Matrix_Dense< T > &M)
 Checks the class invariant.
template<class T >
void add_Matrix (Matrix_Dense< T > &Res, const Matrix_Dense< T > &M)
 Default implementation for operator+( Matrix_BASE<E>&, Matrix_BASE<E> )
template<class T >
bool check_ok (const Matrix_List< T > &M)
template<class T >
bool check_ok (const Matrix_Sparse< T > &M)
 Verifica la invariante de la clase.
template<class T >
void add_Matrix (Matrix_Sparse< T > &Res, const Matrix_Sparse< T > &M)
 Default implementation for operator+( Matrix_BASE<E>&, Matrix_BASE<E> )

Detailed Description

Chirrisquitica matrix by adolf.nosp@m.o@di.nosp@m.-mare.nosp@m..com.


Function Documentation

template<class MAT >
bool Mx::check_ok_Matrix ( const MAT &  M)

Generic verification of the class invariant check_ok().

Remarks:
Releaves the programner form implementing method Ok()
  • check_ok(): (M.rows() == 0) <==> (M.cols() == 0)

Definition at line 140 of file Matrix_BASE.h.

template<class MAT >
unsigned Mx::count_Matrix ( const MAT &  M)

Default implementation for Matrix_BASE<E>::count()

Definition at line 167 of file Matrix_BASE.h.

template<class MAT >
void Mx::clear_Matrix ( MAT &  M)

Default implementation for Matrix_BASE<E>::clear()

Definition at line 178 of file Matrix_BASE.h.

template<class MAT >
bool Mx::equals_Matrix ( const MAT &  A,
const MAT &  B 
)

Default implementation for Matrix_BASE<E>::operator==()

Definition at line 190 of file Matrix_BASE.h.

template<class MAT >
void Mx::add_Matrix ( MAT &  Res,
const MAT &  M 
)

Default implementation for operator+( Matrix_BASE<E>&, Matrix_BASE<E> )

Precondition:
  • "*this" y "M" must have the same dimentions.
  • rows() == M.rows() && cols() == M.cols() .
Remarks:
  • This is the implementation for Matrix_BASE<E> operator+( Matrix_BASE<E>&, Matrix_BASE<E> ) .
  • The compiler has problems compiling a friend function ("friend") defined with templates if that friend function is not defined (implemented) within the class declaration. To overcome this deficiency there exists this function that does the work, although it is not convenient to use.

Definition at line 239 of file Matrix_BASE.h.

template<class MAT >
void Mx::substract_Matrix ( MAT &  Res,
const MAT &  M 
)

Default implementation for operator-( Matrix_BASE<E>&, Matrix_BASE<E> )

Definition at line 259 of file Matrix_BASE.h.

template<class MAT >
void Mx::multiply_Matrix ( MAT &  Res,
const MAT &  A,
const MAT &  B 
)

Calculates the multiplication A * B and stores the result in "Res".

  • The dimensions for "*this" get adjusted such that:
    Res.rows() == A.rows() && Res.cols() == B.cols()
  • This is the implementation for Matrix_BASE<E> operator*() .
Precondition:
  • "A" y "B" must have compatible dimensions.
  • A.cols() == B.rows() .
  • The multiplication is carried out [Row x Column], which means that the number of valies in the rows for "A" must be equal to the number of columns of "B".
Complexity:
O( A.cols() * B.cols() * A.cols() )

Definition at line 307 of file Matrix_BASE.h.

template<class MAT >
MAT::reference Mx::at_Matrix ( MAT &  M,
unsigned  i,
unsigned  j 
)

Default implementation for Matrix_BASE<E>::at()

Definition at line 335 of file Matrix_BASE.h.

template<class MAT >
MAT::const_reference Mx::at_Matrix ( const MAT &  M,
unsigned  i,
unsigned  j 
)

Default implementation for Matrix_BASE<E>::at() const.

Definition at line 354 of file Matrix_BASE.h.

template<class MAT >
MAT Mx::operator+ ( const Matrix_BASE< typename MAT::value_type > &  A,
const MAT &  B 
) [inline]

A+B

Definition at line 368 of file Matrix_BASE.h.

template<class MAT >
MAT Mx::operator- ( const Matrix_BASE< typename MAT::value_type > &  A,
const MAT &  B 
) [inline]

A-B

Definition at line 448 of file Matrix_BASE.h.

template<class MAT >
MAT Mx::operator* ( const Matrix_BASE< typename MAT::value_type > &  A,
const MAT &  B 
) [inline]

Res=A*B

Definition at line 454 of file Matrix_BASE.h.

template<class MAT >
bool Mx::operator== ( const Matrix_BASE< typename MAT::value_type > &  A,
const MAT &  B 
) [inline]

¿¿¿ (A == B) ???

Definition at line 460 of file Matrix_BASE.h.

template<class MAT >
bool Mx::operator!= ( const Matrix_BASE< typename MAT::value_type > &  A,
const MAT &  B 
) [inline]

¿¿¿ (A != B) ???

Definition at line 466 of file Matrix_BASE.h.

template<class MAT >
bool Mx::isSquare ( const MAT &  M)

Returns "true" if matrix M[][] is square.

Definition at line 32 of file Matrix_Lib.h.

template<class MAT >
bool Mx::isDiagonal ( const MAT &  M)

Returns "true" if matrix M[][] is diagonal.

Definition at line 43 of file Matrix_Lib.h.

template<class MAT >
bool Mx::isScalar ( const MAT &  M)

Returns "true" if matrix M[][] is scalar.

Definition at line 68 of file Matrix_Lib.h.

template<class MAT >
bool Mx::isUnit ( const MAT &  M) [inline]

Returns "true" if matrix M[][] is a unit matrix.

Definition at line 89 of file Matrix_Lib.h.

template<class MAT >
void Mx::setUnit ( const MAT &  M,
unsigned  n 
)

Transforms M[][] into a identity matrix of size n x n.

Definition at line 102 of file Matrix_Lib.h.

template<class MAT >
bool Mx::isNull ( const MAT &  M)

Returns "true" if matrix M[][] is null.

Definition at line 121 of file Matrix_Lib.h.

template<class MAT >
bool Mx::isSymmetric ( const MAT &  M)

Returns "true" if matrix M[][] is symetric.

Definition at line 141 of file Matrix_Lib.h.

template<class MAT >
bool Mx::isUpperTiangular ( const MAT &  M)

Returns "true" if matrix M[][] is upper triangular.

Definition at line 163 of file Matrix_Lib.h.

template<class MAT >
bool Mx::isLowerTiangular ( const MAT &  M)

Returns "true" if matrix M[][] is lower triangular.

Definition at line 187 of file Matrix_Lib.h.

template<class T >
bool Mx::check_ok ( const Matrix_Dense< T > &  M)

Checks the class invariant.

{{  // Rep ==> Diagrama de la clase
    +---+                                         /         \
    | 2 |  M(i,j) ==> m_val[ (i * m_cols) + j ]   | 0 1 2 3 |   m_rows == 2
    +---+  (almacenamiento por filas)             | 4 5 6 7 |   m_cols == 4
    | 4 |                                         \         /
    +---+   +---+---+---+---+---+---+---+---+
    | *-|-->| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
    +---+   +---+---+---+---+---+---+---+---+

    +---+
    | 4 |  M(i,j) ==> m_val[ i + (j * m_rows) ]   / a e \
    +---+  (almacenamiento por columnas)          | b f |   m_rows == 4
    | 2 |                                         | c g |   m_cols == 2
    +---+   +---+---+---+---+---+---+---+---+     \ d h /
    | *-|-->| a | b | c | d | e | f | g | h |
    +---+   +---+---+---+---+---+---+---+---+
}}
Remarks:
Releaves the programner form implementing method Ok()

  • check_ok(): (M.m_rows == 0) <==> (M.m_cols == 0)

Definition at line 140 of file Matrix_Dense.h.

template<class T >
void Mx::add_Matrix ( Matrix_Dense< T > &  Res,
const Matrix_Dense< T > &  M 
)

Default implementation for operator+( Matrix_BASE<E>&, Matrix_BASE<E> )

Precondition:
  • "*this" y "M" must have the same dimentions.
  • rows() == M.rows() && cols() == M.cols() .
Remarks:
  • This is the implementation for Matrix_BASE<E> operator+( Matrix_BASE<E>&, Matrix_BASE<E> ) .
  • The compiler has problems compiling a friend function ("friend") defined with templates if that friend function is not defined (implemented) within the class declaration. To overcome this deficiency there exists this function that does the work, although it is not convenient to use.

Definition at line 394 of file Matrix_Dense.h.

template<class T >
bool Mx::check_ok ( const Matrix_List< T > &  M)

Definition at line 187 of file Matrix_List.h.

template<class T >
bool Mx::check_ok ( const Matrix_Sparse< T > &  M)

Verifica la invariante de la clase.

- El campo \c m_same indica cuál es el valor que se repite más en toda la matriz.
- Usualmente \c same es el neutro aditivo \c value_type().
- No existe un constructor explícito para darle a \c m_same su valor inicial, que
  es siempre inicializado en \c value_type(). Para cambiarlo es necesario invocar
  el método \c setgetDefault().
- Los vectores \c m_I[], \c m_J[] y \c m_val[] son vectores paralelos, todos de
  longitud \c Matrix_Sparse::m_capacity.
- La cantidad máxima de valores diferente que pueden ser almacenados en la matriz
  es \c Matrix_Sparse::m_capacity.
- El largo de estos vectores aumenta cuando se hace referencia a un valor M(i,j)
  mediante la versión que no es \c const del \c operator()(i,j). O sea, que es
  ese método el encargado de agregar valores en \c m_val[], pues el operador
  homónimo \c const operator()(i,j) nunca agrega nada y, como es \c const, en
  general retorna una referencia constante a \c m_same.
- Es posible que la matriz tenga dimensiones nulas, lo que implica que todos los
  punteros a los vectors paralelos deben ser nulos. Este hecho se marca dándolo
  el valor \c 0 (cero) al campo \c m_capacity.
- En todos los algoritmos, "m" o "m_rows" es la cantidad de filas == \c rows()
- En todos los algoritmos, "n" o "m_cols" es la cantidad de columnas == \c cols()

\par <em>Rep</em> Modelo de la clase
         ____________________________________
        /          m_capacity                \
        +---+---+---+---+---+---+-..-+---+---+       0 1 2 3 4 5 6
 m_I--->| 1 | 3 | 3 |'-'| ...       ...  |'-'|   0 / - - - - - - - \
        +---+---+---+---+ ...       ...  +---+   1 | - a - - - - - |
 m_J--->| 1 | 2 | 1 |'-'| ...       ...  |'-'|   2 | - - - - - - - |
        +---+---+---+---+ ...       ...  +---+   3 | - c b - - - - |
m_val-->|'a'|'b'|'c'|'-'| ...       ...  |'-'|   4 \ - - - - - - - /
        +---+---+---+---+---+---+-..-+---+---+
          0   1   2   |
        m_size--------+ == 3    m_same == '-'   m_rows == 5  m_cols == 7
  • check_ok(): ( (0<=m_I[k]) && (m_I[k] < m_rows) ) k = [0..m_size-1]
  • check_ok(): ( (0<=m_J[k]) && (m_J[k] < m_cols) ) k = [0..m_size-1]

Definition at line 141 of file Matrix_Sparse.h.

template<class T >
void Mx::add_Matrix ( Matrix_Sparse< T > &  Res,
const Matrix_Sparse< T > &  M 
)

Default implementation for operator+( Matrix_BASE<E>&, Matrix_BASE<E> )

Precondition:
  • "*this" y "M" must have the same dimentions.
  • rows() == M.rows() && cols() == M.cols() .
Remarks:
  • This is the implementation for Matrix_BASE<E> operator+( Matrix_BASE<E>&, Matrix_BASE<E> ) .
  • The compiler has problems compiling a friend function ("friend") defined with templates if that friend function is not defined (implemented) within the class declaration. To overcome this deficiency there exists this function that does the work, although it is not convenient to use.

Definition at line 652 of file Matrix_Sparse.h.