solver  1.0
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
SparseMatrix< T > Class Template Reference

Memory efficient storage of the constraint matrix. More...

#include <SparseMatrix.h>

+ Collaboration diagram for SparseMatrix< T >:

Public Types

using Row = std::vector< std::pair< uint32_t, T > >
 The matrix row is stored as a vector of pairs where each pair consists of column index and the related value.
 

Public Member Functions

 SparseMatrix (T defaultValue=T())
 Creates empty matrix with a default value for unfilled elements.
 
get (const uint32_t &i, const uint32_t &j) const
 It returns a value of the matrix for the specified indices. More...
 
void addRow (Row &row)
 Adds precreated row to the matrix. Passed argument is destroyed.
 
Rowoperator[] (const uint32_t &i)
 It returns i-th row of the matrix.
 
const Rowoperator[] (const uint32_t &i) const
 It returns i-th row of the matrix.
 
uint64_t numberOfRows () const
 
uint64_t numberOfColumns () const
 
uint64_t numberOfElements () const
 Number of non-zero elements of the matrix.
 
double densityOfMatrix () const
 Percentage of filled elements.
 
void clear ()
 Destroys the matrix.
 

Private Member Functions

bool checkColumn (const Row &row) const
 It checks whether the column is uniquely defined. More...
 

Private Attributes

mDefaultValue
 Default value for unfilled elements.
 
std::vector< RowmSparseMatrix
 Sparse constraint matrix.
 

Detailed Description

template<class T>
class SparseMatrix< T >

Memory efficient storage of the constraint matrix.

Sparse matrix implementation suitable for the row-by-row consecutive access that is very appropriate for building of Integer Linear Programming problems. A random access by columns is not recommended since it causes huge latencies.

Template Parameters
TMostly either float or double.

Definition at line 43 of file SparseMatrix.h.

Member Function Documentation

template<class T>
bool SparseMatrix< T >::checkColumn ( const Row row) const
inlineprivate

It checks whether the column is uniquely defined.

Parameters
rowMatrix row to be checked.
Returns
True if the column does not contain redefined values, otherwise false.

Definition at line 119 of file SparseMatrix.h.

template<class T>
T SparseMatrix< T >::get ( const uint32_t &  i,
const uint32_t &  j 
) const
inline

It returns a value of the matrix for the specified indices.

Parameters
i,jRow and column index, respectively.
Returns
Value of the matrix at (i,j) indices.

Definition at line 53 of file SparseMatrix.h.


The documentation for this class was generated from the following file: