|
lkptr
|
Esta es una clase matriz muy chirrisquitica que puede cambiar dinámicamente de tamaño. More...
#include <Matrix.h>
Public Types | |
| typedef E | value_type |
| Tipo del objeto almacenado, similar al nombre usado en STL. | |
| typedef value_type & | reference |
| Tipo del objeto almacenado, similar al nombre usado en STL. | |
| typedef const value_type & | const_reference |
| Tipo del objeto almacenado, similar al nombre usado en STL. | |
| typedef unsigned | size_type |
| Tipo del tamaño de un objeto, similar al nombre usado en STL. | |
Public Member Functions | |
| Matrix (unsigned m=1, unsigned n=1) | |
| Constructor de vector. | |
| Matrix (const Matrix &o) | |
| Constructor de copia. | |
| Matrix (const value_type V) | |
Matriz escalar de valor V. | |
| ~Matrix () | |
| Destructor. | |
| unsigned | rows () const |
| Cantidad de filas de la matriz. | |
| unsigned | cols () const |
| Cantidad de columnas de la Matriz. | |
| unsigned | size () const |
| Cantidad de valores almacenados en la matriz. | |
| unsigned | count () const |
| Cantidad de valores almacenados en la matriz. | |
| size_type | capacity () const |
| Cantidad máxima posible de valores diferentes que pueden ser almacenados en la matriz. | |
| Matrix & | operator= (const Matrix &o) |
Sinónimo de this->copy(o) | |
| Matrix & | copy (const Matrix &o) |
Copia desde "o". | |
| Matrix & | move (Matrix &o) |
Traslada el valor de "o" a "*this". | |
| Matrix & | swap (Matrix &o) |
Intercambia los valores de "*this" y "o". | |
| bool | equals (const Matrix &o) const |
| ¿¿¿ (*this==o) ??? | |
| bool | same (const Matrix &o) const |
Retorna true si "o" comparte sus valores con "*this". | |
| reference | operator() (unsigned, unsigned) |
| Retorna una referencia al elemento [i,j] de la matriz. | |
| const_reference | operator() (unsigned, unsigned) const |
Retorna una referencia al elemento [i,j] de la matriz ( const ). | |
| reference | at (unsigned m, unsigned n) |
Retorna operator()(m,n). | |
| const_reference | at (unsigned m, unsigned n) const |
Retorna operator()(m,n) "const". | |
| void | reSize (unsigned, unsigned) |
| Le cambia las dimensiones a la matriz. | |
| void | reShape (unsigned, unsigned) |
| Le ajusta las dimensiones a la matriz. | |
| void | transpose () |
| Transpone la matriz. | |
Protected Member Functions | |
| void | add (const Matrix &) |
Le suma a "*this" la matriz "O". | |
| void | substract (const Matrix &) |
Le resta a "*this" la matriz "O". | |
| void | multiply (const Matrix &, const Matrix &) |
Calcula la multiplicación A * B y la almacena en "*this". | |
Private Attributes | |
| value_type * | m_val |
| Vector de valores de la matriz. | |
| unsigned | m_rows |
| Cantidad de filas de la matriz. | |
| unsigned | m_cols |
| Cantidad de columnas de la matris. | |
Friends | |
| class | test_Matrix |
| Datos de prueba para la clase. | |
| bool | operator== (const Matrix &p, const Matrix &q) |
| ¿¿¿ (p == q) ??? | |
| bool | operator!= (const Matrix &p, const Matrix &q) |
| ¿¿¿ (p != q) ??? | |
| Matrix | operator+ (const Matrix &A, const Matrix &B) |
Retorna A+B. | |
| Matrix | operator- (const Matrix &A, const Matrix &B) |
Retorna A-B. | |
| Matrix | operator* (const Matrix &A, const Matrix &B) |
Retorna A*B. | |
| template<class T > | |
| bool | check_ok (const Matrix< T > &M) |
| Verifica la invariante de la clase. | |
Esta es una clase matriz muy chirrisquitica que puede cambiar dinámicamente de tamaño.
rows() x cols() reSize().E debe incluir un neutro para la adición, cuyo valor debe poderse obtener invocando el convertidor Sparse_Matrix<E>::value_type().Matrix<E>::value_type y debe existir el valor Matrix<E>::value_type() y también Matrix<E>::value_type(1) (para matrices unitarias)Matrix<E>::operator(unsigned, unsigned) | typedef E Mx::Matrix< E >::value_type |
| typedef value_type& Mx::Matrix< E >::reference |
| typedef const value_type& Mx::Matrix< E >::const_reference |
| typedef unsigned Mx::Matrix< E >::size_type |
| Mx::Matrix< E >::Matrix | ( | unsigned | m = 1, |
| unsigned | n = 1 |
||
| ) | [inline] |
Constructor de vector.
n * m valores de la matriz"value_type" tiene un constructor de vector, lo usar para inicializar cada uno de los valores de la matriz; de lo contrario, los deja tal cual están en la memoria"value_type" es uno de los tipos escalares básicos, como lo son int o float, los valores almacenados en la matriz quedan tal cual están y no son inicializados. m * n > 0 (m > 0) && (n > 0) | Mx::Matrix< E >::Matrix | ( | const Matrix< E > & | o | ) |
| template< class E > inline Mx::Matrix< E >::Matrix | ( | const value_type | V | ) | [inline] |
| Mx::Matrix< E >::~Matrix | ( | ) | [inline] |
| unsigned Mx::Matrix< E >::rows | ( | ) | const [inline] |
| unsigned Mx::Matrix< E >::cols | ( | ) | const [inline] |
| unsigned Mx::Matrix< E >::size | ( | ) | const [inline] |
| unsigned Mx::Matrix< E >::count | ( | ) | const [inline] |
| size_type Mx::Matrix< E >::capacity | ( | ) | const [inline] |
| Matrix& Mx::Matrix< E >::operator= | ( | const Matrix< E > & | o | ) | [inline] |
| Matrix< E > & Mx::Matrix< E >::copy | ( | const Matrix< E > & | o | ) |
Copia desde "o".
"o" sobre "*this", de forma que el nuevo valor de "*this" sea un duplicado exacto del valor de "o" "*this" se pierde"o" mantiene su valor anterior"o" cambia, el de "*this" no cambiará, y viceversa, pues la copia es una copia profunda; no es superficial"*this" es "o" entonces su valor no cambia *this == o | Matrix< E > & Mx::Matrix< E >::move | ( | Matrix< E > & | o | ) |
Traslada el valor de "o" a "*this".
"*this" se pierde"*this" es el que "o" tuvo"o" queda en el estado en que lo dejaría Erase() "*this" es "o" entonces su valor no cambia (*this == o) *this | Matrix< E > & Mx::Matrix< E >::swap | ( | Matrix< E > & | o | ) | [inline] |
Intercambia los valores de "*this" y "o".
"*this" en lugar de una referencia, como ocurre con Matrix::Child(), a veces swap() no tiene el resultado esperado por el programador. T.Child(i). swap( T.Child(j) ) el resultado no es intercambiar los hijos, sino más bien intercambiar los valores de los sub-árboles temporales T.Child(i) y T.Child(j). La forma correcta de intercambiar hijos es usar Graft().1 )| bool Mx::Matrix< E >::equals | ( | const Matrix< E > & | o | ) | const |
| bool Mx::Matrix< E >::same | ( | const Matrix< E > & | o | ) | const [inline] |
| void Mx::Matrix< E >::add | ( | const Matrix< E > & | O | ) | [protected] |
Le suma a "*this" la matriz "O".
| void Mx::Matrix< E >::substract | ( | const Matrix< E > & | O | ) | [protected] |
Le resta a "*this" la matriz "O".
| void Mx::Matrix< E >::multiply | ( | const Matrix< E > & | A, |
| const Matrix< E > & | B | ||
| ) | [protected] |
Calcula la multiplicación A * B y la almacena en "*this".
"A" y "B" deben tener dimensiones compatibles A.cols() == B.rows() "A" debe ser igual a la cantidad de columnas de "B" A.cols() * B.cols() * A.cols() )| E & Mx::Matrix< E >::operator() | ( | unsigned | i, |
| unsigned | j | ||
| ) | [inline] |
| const E & Mx::Matrix< E >::operator() | ( | unsigned | i, |
| unsigned | j | ||
| ) | const [inline] |
| reference Mx::Matrix< E >::at | ( | unsigned | m, |
| unsigned | n | ||
| ) | [inline] |
| const_reference Mx::Matrix< E >::at | ( | unsigned | m, |
| unsigned | n | ||
| ) | const [inline] |
| void Mx::Matrix< E >::reSize | ( | unsigned | m, |
| unsigned | n | ||
| ) |
Le cambia las dimensiones a la matriz.
Matrix<E>::value_type(). (m * n == 0) deja la matriz vacía. | void Mx::Matrix< E >::reShape | ( | unsigned | m, |
| unsigned | n | ||
| ) | [inline] |
| void Mx::Matrix< E >::transpose | ( | ) | [inline] |
friend class test_Matrix [friend] |
Verifica la invariante de la clase.
0 (cero) al campo m_val.rows() cols() Ok()
(M.m_rows == 0) <==> (M.m_cols == 0)(M.m_rows == 0) <==> (M.m_val == 0)check_ok( m_val[k] ) value_type* Mx::Matrix< E >::m_val [private] |
unsigned Mx::Matrix< E >::m_rows [private] |
unsigned Mx::Matrix< E >::m_cols [private] |
1.7.4