Sleipnir
Data Structures | Public Member Functions
Sleipnir::CSparseListMatrix< tType > Class Template Reference

An asymmetric two-dimensional sparse matrix using linked lists for each row. More...

#include <sparsematrix.h>

Inheritance diagram for Sleipnir::CSparseListMatrix< tType >:
Sleipnir::CSparseMatrixImpl< tType >

Data Structures

struct  SNode

Public Member Functions

 CSparseListMatrix (const tType &Default)
 Create a new sparse matrix with the given default value.
void Reset ()
 Empties the matrix and deallocates all associated memory.
void Initialize (size_t iR)
 Create a new matrix of the requested size.
tType Get (size_t iY, size_t iX) const
 Returns the value at the requested matrix position.
void Set (size_t iY, size_t iX, const tType &Value)
 Set the value at the requested matrix position.
const tType & GetDefault () const
 Return the default value for entries not in the matrix.
size_t GetRows () const
 Return the number of rows in the matrix.

Detailed Description

template<class tType>
class Sleipnir::CSparseListMatrix< tType >

An asymmetric two-dimensional sparse matrix using linked lists for each row.

Parameters:
tTypeType of element contained by the matrix.

Implements a two-dimensional matrix assuming few non-default entries in each row. These entries are maintained by a linked list for each row, allowing very low memory usage (for sufficiently sparse matrices) at the expense of potentially slow lookup.

See also:
CSparseMapMatrix | CFullMatrix

Definition at line 496 of file sparsematrix.h.


Constructor & Destructor Documentation

template<class tType >
Sleipnir::CSparseListMatrix< tType >::CSparseListMatrix ( const tType &  Default) [inline]

Create a new sparse matrix with the given default value.

Parameters:
DefaultDefault value provided for entries not in the matrix.

Definition at line 514 of file sparsematrix.h.


Member Function Documentation

template<class tType >
tType Sleipnir::CSparseListMatrix< tType >::Get ( size_t  iY,
size_t  iX 
) const [inline]

Returns the value at the requested matrix position.

Parameters:
iYMatrix row.
iXMatrix column.
Returns:
Value at the requested matrix position.
Remarks:
For efficiency, no bounds checking is performed. The given row must be smaller than GetRows. If no entry is found for the given position, the default value is returned.
See also:
Set

Definition at line 573 of file sparsematrix.h.

template<class tType >
const tType& Sleipnir::CSparseListMatrix< tType >::GetDefault ( ) const [inline]

Return the default value for entries not in the matrix.

Returns:
Default value for entries not in the matrix.

Reimplemented from Sleipnir::CSparseMatrixImpl< tType >.

Definition at line 626 of file sparsematrix.h.

template<class tType >
size_t Sleipnir::CSparseListMatrix< tType >::GetRows ( ) const [inline]

Return the number of rows in the matrix.

Returns:
Number of rows in the matrix.

Reimplemented from Sleipnir::CSparseMatrixImpl< tType >.

Definition at line 637 of file sparsematrix.h.

template<class tType >
void Sleipnir::CSparseListMatrix< tType >::Initialize ( size_t  iR) [inline]

Create a new matrix of the requested size.

Parameters:
iRMatrix rows.
Remarks:
Columns are not specified since they are allocated dynamically by each row's map.

Definition at line 547 of file sparsematrix.h.

References Sleipnir::CSparseListMatrix< tType >::Reset().

template<class tType >
void Sleipnir::CSparseListMatrix< tType >::Set ( size_t  iY,
size_t  iX,
const tType &  Value 
) [inline]

Set the value at the requested matrix position.

Parameters:
iYMatrix row.
iXMatrix column.
ValueValue to store.
Remarks:
For efficiency, no bounds checking is performed. The given row must be smaller than GetRows.
See also:
Get

Definition at line 601 of file sparsematrix.h.


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