Ascending Ordered Sparse Matrix. More...
#include <rmaxmatrix.h>
Public Member Functions | |
virtual void | Add (size_t i, size_t j, double val) |
virtual void | Clear (double val=NAN, bool clean=false) |
int | Compare (const RMaxMatrix &matrix) const |
RCursor< RMaxVector > | GetLines (void) const |
size_t | GetNbVectors (void) const |
virtual tType | GetType (void) const |
RMaxVector * | GetValue (size_t i) const |
virtual void | Init (double val) |
bool | IsIn (size_t i) const |
virtual double | operator() (size_t i, size_t j) const |
virtual double & | operator() (size_t i, size_t j) |
RMaxMatrix & | operator= (const RMaxMatrix &matrix) |
const RMaxVector * | operator[] (size_t i) const |
RMaxVector * | operator[] (size_t i) |
RMaxMatrix (size_t nblines, size_t nbcols, bool alllines=true, size_t init=20) | |
RMaxMatrix (const RMaxMatrix &src) | |
virtual void | VerifySize (size_t newlines, size_t newcols, bool fill=false, double val=NAN) |
virtual | ~RMaxMatrix (void) |
Public Member Functions inherited from RGenericMatrix | |
int | Compare (const RGenericMatrix &matrix) const |
size_t | GetNbCols (void) const |
size_t | GetNbLines (void) const |
RGenericMatrix & | operator= (const RGenericMatrix &matrix) |
template<class S > | |
void | Print (S &stream, const RString &name, const char *format="%E", size_t colsize=12) const |
RGenericMatrix (size_t size) | |
RGenericMatrix (size_t lines, size_t cols) | |
RGenericMatrix (const RGenericMatrix &matrix) | |
virtual | ~RGenericMatrix (void) |
Protected Attributes | |
bool | AllLines |
size_t | InitNbCols |
Protected Attributes inherited from RGenericMatrix | |
size_t | NbCols |
size_t | NbLines |
Protected Attributes inherited from iRContainer< C > | |
size_t | IncPtr |
size_t | LastPtr |
size_t | MaxPtr |
size_t | NbPtr |
C ** | Tab |
Additional Inherited Members | |
Public Types inherited from RGenericMatrix | |
enum | tType { tNormal, tDiagonal, tLowerTriangular, tUpperTriangular, tSymmetric, tSparse, tSparseSymmetric, tMax } |
Protected Member Functions inherited from RContainer< RMaxVector, true, true > | |
void | Clear (size_t m=0, size_t i=0, bool force=false) |
int | Compare (const RContainer< RMaxVector, true, true > &) const |
void | Copy (const RContainer< RMaxVector, a, true > &src) |
void | DeletePtr (const TUse &tag, bool sortkey, bool del, size_t min=0, size_t max=0) |
void | DeletePtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
void | DeletePtr (const TUse &tag, size_t min=0, size_t max=0) |
void | DeletePtrAt (size_t pos, bool shift, bool del) |
void | DeletePtrAt (size_t pos, bool shift) |
void | DeletePtrAt (size_t pos) |
void | Exchange (size_t pos1, size_t pos2) |
size_t | GetIncNb (void) const |
size_t | GetIndex (const TUse &tag, bool &find, size_t min=0, size_t max=0) const |
RMaxVector * | GetInsertPtr (const TUse &tag, size_t min=0, size_t max=0) |
RMaxVector * | GetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
RMaxVector * | GetInsertPtrAt (const TUse &tag, size_t pos) |
size_t | GetMaxNb (void) const |
size_t | GetMaxPos (void) const |
size_t | GetNb (void) const |
RMaxVector * | GetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
RMaxVector * | GetPtr (const TUse &tag, size_t min=0, size_t max=0) const |
const RMaxVector * | GetPtrAt (size_t idx) const |
RMaxVector * | GetPtrAt (size_t idx) |
RContainer< RMaxVector, false, true > * | GetPtrs (const TUse &tag, size_t min=0, size_t max=0) const |
size_t | GetTab (const void **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (void **tab, size_t min=0, size_t max=0) |
size_t | GetTab (const RMaxVector **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (RMaxVector **tab, size_t min=0, size_t max=0) |
void | InsertPtr (RMaxVector *ins, bool del=false, size_t min=0, size_t max=0) |
void | InsertPtrAt (RMaxVector *ins, size_t pos, bool del) |
void | InsertPtrAt (RMaxVector *ins, size_t pos) |
void | Inter (const iRContainer< RMaxVector > &src1, const iRContainer< RMaxVector > &src2) |
bool | IsIn (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
bool | IsIn (const TUse &tag, size_t min=0, size_t max=0) const |
RContainer & | operator+= (const RContainer< RMaxVector, a, o > &src) |
RContainer & | operator= (const RContainer< RMaxVector, true, true > &src) |
RContainer & | operator= (const RContainer< RMaxVector, false, true > &src) |
const RMaxVector * | operator[] (size_t idx) const |
RMaxVector * | operator[] (size_t idx) |
RContainer (const RContainer< RMaxVector, true, true > &src) | |
RContainer (const RContainer< RMaxVector, false, true > &src) | |
RContainer (size_t m, size_t i=0) | |
void | ReOrder (int sortOrder(const void *, const void *)) |
void | ReOrder (int sortOrder(const void *, const void *), size_t min, size_t max) |
void | ReOrder (void) |
void | Shift (size_t idx, bool reverse) |
void | Transfer (RContainer< RMaxVector, a, o > &src) |
void | Union (const iRContainer< RMaxVector > &src1, const iRContainer< RMaxVector > &src2) |
bool | VerifyIndex (size_t idx) const |
void | VerifyTab (size_t max=0) |
virtual | ~RContainer (void) |
Protected Member Functions inherited from iRContainer< C > | |
iRContainer & | Add (const iRContainer< C > &src) |
void | Create (const iRContainer< C > &src) |
void | DeepCopy (const iRContainer< C > &src) |
iRContainer & | NormalCopy (const iRContainer< C > &src) |
void | Clear (size_t m=0, size_t i=0, bool force=false) |
void | Copy (const iRContainer< C > &src) |
void | DeletePtr (const TUse &tag, bool sortkey, bool del, size_t min=0, size_t max=0) |
void | DeletePtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
void | DeletePtr (const TUse &tag, size_t min=0, size_t max=0) |
void | DeletePtrAt (size_t pos, bool shift) |
void | DeletePtrAt (size_t pos) |
void | DeletePtrAt (size_t pos, bool shift, bool del) |
void | Exchange (size_t pos1, size_t pos2) |
size_t | GetIncNb (void) const |
size_t | GetIndex (const TUse &tag, bool &find, size_t min=0, size_t max=0) const |
size_t | GetIndex (bool order, const TUse &tag, bool &find, size_t min=0, size_t max=0) const |
C * | GetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
C * | GetInsertPtr (const TUse &tag, size_t min=0, size_t max=0) |
C * | GetInsertPtrAt (const TUse &tag, size_t pos) |
size_t | GetMaxNb (void) const |
size_t | GetMaxPos (void) const |
size_t | GetNb (void) const |
C * | GetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
C * | GetPtr (const TUse &tag, size_t min=0, size_t max=0) const |
const C * | GetPtrAt (size_t idx) const |
C * | GetPtrAt (size_t idx) |
size_t | GetTab (const C **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (C **tab, size_t min=0, size_t max=0) |
size_t | GetTab (const void **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (void **tab, size_t min=0, size_t max=0) |
void | InsertPtr (C *ins, bool del=false, size_t min=0, size_t max=0) |
void | InsertPtrAt (C *ins, size_t pos, bool del) |
void | InsertPtrAt (C *ins, size_t pos) |
void | Inter (const iRContainer< C > &src1, const iRContainer< C > &src2) |
bool | IsIn (const TUse &tag, size_t min=0, size_t max=0) const |
bool | IsIn (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
iRContainer & | operator+= (const iRContainer< C > &src) |
iRContainer & | operator= (const iRContainer< C > &src) |
const C * | operator[] (size_t idx) const |
C * | operator[] (size_t idx) |
void | ReOrder (int sortOrder(const void *, const void *), size_t min, size_t max) |
void | ReOrder (int sortOrder(const void *, const void *)) |
void | ReOrder (void) |
void | Shift (size_t idx, bool reverse) |
void | Transfer (iRContainer< C > &src) |
void | Union (const iRContainer< C > &src1, const iRContainer< C > &src2) |
bool | VerifyIndex (size_t idx) const |
void | VerifyTab (size_t max=0) |
virtual | ~iRContainer (void) |
Static Protected Member Functions inherited from RContainer< RMaxVector, true, true > | |
static int | SortOrder (const void *a, const void *b) |
Static Protected Member Functions inherited from iRContainer< C > | |
static int | SortOrder (const void *a, const void *b) |
Detailed Description
Ascending Ordered Sparse Matrix.
The RMaxMatrix provides a representation for a sparse ordered matrix. The matrix is coded as a container of RMaxVector. To speed up the access, a vector can be build for every line of the matrix.
Here is an example of code:
The number of of the columns of the matrix is fixed (but can be changed). It represents the maximal number of elements per line. Of course, an identifier can be greater than a column index (see example). The following code will generate an exception since the matrix a is of size .
An important aspect is the use of static_cast<const RMaxMatrix&> to ensure the call of the const version of the operator(). If static_cast<const RMaxMatrix&> is not used, the different elements are created with uninitialized values.
Constructor & Destructor Documentation
RMaxMatrix | ( | size_t | nblines, |
size_t | nbcols, | ||
bool | alllines = true , |
||
size_t | init = 20 |
||
) |
Construct a sparse matrix.
- Parameters
-
nblines Number of lines (not the number of vectors). nbcols Maximal number of values for each line. alllines All lines have a vector. init Initial number of elements to reserve for each line.
RMaxMatrix | ( | const RMaxMatrix & | src | ) |
Copy constructor of a sparse matrix.
- Parameters
-
src Sparse matrix used as source.
|
virtual |
Destruct the sparse matrix.
Member Function Documentation
int Compare | ( | const RMaxMatrix & | matrix | ) | const |
|
virtual |
Clear the matrix. All the elements are removed.
- Parameters
-
val Value eventually used to assign to the elements (not used for sparse matrix). clean Clean eventually only the memory.
Reimplemented from RGenericMatrix.
|
virtual |
Initialize the matrix with a given value. It uses the operator(i,j) to initialize the different elements.
- Parameters
-
val Value to assign.
Reimplemented from RGenericMatrix.
|
virtual |
Verify if the matrix has a given size, and increase them if necessary.
- Parameters
-
newlines New line number. newcols New column number. fill Elements must be filled with a value (Not used for sparse matrix). val Value used eventually to fill the elements created (Not used for sparse matrix).
Implements RGenericMatrix.
|
virtual |
Get the type of the matrix.
Implements RGenericMatrix.
size_t GetNbVectors | ( | void | ) | const |
Get the number of vectors contained in the matrix. If the matrix does not create a vector for each line, the number of vectors does not correspond to the number of lines of the matrix.
RCursor<RMaxVector> GetLines | ( | void | ) | const |
Get a cursor over the vectors of the matrix.
RMaxMatrix& operator= | ( | const RMaxMatrix & | matrix | ) |
The assignment operator.
- Parameters
-
matrix Sparse Matrix used as source.
|
virtual |
Return a specific element of the matrix (const version).
- Parameters
-
i Line number of the element. j Index of the element.
Implements RGenericMatrix.
|
virtual |
Return a specific element of the matrix. This function cannot be used with RMaxMatrix.
- Parameters
-
i Line number of the element. j Index of the element.
Implements RGenericMatrix.
|
virtual |
Add a value associated to a given line and identifier into the matrix. If the number of elements for that line equals the size of the matrix, the value is only inserted if another value of that line is smaller (this latest value will then be removed).
- Parameters
-
i Line number of the element. j Identifier of the element. val Value to add.
Reimplemented from RGenericMatrix.
const RMaxVector* operator[] | ( | size_t | i | ) | const |
Return the vector at a given line from the matrix (const version).
- Parameters
-
i Line number of the vector.
RMaxVector* operator[] | ( | size_t | i | ) |
Return the vector at a given line from the matrix.
- Parameters
-
i Line number of the vector.
bool IsIn | ( | size_t | i | ) | const |
Verify if a given identifier has a vector defined in the matrix.
- Parameters
-
i Identifier.
- Returns
- true or false.
RMaxVector* GetValue | ( | size_t | i | ) | const |
Get a pointer over the vector associated with a given identifier.
- Parameters
-
i Identifier.
- Returns
- Pointer or null if the identifier hasn't no vector.
Member Data Documentation
|
protected |
All lines have an entry.
|
protected |
Initial number of values to reserve for each line.