Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
|
Class sparseMatrix: implementation of a transition structure using the sparse matrix data structure. Elements of the transition structure (matrix) are stored by row, using two arrays containing indices of columns, and values of entries. A priori, only non-zero entries are stored but this is not a requirement. More...
#include <sparseMatrix.h>
Public Member Functions | |
sparseMatrix (int size) | |
Standard constructor for sparse matrices. The internal structures are initialized. The result is the null matrix. More... | |
~sparseMatrix () | |
Destructor of the class. More... | |
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 This is because in the context of Markov Reward Processes, there may be several transitions with different reward. It is simpler to handle this by allowing replicated entries in the neighborhood lists. The multiplication algorithm handles this in a natural way. BUT the getEntry(int,int) method must handle this situation carefully. More... | |
double | getEntry (int, int) |
Retrieving an entry from the matrix. Takes into account the fact that columns may be replicated: the different values are then added. More... | |
int | getNbElts (int row) |
Retrieving a the number of elements on some row. More... | |
int | getCol (int row, int numCol) |
Retrieving an low-level entry from the matrix. More... | |
double | getEntryByCol (int row, int numCol) |
Retrieving an low-level entry from the matrix. More... | |
discreteDistribution * | getTransDistrib (int row) |
Retrieving the transitions from some state as a discrete distribution. More... | |
double | rowSum (int row) |
Summing a row. More... | |
void | evaluateMeasure (double *m, double *res) |
Sparse vector/matrix multiplication. The result is stored in an array that must be already allocated. Anciently the "multVM" method. More... | |
void | evaluateMeasure (discreteDistribution *d, discreteDistribution *res) |
void | evaluateValue (double *v, double *res) |
Sparse vector/matrix multiplication. The result is stored in an array that must be already allocated. Anciently the "multMV" method. More... | |
sparseMatrix * | copy () |
Sparse matrix copy. This is a straightforward copy. No optimization is performed, viz replicated columns. More... | |
sparseMatrix * | uniformize () |
Sparse matrix uniformization. Returns a sparse matrix and sets the uniformization factor. If the type is already discrete, returns a copy. More... | |
void | write (FILE *out, std::string format) |
Writing a sparse matrix to a file. Several formats could be chosen. Supported formats are: "Ers", "Full", "MatrixMarket-sparse", "MatrixMarket-full", "Maple", "MARCA", "R", "scilab", "XBORNE". More... | |
bool | addToEntry (int row, int col, double val) |
Adding a value to an element to the matrix. More... | |
sparseMatrix (int size) | |
Standard constructor for sparse matrices. The internal structures are initialized. The result is the null matrix. More... | |
~sparseMatrix () | |
Destructor of the class. More... | |
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 This is because in the context of Markov Reward Processes, there may be several transitions with different reward. It is simpler to handle this by allowing replicated entries in the neighborhood lists. The multiplication algorithm handles this in a natural way. BUT the getEntry(int,int) method must handle this situation carefully. More... | |
double | getEntry (int, int) |
Retrieving an entry from the matrix. Takes into account the fact that columns may be replicated: the different values are then added. More... | |
int | getNbElts (int row) |
Retrieving a the number of elements on some row. More... | |
int | getCol (int row, int numCol) |
Retrieving an low-level entry from the matrix. More... | |
double | getEntryByCol (int row, int numCol) |
Retrieving an low-level entry from the matrix. More... | |
discreteDistribution * | getTransDistrib (int row) |
Retrieving the transitions from some state as a discrete distribution. More... | |
double | rowSum (int row) |
Summing a row. More... | |
void | evaluateMeasure (double *m, double *res) |
Sparse vector/matrix multiplication. The result is stored in an array that must be already allocated. Anciently the "multVM" method. More... | |
void | evaluateMeasure (discreteDistribution *d, discreteDistribution *res) |
void | evaluateValue (double *v, double *res) |
Sparse vector/matrix multiplication. The result is stored in an array that must be already allocated. Anciently the "multMV" method. More... | |
sparseMatrix * | copy () |
Sparse matrix copy. This is a straightforward copy. No optimization is performed, viz replicated columns. More... | |
sparseMatrix * | uniformize () |
Sparse matrix uniformization. Returns a sparse matrix and sets the uniformization factor. If the type is already discrete, returns a copy. More... | |
void | write (FILE *out, std::string format) |
Writing a sparse matrix to a file. Several formats could be chosen. Supported formats are: "Ers", "Full", "MatrixMarket-sparse", "MatrixMarket-full", "Maple", "MARCA", "R", "scilab", "XBORNE". More... | |
bool | addToEntry (int row, int col, double val) |
Adding a value to an element to the matrix. More... | |
![]() | |
virtual | ~transitionStructure () |
Destructor of the class. More... | |
int | size () |
Read accessor for the size of the state space. More... | |
timeType | type () |
Read accessor for the time type. More... | |
double | uniformizationRate () |
Read accessor for the uniformization rate. Relevant mostly for discrete-time structures created by uniformization of a continuous-time one. More... | |
void | setType (timeType t) |
Write accessor for the time type. More... | |
void | setUniformizationRate (double rate) |
Write accessor for the uniformization rate. More... | |
bool | readEntry (FILE *input) |
Reading from a file, and adding an element to the matrix. The field must be in the form "row column value" with blank spaces as separators. More... | |
virtual | ~transitionStructure () |
Destructor of the class. More... | |
int | size () |
Read accessor for the size of the state space. More... | |
timeType | type () |
Read accessor for the time type. More... | |
double | uniformizationRate () |
Read accessor for the uniformization rate. Relevant mostly for discrete-time structures created by uniformization of a continuous-time one. More... | |
void | setType (timeType t) |
Write accessor for the time type. More... | |
void | setUniformizationRate (double rate) |
Write accessor for the uniformization rate. More... | |
bool | readEntry (FILE *input) |
Reading from a file, and adding an element to the matrix. The field must be in the form "row column value" with blank spaces as separators. More... | |
Additional Inherited Members | |
![]() | |
int | consolidate (int i, int *destinations, double *values) |
Method to consolidate (aggregate) transition probabilities from a given state. The method returns the number of different destination states, and modifies the arrays which will containt the lists of destinations and the corresponding probabilities. These arrays must have been allocated beforehand, with a size large enough to handle safely all possibilities. More... | |
int | consolidate (int i, int *destinations, double *values) |
Method to consolidate (aggregate) transition probabilities from a given state. The method returns the number of different destination states, and modifies the arrays which will containt the lists of destinations and the corresponding probabilities. These arrays must have been allocated beforehand, with a size large enough to handle safely all possibilities. More... | |
![]() | |
timeType | _type |
the time type of the structure: discrete or continuous. More... | |
long int | _size |
size of the state space. More... | |
double | _uniformizationRate |
value related to the uniformization procedure. More... | |
Class sparseMatrix: implementation of a transition structure using the sparse matrix data structure. Elements of the transition structure (matrix) are stored by row, using two arrays containing indices of columns, and values of entries. A priori, only non-zero entries are stored but this is not a requirement.
sparseMatrix::sparseMatrix | ( | int | size | ) |
Standard constructor for sparse matrices. The internal structures are initialized. The result is the null matrix.
size | the number of states/rows in the structure |
Standard constructor for sparse matrices. The internal structures are initialized. The result is the null matrix.
sparseMatrix::~sparseMatrix | ( | ) |
Destructor of the class.
Standard destructor.
sparseMatrix::sparseMatrix | ( | int | size | ) |
Standard constructor for sparse matrices. The internal structures are initialized. The result is the null matrix.
size | the number of states/rows in the structure |
sparseMatrix::~sparseMatrix | ( | ) |
Destructor of the class.
bool sparseMatrix::addToEntry | ( | int | row, |
int | col, | ||
double | val | ||
) |
Adding a value to an element to the matrix.
row | number of the row |
col | number of the column |
val | value to be added |
bool sparseMatrix::addToEntry | ( | int | row, |
int | col, | ||
double | val | ||
) |
Adding a value to an element to the matrix.
row | number of the row |
col | number of the column |
val | value to be added |
|
virtual |
Sparse matrix copy. This is a straightforward copy. No optimization is performed, viz replicated columns.
Implements transitionStructure.
|
virtual |
Sparse matrix copy. This is a straightforward copy. No optimization is performed, viz replicated columns.
Implements transitionStructure.
|
virtual |
Sparse vector/matrix multiplication. The result is stored in an array that must be already allocated. Anciently the "multVM" method.
m | the measure (row vector) to be multiplied |
res | the resulting vector |
Reimplemented from transitionStructure.
|
virtual |
Version of the vector/matrix multiplication that acts on discreteDistribution objects.
d | the distribution to be multiplied |
res | the resulting distribution |
Reimplemented from transitionStructure.
|
virtual |
Sparse vector/matrix multiplication. The result is stored in an array that must be already allocated. Anciently the "multVM" method.
m | the measure (row vector) to be multiplied |
res | the resulting vector |
Reimplemented from transitionStructure.
|
virtual |
Version of the vector/matrix multiplication that acts on discreteDistribution objects.
d | the distribution to be multiplied |
res | the resulting distribution |
Reimplemented from transitionStructure.
|
virtual |
Sparse vector/matrix multiplication. The result is stored in an array that must be already allocated. Anciently the "multMV" method.
v | the value (column vector) to be multiplied |
res | the resulting vector |
Implements transitionStructure.
|
virtual |
Sparse vector/matrix multiplication. The result is stored in an array that must be already allocated. Anciently the "multMV" method.
v | the value (column vector) to be multiplied |
res | the resulting vector |
Implements transitionStructure.
|
virtual |
Retrieving an low-level entry from the matrix.
row | the number of the row |
numCol | the number of the entry in the sparse structure |
Implements transitionStructure.
|
virtual |
Retrieving an low-level entry from the matrix.
row | the number of the row |
numCol | the number of the entry in the sparse structure |
Implements transitionStructure.
|
virtual |
Retrieving an entry from the matrix. Takes into account the fact that columns may be replicated: the different values are then added.
row | |
col |
Implements transitionStructure.
|
virtual |
Retrieving an entry from the matrix. Takes into account the fact that columns may be replicated: the different values are then added.
row | |
col |
Implements transitionStructure.
|
virtual |
Retrieving an low-level entry from the matrix.
row | the number of the row |
numCol | the number of the entry in the sparse structure |
Implements transitionStructure.
|
virtual |
Retrieving an low-level entry from the matrix.
row | the number of the row |
numCol | the number of the entry in the sparse structure |
Implements transitionStructure.
|
virtual |
Retrieving a the number of elements on some row.
row | the number of the row |
Implements transitionStructure.
|
virtual |
Retrieving a the number of elements on some row.
row | the number of the row |
Implements transitionStructure.
|
virtual |
Retrieving the transitions from some state as a discrete distribution.
row | the number of the row |
Implements transitionStructure.
|
virtual |
Retrieving the transitions from some state as a discrete distribution.
row | the number of the row |
Implements transitionStructure.
|
virtual |
Summing a row.
row | the number of the row |
Implements transitionStructure.
|
virtual |
Summing a row.
row | the number of the row |
Implements transitionStructure.
|
virtual |
Inserting an element in the matrix. IMPORTANT NOTE: there is no check for the existence of the column This is because in the context of Markov Reward Processes, there may be several transitions with different reward. It is simpler to handle this by allowing replicated entries in the neighborhood lists. The multiplication algorithm handles this in a natural way. BUT the getEntry(int,int) method must handle this situation carefully.
row | the row number |
col | the column number |
val | the value to be inserted |
Implements transitionStructure.
|
virtual |
Inserting an element in the matrix. IMPORTANT NOTE: there is no check for the existence of the column This is because in the context of Markov Reward Processes, there may be several transitions with different reward. It is simpler to handle this by allowing replicated entries in the neighborhood lists. The multiplication algorithm handles this in a natural way. BUT the getEntry(int,int) method must handle this situation carefully.
row | the row number |
col | the column number |
val | the value to be inserted |
Implements transitionStructure.
|
virtual |
Sparse matrix uniformization. Returns a sparse matrix and sets the uniformization factor. If the type is already discrete, returns a copy.
Implements transitionStructure.
|
virtual |
Sparse matrix uniformization. Returns a sparse matrix and sets the uniformization factor. If the type is already discrete, returns a copy.
Implements transitionStructure.
|
virtual |
Writing a sparse matrix to a file. Several formats could be chosen. Supported formats are: "Ers", "Full", "MatrixMarket-sparse", "MatrixMarket-full", "Maple", "MARCA", "R", "scilab", "XBORNE".
out | the file descriptor to which the matrix is written |
format | the name of the format/language to use |
Implements transitionStructure.
|
virtual |
Writing a sparse matrix to a file. Several formats could be chosen. Supported formats are: "Ers", "Full", "MatrixMarket-sparse", "MatrixMarket-full", "Maple", "MARCA", "R", "scilab", "XBORNE".
out | the file descriptor to which the matrix is written |
format | the name of the format/language to use |
Implements transitionStructure.