This class defines a simple data structure for a flat 2-dim square matrix whose entries are stored in a single array. More...
#include <flatmatr.h>
Classes | |
class | const_row |
The class that represents a constant single row of the matrix. More... | |
class | row |
The class that represents a single row of the matrix. More... | |
Public Member Functions | |
flatMatrix (int size) | |
The main constructor. | |
flatMatrix (const flatMatrix< element > &M) | |
The copy constructor which copies all the entries of the matrix. | |
flatMatrix & | operator= (const flatMatrix< element > &M) |
The assignment operator. | |
~flatMatrix () | |
The destructor which deallocates the memory. | |
row | operator[] (int i) |
Returns a row of the matrix. | |
const_row | operator[] (int i) const |
Returns a constant row of the matrix. | |
void | clear (const element &elem) |
Clears all the entries of the matrix with the provided value. | |
void | swap (flatMatrix< element > &M) |
Swaps the memory of two flat matrices. | |
const element * | memory () const |
Returns the address of the memory buffer with the elements of the matrix for reading only. | |
element * | memory () |
Returns the address of the memory buffer with the elements of the matrix for reading and writing. | |
Protected Attributes | |
int | n |
The size of the matrix. | |
element * | tab |
The array of elements. |
This class defines a simple data structure for a flat 2-dim square matrix whose entries are stored in a single array.
Additional classes for a row and a constant row are defined within this class which allow to use the usual double indexing to get to the entries of the matrix, both for reading only and for modifying the entries, e.g., M[0][1].
Definition at line 55 of file flatmatr.h.
chomp::homology::flatMatrix< element >::flatMatrix | ( | int | size | ) | [inline] |
chomp::homology::flatMatrix< element >::flatMatrix | ( | const flatMatrix< element > & | M | ) | [inline] |
The copy constructor which copies all the entries of the matrix.
Definition at line 64 of file flatmatr.h.
References chomp::homology::flatMatrix< element >::n, and chomp::homology::flatMatrix< element >::tab.
chomp::homology::flatMatrix< element >::~flatMatrix | ( | ) | [inline] |
The destructor which deallocates the memory.
Definition at line 86 of file flatmatr.h.
References chomp::homology::flatMatrix< element >::tab.
{delete [] tab;}
void chomp::homology::flatMatrix< element >::clear | ( | const element & | elem | ) | [inline] |
Clears all the entries of the matrix with the provided value.
Definition at line 139 of file flatmatr.h.
References chomp::homology::flatMatrix< element >::n, and chomp::homology::flatMatrix< element >::tab.
element* chomp::homology::flatMatrix< element >::memory | ( | ) | [inline] |
Returns the address of the memory buffer with the elements of the matrix for reading and writing.
Definition at line 165 of file flatmatr.h.
References chomp::homology::flatMatrix< element >::tab.
{return tab;}
const element* chomp::homology::flatMatrix< element >::memory | ( | ) | const [inline] |
Returns the address of the memory buffer with the elements of the matrix for reading only.
Definition at line 161 of file flatmatr.h.
References chomp::homology::flatMatrix< element >::tab.
{return tab;}
flatMatrix& chomp::homology::flatMatrix< element >::operator= | ( | const flatMatrix< element > & | M | ) | [inline] |
The assignment operator.
It is permitted only for matrices of the same size. It copies all the entries of the matrix.
Definition at line 75 of file flatmatr.h.
References chomp::homology::flatMatrix< element >::n, and chomp::homology::flatMatrix< element >::tab.
row chomp::homology::flatMatrix< element >::operator[] | ( | int | i | ) | [inline] |
Returns a row of the matrix.
Definition at line 110 of file flatmatr.h.
References chomp::homology::flatMatrix< element >::n, and chomp::homology::flatMatrix< element >::tab.
const_row chomp::homology::flatMatrix< element >::operator[] | ( | int | i | ) | const [inline] |
Returns a constant row of the matrix.
Definition at line 135 of file flatmatr.h.
References chomp::homology::flatMatrix< element >::n, and chomp::homology::flatMatrix< element >::tab.
void chomp::homology::flatMatrix< element >::swap | ( | flatMatrix< element > & | M | ) | [inline] |
Swaps the memory of two flat matrices.
Definition at line 148 of file flatmatr.h.
References chomp::homology::flatMatrix< element >::n, and chomp::homology::flatMatrix< element >::tab.
int chomp::homology::flatMatrix< element >::n [protected] |
The size of the matrix.
Definition at line 169 of file flatmatr.h.
Referenced by chomp::homology::flatMatrix< element >::clear(), chomp::homology::flatMatrix< element >::flatMatrix(), chomp::homology::flatMatrix< element >::operator=(), chomp::homology::flatMatrix< element >::operator[](), and chomp::homology::flatMatrix< element >::swap().
element* chomp::homology::flatMatrix< element >::tab [protected] |
The array of elements.
Definition at line 172 of file flatmatr.h.
Referenced by chomp::homology::flatMatrix< element >::clear(), chomp::homology::flatMatrix< element >::flatMatrix(), chomp::homology::flatMatrix< element >::memory(), chomp::homology::flatMatrix< element >::operator=(), chomp::homology::flatMatrix< element >::operator[](), chomp::homology::flatMatrix< element >::swap(), and chomp::homology::flatMatrix< element >::~flatMatrix().