Sleipnir
Public Member Functions
Sleipnir::CSparseMapMatrix< tType > Class Template Reference

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

#include <sparsematrix.h>

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

Public Member Functions

 CSparseMapMatrix (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.
size_t GetRows () const
 Return the number of rows in the matrix.
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.

Detailed Description

template<class tType>
class Sleipnir::CSparseMapMatrix< tType >

An asymmetric two-dimensional sparse matrix using maps 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 map for each row, allowing fairly rapid lookup at the expense of moderate memory usage.

See also:
CSparseListMatrix | CFullMatrix

Definition at line 366 of file sparsematrix.h.


Constructor & Destructor Documentation

template<class tType >
Sleipnir::CSparseMapMatrix< tType >::CSparseMapMatrix ( 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 375 of file sparsematrix.h.


Member Function Documentation

template<class tType >
tType Sleipnir::CSparseMapMatrix< 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 437 of file sparsematrix.h.

template<class tType >
const tType& Sleipnir::CSparseMapMatrix< 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 473 of file sparsematrix.h.

template<class tType >
size_t Sleipnir::CSparseMapMatrix< 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 413 of file sparsematrix.h.

template<class tType >
void Sleipnir::CSparseMapMatrix< 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 401 of file sparsematrix.h.

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

template<class tType >
void Sleipnir::CSparseMapMatrix< 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 462 of file sparsematrix.h.


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