Sparse Matrix. More...
#include <rsparsematrix.h>
Public Member Functions | |
virtual void | Clear (double val=NAN, bool clean=false) |
int | Compare (const RSparseMatrix &matrix) const |
RCursor< RSparseVector > | GetLines (void) const |
size_t | GetNbVectors (void) const |
virtual tType | GetType (void) const |
RSparseVector * | 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) |
RSparseMatrix & | operator= (const RSparseMatrix &matrix) |
const RSparseVector * | operator[] (size_t i) const |
RSparseVector * | operator[] (size_t i) |
RSparseMatrix (size_t nblines, size_t nbcols, bool alllines=true, size_t init=20) | |
RSparseMatrix (const RSparseMatrix &src) | |
virtual void | VerifySize (size_t newlines, size_t newcols, bool fill=false, double val=NAN) |
virtual | ~RSparseMatrix (void) |
Public Member Functions inherited from RGenericMatrix | |
virtual void | Add (size_t i, size_t j, double val) |
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< RSparseVector, true, true > | |
void | Clear (size_t m=0, size_t i=0, bool force=false) |
int | Compare (const RContainer< RSparseVector, true, true > &) const |
void | Copy (const RContainer< RSparseVector, 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 |
RSparseVector * | GetInsertPtr (const TUse &tag, size_t min=0, size_t max=0) |
RSparseVector * | GetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
RSparseVector * | GetInsertPtrAt (const TUse &tag, size_t pos) |
size_t | GetMaxNb (void) const |
size_t | GetMaxPos (void) const |
size_t | GetNb (void) const |
RSparseVector * | GetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
RSparseVector * | GetPtr (const TUse &tag, size_t min=0, size_t max=0) const |
const RSparseVector * | GetPtrAt (size_t idx) const |
RSparseVector * | GetPtrAt (size_t idx) |
RContainer< RSparseVector, 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 RSparseVector **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (RSparseVector **tab, size_t min=0, size_t max=0) |
void | InsertPtr (RSparseVector *ins, bool del=false, size_t min=0, size_t max=0) |
void | InsertPtrAt (RSparseVector *ins, size_t pos, bool del) |
void | InsertPtrAt (RSparseVector *ins, size_t pos) |
void | Inter (const iRContainer< RSparseVector > &src1, const iRContainer< RSparseVector > &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< RSparseVector, a, o > &src) |
RContainer & | operator= (const RContainer< RSparseVector, true, true > &src) |
RContainer & | operator= (const RContainer< RSparseVector, false, true > &src) |
const RSparseVector * | operator[] (size_t idx) const |
RSparseVector * | operator[] (size_t idx) |
RContainer (const RContainer< RSparseVector, true, true > &src) | |
RContainer (const RContainer< RSparseVector, 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< RSparseVector, a, o > &src) |
void | Union (const iRContainer< RSparseVector > &src1, const iRContainer< RSparseVector > &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< RSparseVector, 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
Sparse Matrix.
The RSparseMatrix provides a representation for a sparse matrix. The matrix is coded as a container of RSparseVector. The matrix can be created so that to each line a vector is always build to speed up the access.
Here is an example of code:
An important aspect is the use of static_cast<const RSparseMatrix&> to ensure the call of the const version of the operator(). If static_cast<const RSparseMatrix&> is not used, the different elements are created with uninitialized values.
Constructor & Destructor Documentation
RSparseMatrix | ( | 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 Number of columns (not the number of elements in each vector). alllines All lines have a vector. init Initial number of elements to reserve for each line.
RSparseMatrix | ( | const RSparseMatrix & | 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 RSparseMatrix & | 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 |
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<RSparseVector> GetLines | ( | void | ) | const |
Get a cursor over the vectors of the matrix.
RSparseMatrix& operator= | ( | const RSparseMatrix & | 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 Column number of the element.
Implements RGenericMatrix.
Reimplemented in RSparseSymmetricMatrix.
|
virtual |
Return a specific element of the matrix.
- Parameters
-
i Line number of the element. j Column number of the element.
Implements RGenericMatrix.
Reimplemented in RSparseSymmetricMatrix.
const RSparseVector* operator[] | ( | size_t | i | ) | const |
Return the vector at a given line from the matrix (const version).
- Parameters
-
i Line number of the vector.
RSparseVector* 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 index has a vector defined in the matrix.
- Parameters
-
i Index.
- Returns
- true or false.
RSparseVector* GetValue | ( | size_t | i | ) | const |
Get a pointer over the vector at a given index.
- Parameters
-
i Index.
- Returns
- Pointer or null if the index hasn't no vector.
Member Data Documentation
|
protected |
All lines have an entry.
|
protected |
Initial number of values to reserve for each line.