SparseMatrix Class Template Reference

A kernel for sparse matrix classes. More...

#include <SparseMatrix.h>

Inheritance diagram for SparseMatrix::

CMSparseMatrix RMSparseMatrix List of all members.

Public Methods

int get_ncols (void) const
 Returns the number of columns in the matrix.

int get_nrows (void) const
 Returns the number of rows in the matrix.

int get_nnzero (void) const
 Returns the number of non-zeros in the matrix.

IntVectorget_matbeg (void)
 Returns the matbeg array.

IntVectorget_matcnt (void)
 Returns the matcnt array.

IntVectorget_matind (void)
 Returns the matind array.

NumArray< T > & get_matval (void)
 Returns the matval array.

virtual T & operator() (const int row, const int col)=0
 Returns the value of the element at the row-th row and col-th column.

virtual const T & operator() (const int row, const int col) const=0
 Returns the value of the element at the row-th row and col-th column.

virtual int pretty_print (ostream &ostr) const
 Print out the matrix in a pretty format.

virtual int write (ostream &ostr) const=0
 Write out the matrix to an output stream.

virtual int read (istream &istr)=0
 Read in the matrix from an input stream.

int write (PackBuffer &ostr) const
 Write out the matrix to a pack buffer.

int read (UnPackBuffer &istr)
 Read in the matrix from a pack buffer.

virtual void delete_row (const int i)=0
 Delete the i-th row.

virtual void delete_col (const int i)=0
 Delete the i-th column.

virtual void delete_element (const int row, const int col)=0
 Delete the (row,col)-th element.


Protected Methods

 SparseMatrix (void)
 A protected constructor, which initializes elements in this class.

virtual ~SparseMatrix ()
 Dummy destructor.

virtual void initialize (int nrow, int ncol, int nnzero)=0
 Initialize a sparse matrix.

void setup (int ncol, int nrow, int nnzero, int flag)
 Initialize the memory of a sparse matrix.


Protected Attributes

int ncols
 The number of columns in the matrix.

int nrows
 The number of rows in the matrix.

int nnzeros
 The number of nonzeros in the matrix.

IntVector matbeg
 Index where the i-th row/column begins in matval.

IntVector matcnt
 The number of values in the i-th row/column.

IntVector matind
 matind[i] is the column/row number for the i-th value in row/column.

NumArray< T > matval
 The vector of values in the matrix.


Detailed Description

template<class T>
class SparseMatrix< T >

A kernel for sparse matrix classes.

Adapted from the sparse matrix classes developed by Kalyan S. Perumalla and Jeff T. Linderoth.

Note: this code uses integer indeces. This limits the total size of the sparse matrix to a smaller size than would be possible if 'long integers' were used for indexing, but this is compatable with CPLEX's use of sparse arrays.


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