Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
sparseMatrix.h
1 #ifndef SPARSEMATRIX_H
2 #define SPARSEMATRIX_H
3 
4 #include "transitionStructure.h"
5 
15 {
16 
17 private:
18  // specific variables of the class
19  int* _nbElts;
20  int** _elts;
21  double** _vals;
22  bool _debug;
24 public:
25  // constructors
32  sparseMatrix(int size);
33 
34  // destructor
38  ~sparseMatrix();
39 
40 public:
55  bool setEntry(int row, int col, double val); // set A[i,j]
63  double getEntry(int,int); // get A[i,j]
70  int getNbElts(int row); // get the number of entries in row i
77  int getCol(int row, int numCol ); // get the jth column for row i
84  double getEntryByCol(int row, int numCol); // get the value in the jth column for row i
91  discreteDistribution* getTransDistrib(int row); // transitions from some state
98  double rowSum(int row);
106  void evaluateMeasure(double* m, double* res);
121  void evaluateValue(double* v, double* res);
122 
123 public:
130  sparseMatrix* copy();
139 
140  public:
149  void write(FILE* out, std::string format);
150 
151  // methods specific to this class
160  bool addToEntry(int row, int col, double val); // add to A[i,j]
161 
162 private:
163  // specific technical methods
175  int consolidate(int i, int* destinations, double* values);
176 };
177 
178 #endif // SPARSEMATRIX_H
void evaluateMeasure(double *m, double *res)
Sparse vector/matrix multiplication. The result is stored in an array that must be already allocated...
Definition: sparseMatrix.cpp:278
double rowSum(int row)
Summing a row.
Definition: sparseMatrix.cpp:265
sparseMatrix(int size)
Standard constructor for sparse matrices. The internal structures are initialized. The result is the null matrix.
Definition: sparseMatrix.cpp:24
int getCol(int row, int numCol)
Retrieving an low-level entry from the matrix.
Definition: sparseMatrix.cpp:183
bool setEntry(int row, int col, double val)
Inserting an element in the matrix. IMPORTANT NOTE: there is no check for the existence of the column...
Definition: sparseMatrix.cpp:74
void write(FILE *out, std::string format)
Writing a sparse matrix to a file. Several formats could be chosen. Supported formats are: "Ers"...
Definition: sparseMatrix.cpp:388
discreteDistribution * getTransDistrib(int row)
Retrieving the transitions from some state as a discrete distribution.
Definition: sparseMatrix.cpp:215
sparseMatrix * uniformize()
Sparse matrix uniformization. Returns a sparse matrix and sets the uniformization factor...
Definition: sparseMatrix.cpp:340
int getNbElts(int row)
Retrieving a the number of elements on some row.
Definition: sparseMatrix.cpp:166
sparseMatrix * copy()
Sparse matrix copy. This is a straightforward copy. No optimization is performed, viz replicated colu...
Definition: sparseMatrix.cpp:322
~sparseMatrix()
Destructor of the class.
Definition: sparseMatrix.cpp:58
double getEntry(int, int)
Retrieving an entry from the matrix. Takes into account the fact that columns may be replicated: the ...
Definition: sparseMatrix.cpp:151
Abstract class for transition structures. These are structures which describe transitions to one stat...
Definition: transitionStructure.h:17
void evaluateValue(double *v, double *res)
Sparse vector/matrix multiplication. The result is stored in an array that must be already allocated...
Definition: sparseMatrix.cpp:311
bool addToEntry(int row, int col, double val)
Adding a value to an element to the matrix.
Definition: sparseMatrix.cpp:106
Class sparseMatrix: implementation of a transition structure using the sparse matrix data structure...
Definition: sparseMatrix.h:14
int size()
Read accessor for the size of the state space.
Definition: transitionStructure.h:41
The general discrete distribution with finite support.
Definition: discreteDistribution.h:25
double getEntryByCol(int row, int numCol)
Retrieving an low-level entry from the matrix.
Definition: sparseMatrix.cpp:199