Sleipnir
Public Member Functions
Sleipnir::CCompactFullMatrix Class Reference

Store a discrete matrix using the fewest possible bytes. More...

#include <compactmatrix.h>

Inheritance diagram for Sleipnir::CCompactFullMatrix:
Sleipnir::CCompactFullMatrixImpl

Public Member Functions

void Initialize (size_t iRows, size_t iColumns, unsigned char cValues, bool fClear)
 Initialize a new compact matrix with the requested numbers of rows, columns, and discrete values.
size_t GetRows () const
 Returns the number of rows in the matrix.
size_t GetColumns () const
 Returns the number of columns in the matrix.
unsigned char Get (size_t iY, size_t iX) const
 Returns the value at the requested matrix position.
void Set (size_t iY, size_t iX, unsigned char cValue)
 Set the value at the requested matrix position.

Detailed Description

Store a discrete matrix using the fewest possible bytes.

Store a discrete matrix using the fewest possible bytes. This is done using sub-byte alignment, with each value occupying the smallest number of bits possible to store the total number of possible different values.

See also:
CCompactMatrix | CFullMatrix

Definition at line 170 of file compactmatrix.h.


Member Function Documentation

unsigned char Sleipnir::CCompactFullMatrix::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 and column must be smaller than the size.
See also:
Set

Reimplemented from Sleipnir::CCompactMatrixBase.

Definition at line 251 of file compactmatrix.h.

size_t Sleipnir::CCompactFullMatrix::GetColumns ( ) const [inline]

Returns the number of columns in the matrix.

Returns:
Number of columns in the matrix.
See also:
GetRows

Definition at line 227 of file compactmatrix.h.

size_t Sleipnir::CCompactFullMatrix::GetRows ( ) const [inline]

Returns the number of rows in the matrix.

Returns:
Number of rows in the matrix.
See also:
GetColumns

Definition at line 213 of file compactmatrix.h.

void Sleipnir::CCompactFullMatrix::Initialize ( size_t  iRows,
size_t  iColumns,
unsigned char  cValues,
bool  fClear 
) [inline]

Initialize a new compact matrix with the requested numbers of rows, columns, and discrete values.

Parameters:
iRowsNumber of rows in the matrix.
iColumnsNumber of columns in the matrix.
cValuesNumber of different values that each entry in the matrix can take.
fClearIf true, set each matrix entry to zero after allocation.

Allocates and, optionally, clears enough memory to store a matrix with the requested number of rows and columns, with each entry taking the requested number of different values. A matrix with iRows rows and iColumns columns will have iRows * iColumns entries, each of which takes ceil(log2(cValues)) bits. This means that roughly ceil(8 * log2(cValues) * iRows * iColumns) bytes will be allocated for the entire matrix.

Remarks:
cValues should be greater than one.

Definition at line 197 of file compactmatrix.h.

void Sleipnir::CCompactFullMatrix::Set ( size_t  iY,
size_t  iX,
unsigned char  cValue 
) [inline]

Set the value at the requested matrix position.

Parameters:
iYMatrix row.
iXMatrix column.
cValueValue to store.
Remarks:
For efficiency, no bounds checking is performed. The given value must be smaller than the maximum value with which the matrix was initialized, and the row and column must be smaller than the size.
See also:
Get

Reimplemented from Sleipnir::CCompactMatrixBase.

Definition at line 275 of file compactmatrix.h.


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