|
Abstract non Polymorphyc Matrix:
|
Chirrisquitica matrix stored as a sparse matrix implemented with lists. More...
#include <Matrix_List.h>
Public Types | |
| typedef E | value_type |
| Type of the stored object, similar to the name used in the STL. | |
| typedef value_type & | reference |
| Reference to the stored object, similar to the name used in the STL. | |
| typedef const value_type & | const_reference |
| Reference [const] to the stored object, similar to the name used in the STL. | |
Public Member Functions | |
| Matrix_List (unsigned m=1, unsigned n=1) | |
| Vector constructor. | |
| Matrix_List (const Matrix_List &o) | |
| Copy constructor. | |
| Matrix_List (const E &V) | |
| Scalar constructor. | |
| ~Matrix_List () | |
| Destructor. | |
| unsigned | rows () const |
| Number of rows in the matrix. | |
| unsigned | cols () const |
| Number of columns in the matrix. | |
| unsigned | size () const |
| Number of values stored in the matrix. | |
| unsigned | count () const |
Sinonim of size(). | |
| unsigned | capacity () const |
| Maximum number of values that can be stored in the matrix. | |
| Matrix_List & | operator= (const Matrix_List &o) |
| Matrix_List & | copy (const Matrix_List &o) |
Copies from "M". | |
| Matrix_List & | move (Matrix_List &o) |
Moves the value from "M" into "*this". | |
| Matrix_List & | swap (Matrix_List &o) |
Interchanges the values of "*this" and "M". | |
| void | clear () |
Leaves "*this" with the value the vector constructor initializes it to. | |
| bool | equals (const Matrix_List &o) const |
| ¿¿¿ A == B ??? | |
| E & | operator() (unsigned, unsigned) |
Returns a reference to element [i][j] in the matrix. | |
| const E & | operator() (unsigned, unsigned) const |
Returns a const reference to element [i][j] in the matrix [CONST]. | |
| E & | at (unsigned i, unsigned j) |
Returns a reference to element [i][j] in the matrix. | |
| const E & | at (unsigned i, unsigned j) const |
Returns a const reference to element [i][j] in the matrix [CONST]. | |
| void | reShape (unsigned m, unsigned n) |
| Reshapes the dimensions for the matrix. | |
| void | reSize (unsigned m, unsigned n) |
| Changes the dimensions for the matrix. | |
| void | transpose () |
| Transforms the matrix into its transpose. | |
| void | setDefault (const E &same) |
| Defines which is the most common value stored in the matrix. | |
| const E & | getDefault () |
| Gets the most common value stored in the matrix. | |
| bool | same (const Matrix_BASE &M) const |
Returns true if "M" shares its value with "*this". | |
Protected Member Functions | |
| Matrix_BASE & | copy (const Matrix_BASE &M) |
Copies from "M". | |
| Matrix_BASE & | move (Matrix_BASE &M) |
Moves the value from "M" into "*this". | |
| Matrix_BASE & | swap (Matrix_BASE &M) |
Interchanges the values of "*this" and "M". | |
| bool | equals (const Matrix_BASE &M) const |
| ¿¿¿ A == B ??? | |
Private Member Functions | |
| void | reserve (unsigned n) |
| Adjust the matrix so that it can store at least values different than getDefault(). | |
| void | reSize (unsigned newsize) |
Private Attributes | |
| std::vector< std::list < Matrix_List_ColVal< E > > > | m_VL |
| Vector where the column list values are stored. | |
| unsigned | m_cols |
| Number of columns in the matrix. | |
| E | m_same |
Most common value stored in the Matrix_List. | |
Friends | |
| class | test_Matrix |
| BUnit test. | |
| template<class T > | |
| bool | check_ok (const Matrix_List< T > &M) |
| template<class MAT > | |
| bool | check_ok_Matrix (const MAT &M) |
Generic verification of the class invariant check_ok(). | |
| template<class MAT > | |
| bool | check_ok_Matrix (const MAT &M) |
Generic verification of the class invariant check_ok(). | |
| 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 > | |
| 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. | |
Chirrisquitica matrix stored as a sparse matrix implemented with lists.
n * m matrix values."value_type" is one of the basic scalar types, as int or float, the stored values in the matrix will not be initialized to zero."m" or "n" is zero, the matrix is empty. Definition at line 69 of file Matrix_List.h.
Mx::Matrix_BASE< E >::value_type [inherited] |
Type of the stored object, similar to the name used in the STL.
Definition at line 47 of file Matrix_BASE.h.
Mx::Matrix_BASE< E >::reference [inherited] |
Reference to the stored object, similar to the name used in the STL.
Definition at line 48 of file Matrix_BASE.h.
Mx::Matrix_BASE< E >::const_reference [inherited] |
Reference [const] to the stored object, similar to the name used in the STL.
Definition at line 49 of file Matrix_BASE.h.
| Mx::Matrix_List< E >::Matrix_List | ( | unsigned | m = 1, |
| unsigned | n = 1 |
||
| ) |
Vector constructor.
n * m matrix values."value_type" is one of the basic scalar types, as int or float, the stored values in the matrix will not be initialized to zero."m" or "n" is zero, the matrix is empty. Definition at line 221 of file Matrix_List.h.
| Mx::Matrix_List< E >::Matrix_List | ( | const Matrix_List< E > & | o | ) | [inline] |
Copy constructor.
Definition at line 235 of file Matrix_List.h.
| Mx::Matrix_List< E >::Matrix_List | ( | const E & | V | ) | [inline] |
Scalar constructor.
"V". Definition at line 74 of file Matrix_List.h.
| Mx::Matrix_List< E >::~Matrix_List | ( | ) | [inline] |
Destructor.
Definition at line 241 of file Matrix_List.h.
| unsigned Mx::Matrix_List< E >::rows | ( | ) | const [inline] |
Number of rows in the matrix.
Reimplemented from Mx::Matrix_BASE< E >.
Definition at line 79 of file Matrix_List.h.
| unsigned Mx::Matrix_List< E >::cols | ( | ) | const [inline] |
Number of columns in the matrix.
Reimplemented from Mx::Matrix_BASE< E >.
Definition at line 80 of file Matrix_List.h.
| unsigned Mx::Matrix_List< E >::size | ( | ) | const [inline] |
Number of values stored in the matrix.
Reimplemented from Mx::Matrix_BASE< E >.
Definition at line 81 of file Matrix_List.h.
| unsigned Mx::Matrix_List< E >::count | ( | ) | const [inline] |
Sinonim of size().
Reimplemented from Mx::Matrix_BASE< E >.
Definition at line 82 of file Matrix_List.h.
| unsigned Mx::Matrix_List< E >::capacity | ( | ) | const [inline] |
Maximum number of values that can be stored in the matrix.
Reimplemented from Mx::Matrix_BASE< E >.
Definition at line 83 of file Matrix_List.h.
| Matrix_List& Mx::Matrix_List< E >::operator= | ( | const Matrix_List< E > & | o | ) | [inline] |
Definition at line 85 of file Matrix_List.h.
| Matrix_List< E > & Mx::Matrix_List< E >::copy | ( | const Matrix_List< E > & | o | ) |
Copies from "M".
"M" into "*this" in such a way that the new valuer for "*this" is an exact duplicate of the value in "M"."*this" is lost."M" maintains its value."M" changes, the value for "*this" will not change, and viceversa, because the copy is a deep copy; it is not supperficial."*this" is "M" its value will not change. *this == M ."*this" Definition at line 251 of file Matrix_List.h.
| Matrix_List< E > & Mx::Matrix_List< E >::move | ( | Matrix_List< E > & | o | ) |
Moves the value from "M" into "*this".
"*this" is lost."*this" is what was stored in "M"."M" remains in the state an object will have after being initialized by the vector contructor."*this" is "M" its value will not change. (*this == M) ."*this" Definition at line 263 of file Matrix_List.h.
| Matrix_List< E > & Mx::Matrix_List< E >::swap | ( | Matrix_List< E > & | o | ) |
Interchanges the values of "*this" and "M".
"*this" Definition at line 283 of file Matrix_List.h.
| void Mx::Matrix_List< E >::clear | ( | ) |
Leaves "*this" with the value the vector constructor initializes it to.
Reimplemented from Mx::Matrix_BASE< E >.
Definition at line 292 of file Matrix_List.h.
| bool Mx::Matrix_List< E >::equals | ( | const Matrix_List< E > & | o | ) | const [inline] |
¿¿¿ A == B ???
Definition at line 245 of file Matrix_List.h.
| E & Mx::Matrix_List< E >::operator() | ( | unsigned | i, |
| unsigned | j | ||
| ) | [inline] |
Returns a reference to element [i][j] in the matrix.
M(i,j) means what in arrays is M[i][j].M(i,j) = val; // M(i,j) is un "lvalue" (mutable) Reimplemented from Mx::Matrix_BASE< E >.
Definition at line 393 of file Matrix_List.h.
| const E & Mx::Matrix_List< E >::operator() | ( | unsigned | i, |
| unsigned | j | ||
| ) | const [inline] |
Returns a const reference to element [i][j] in the matrix [CONST].
M(i,j) means what in arrays is M[i][j].val = M(i,j); // M(i,j) is a "rvalue" (const) Reimplemented from Mx::Matrix_BASE< E >.
Definition at line 347 of file Matrix_List.h.
| E& Mx::Matrix_List< E >::at | ( | unsigned | i, |
| unsigned | j | ||
| ) | [inline] |
Returns a reference to element [i][j] in the matrix.
[i][j] exists in the matrix.[i][j] is out of range throws exception std::out_of_range.M.at(i,j) = val; // M.at(i,j) is un "lvalue" (mutable) Reimplemented from Mx::Matrix_BASE< E >.
Definition at line 95 of file Matrix_List.h.
| const E& Mx::Matrix_List< E >::at | ( | unsigned | i, |
| unsigned | j | ||
| ) | const [inline] |
Returns a const reference to element [i][j] in the matrix [CONST].
[i][j] exists in the matrix.[i][j] is out of range throws exception std::out_of_range.val = M.at(i,j); // M.at(i,j) is a "rvalue" (const) Reimplemented from Mx::Matrix_BASE< E >.
Definition at line 96 of file Matrix_List.h.
| void Mx::Matrix_List< E >::reShape | ( | unsigned | m, |
| unsigned | n | ||
| ) |
Reshapes the dimensions for the matrix.
Resize(m,n).Reimplemented from Mx::Matrix_BASE< E >.
Definition at line 339 of file Matrix_List.h.
| void Mx::Matrix_List< E >::reSize | ( | unsigned | m, |
| unsigned | n | ||
| ) |
Changes the dimensions for the matrix.
(m*n == 0) the matrix becomes empty. Reimplemented from Mx::Matrix_BASE< E >.
Definition at line 301 of file Matrix_List.h.
| void Mx::Matrix_List< E >::transpose | ( | ) |
Transforms the matrix into its transpose.
Reimplemented from Mx::Matrix_BASE< E >.
| void Mx::Matrix_List< E >::setDefault | ( | const E & | same | ) | [inline] |
Defines which is the most common value stored in the matrix.
same as the most common value.same != getDefault() the matrix becomes empty as if clear() had been invoked for it. Reimplemented from Mx::Matrix_BASE< E >.
Definition at line 421 of file Matrix_List.h.
| const E & Mx::Matrix_List< E >::getDefault | ( | ) | [inline] |
Gets the most common value stored in the matrix.
Reimplemented from Mx::Matrix_BASE< E >.
Definition at line 415 of file Matrix_List.h.
| Mx::Matrix_List< E >::reserve | ( | unsigned | n | ) | [private] |
Adjust the matrix so that it can store at least
values different than getDefault().
| void Mx::Matrix_List< E >::reSize | ( | unsigned | newsize | ) | [private] |
| Matrix_BASE< E > & Mx::Matrix_BASE< E >::copy | ( | const Matrix_BASE< E > & | M | ) | [protected, inherited] |
Copies from "M".
"M" into "*this" in such a way that the new valuer for "*this" is an exact duplicate of the value in "M"."*this" is lost."M" maintains its value."M" changes, the value for "*this" will not change, and viceversa, because the copy is a deep copy; it is not supperficial."*this" is "M" its value will not change. *this == M ."*this" | Matrix_BASE< E > & Mx::Matrix_BASE< E >::move | ( | Matrix_BASE< E > & | M | ) | [protected, inherited] |
Moves the value from "M" into "*this".
"*this" is lost."*this" is what was stored in "M"."M" remains in the state an object will have after being initialized by the vector contructor."*this" is "M" its value will not change. (*this == M) ."*this" | Matrix_BASE< E > & Mx::Matrix_BASE< E >::swap | ( | Matrix_BASE< E > & | M | ) | [protected, inherited] |
Interchanges the values of "*this" and "M".
"*this" | bool Mx::Matrix_BASE< E >::same | ( | const Matrix_BASE< E > & | M | ) | const [inline, inherited] |
Returns true if "M" shares its value with "*this".
Definition at line 68 of file Matrix_BASE.h.
| bool Mx::Matrix_BASE< E >::equals | ( | const Matrix_BASE< E > & | M | ) | const [protected, inherited] |
¿¿¿ A == B ???
friend class test_Matrix [friend] |
(m_cols == 0) <==> (m_VL.empty())check_ok( M.m_same ) Definition at line 187 of file Matrix_List.h.
Generic verification of the class invariant check_ok().
Ok()
&M != 0 .(M.rows() == 0) <==> (M.cols() == 0)check_ok( M(i,j) ) Definition at line 140 of file Matrix_BASE.h.
Generic verification of the class invariant check_ok().
Ok()
&M != 0 .(M.rows() == 0) <==> (M.cols() == 0)check_ok( M(i,j) ) Definition at line 140 of file Matrix_BASE.h.
| MAT operator+ | ( | const Matrix_BASE< typename MAT::value_type > & | A, |
| const MAT & | B | ||
| ) | [friend, inherited] |
A+B
Definition at line 368 of file Matrix_BASE.h.
| MAT operator- | ( | const Matrix_BASE< typename MAT::value_type > & | A, |
| const MAT & | B | ||
| ) | [friend, inherited] |
A-B
Definition at line 448 of file Matrix_BASE.h.
| MAT operator* | ( | const Matrix_BASE< typename MAT::value_type > & | A, |
| const MAT & | B | ||
| ) | [friend, inherited] |
Res=A*B
Definition at line 454 of file Matrix_BASE.h.
| bool operator== | ( | const Matrix_BASE< typename MAT::value_type > & | A, |
| const MAT & | B | ||
| ) | [friend, inherited] |
¿¿¿ (A == B) ???
Definition at line 460 of file Matrix_BASE.h.
| bool operator!= | ( | const Matrix_BASE< typename MAT::value_type > & | A, |
| const MAT & | B | ||
| ) | [friend, inherited] |
¿¿¿ (A != B) ???
Definition at line 466 of file Matrix_BASE.h.
Default implementation for Matrix_BASE<E>::count()
Definition at line 167 of file Matrix_BASE.h.
Default implementation for Matrix_BASE<E>::clear()
Definition at line 178 of file Matrix_BASE.h.
| bool equals_Matrix | ( | const MAT & | A, |
| const MAT & | B | ||
| ) | [friend, inherited] |
Default implementation for Matrix_BASE<E>::operator==()
Definition at line 190 of file Matrix_BASE.h.
| void add_Matrix | ( | MAT & | Res, |
| const MAT & | M | ||
| ) | [friend, inherited] |
Default implementation for operator+( Matrix_BASE<E>&, Matrix_BASE<E> )
Matrix_BASE<E> operator+( Matrix_BASE<E>&, Matrix_BASE<E> ) .Definition at line 239 of file Matrix_BASE.h.
| void substract_Matrix | ( | MAT & | Res, |
| const MAT & | M | ||
| ) | [friend, inherited] |
Default implementation for operator-( Matrix_BASE<E>&, Matrix_BASE<E> )
Definition at line 259 of file Matrix_BASE.h.
| void multiply_Matrix | ( | MAT & | Res, |
| const MAT & | A, | ||
| const MAT & | B | ||
| ) | [friend, inherited] |
Calculates the multiplication A * B and stores the result in "Res".
"*this" get adjusted such that: Res.rows() == A.rows() && Res.cols() == B.cols() Matrix_BASE<E> operator*() ."A" y "B" must have compatible dimensions. A.cols() == B.rows() ."A" must be equal to the number of columns of "B". A.cols() * B.cols() * A.cols() ) Definition at line 307 of file Matrix_BASE.h.
| MAT::reference at_Matrix | ( | MAT & | M, |
| unsigned | i, | ||
| unsigned | j | ||
| ) | [friend, inherited] |
Default implementation for Matrix_BASE<E>::at()
Definition at line 335 of file Matrix_BASE.h.
| MAT::const_reference at_Matrix | ( | const MAT & | M, |
| unsigned | i, | ||
| unsigned | j | ||
| ) | [friend, inherited] |
Default implementation for Matrix_BASE<E>::at() const.
Definition at line 354 of file Matrix_BASE.h.
Mx::Matrix_List< E >::m_VL [private] |
Vector where the column list values are stored.
Definition at line 108 of file Matrix_List.h.
Mx::Matrix_List< E >::m_cols [private] |
Number of columns in the matrix.
Definition at line 109 of file Matrix_List.h.
Mx::Matrix_List< E >::m_same [private] |
Most common value stored in the Matrix_List.
Definition at line 110 of file Matrix_List.h.
1.8.0