Thea
|
Wrapper for a sparse 2D matrix, implementing a pure virtual interface for passing across shared library boundaries. More...
#include <SparseMatrixWrapper.hpp>
Public Types | |
typedef MatrixT::value_type | Value |
Type of values stored in the matrix. More... | |
typedef T | Value |
Type of values stored in the matrix. More... | |
typedef T | value_type |
Type of values stored in the matrix (STL convention). More... | |
typedef MatrixT::value_type | value_type |
Type of values stored in the matrix (STL convention). More... | |
typedef MatrixT | WrappedMatrix |
The wrapped matrix type. More... | |
Public Member Functions | |
IAddressableMatrix< Value > const * | asAddressable () const |
If the matrix elements are addressable by (row, col) pairs, get a pointer to a derived interface supporting such access. More... | |
IAddressableMatrix< Value > * | asAddressable () |
If the matrix elements are addressable by (row, col) pairs, get a pointer to a derived interface supporting such access. More... | |
ICompressedSparseMatrix< Value > const * | asCompressed () const |
If the matrix is stored in compressed column or row format, get a pointer to a derived interface supporting access specific to that format. More... | |
ICompressedSparseMatrix< Value > * | asCompressed () |
If the matrix is stored in compressed column or row format, get a pointer to a derived interface supporting access specific to that format. More... | |
ISparseMatrix< Value > const * | asSparse () const |
If the matrix elements are addressable by (row, col) pairs, get a pointer to a derived interface supporting such access. More... | |
ISparseMatrix< Value > * | asSparse () |
If the matrix is sparse, get a pointer to a derived interface giving sparse-specific access. More... | |
int64 | cols () const |
Get the number of columns. More... | |
int32 | getInnerIndexType () const |
The integer type used to store inner indices, as per the values in NumericType. More... | |
void const * | getInnerIndices () const |
Get the array of inner indices. More... | |
void * | getInnerIndices () |
Get the array of inner indices. More... | |
MatrixT const & | getMatrix () const |
Get the wrapped matrix. More... | |
MatrixT & | getMatrix () |
Get the wrapped matrix. More... | |
void const * | getNonZeroCounts () const |
Get the array of non-zero counts. More... | |
void * | getNonZeroCounts () |
Get the array of non-zero counts. More... | |
int32 | getNonZeroCountType () const |
The integer type used to store per-segment non-zero counts, as per the values in NumericType. More... | |
int32 | getOuterIndexType () const |
The integer type used to store outer indices, as per the values in NumericType. More... | |
void const * | getOuterIndices () const |
Get the array of outer indices. More... | |
void * | getOuterIndices () |
Get the array of outer indices. More... | |
Value const * | getValues () const |
Get the array storing the non-zero values. More... | |
Value * | getValues () |
Get the array storing the non-zero values. More... | |
int64 | innerSize () const |
Get the size of the matrix along the inner dimension (rows if column-major, or columns if row-major). More... | |
int8 | isColumnMajor () const |
Is the matrix stored in column-major format? More... | |
int8 | isFullyCompressed () const |
Make sure the matrix actually is fully compressed. More... | |
int8 | isResizable () const |
Check if the matrix can be freely resized. More... | |
int8 | isRowMajor () const |
Is the matrix stored in row-major format? More... | |
int64 | numStoredElements () const |
Get the number of entries actually stored in the matrix. More... | |
int64 | outerSize () const |
Get the size of the matrix int64 the outer dimension (columns if column-major, or row if row-major). More... | |
int8 | resize (int64 nrows, int64 ncols) |
Resize the matrix to new dimensions, if isResizable() returns true. More... | |
int64 | rows () const |
Get the number of rows. More... | |
void | setZero () |
Set all elements to zero. More... | |
SparseMatrixWrapper (MatrixT *mat) | |
Constructor. More... | |
~SparseMatrixWrapper () | |
Destructor. More... | |
Wrapper for a sparse 2D matrix, implementing a pure virtual interface for passing across shared library boundaries.
MatrixT must be an instance of the Eigen::SparseMatrix template.
Definition at line 29 of file SparseMatrixWrapper.hpp.
|
inherited |
Type of values stored in the matrix.
Definition at line 33 of file IMatrix.hpp.
|
inherited |
Type of values stored in the matrix.
Definition at line 33 of file IMatrix.hpp.
|
inherited |
Type of values stored in the matrix (STL convention).
Definition at line 34 of file IMatrix.hpp.
|
inherited |
Type of values stored in the matrix (STL convention).
Definition at line 34 of file IMatrix.hpp.
typedef MatrixT WrappedMatrix |
The wrapped matrix type.
Definition at line 40 of file SparseMatrixWrapper.hpp.
SparseMatrixWrapper | ( | MatrixT * | mat | ) |
Constructor.
The passed matrix must persist as int64 as this class is being actively used, since it is accessed via a pointer.
Definition at line 48 of file SparseMatrixWrapper.hpp.
~SparseMatrixWrapper | ( | ) |
Destructor.
Definition at line 55 of file SparseMatrixWrapper.hpp.
|
virtual |
If the matrix elements are addressable by (row, col) pairs, get a pointer to a derived interface supporting such access.
Else, return null.
dynamic_cast
does not work reliably across shared library boundaries, and relying on users to avoid it and only use static_cast
is dangerous. Implements IMatrix< T >.
Definition at line 102 of file SparseMatrixWrapper.hpp.
|
virtual |
If the matrix elements are addressable by (row, col) pairs, get a pointer to a derived interface supporting such access.
Else, return null.
dynamic_cast
does not work reliably across shared library boundaries, and relying on users to avoid it and only use static_cast
is dangerous. Implements IMatrix< T >.
Definition at line 103 of file SparseMatrixWrapper.hpp.
|
virtual |
If the matrix is stored in compressed column or row format, get a pointer to a derived interface supporting access specific to that format.
Else, return null.
dynamic_cast
does not work reliably across shared library boundaries, and relying on users to avoid it and only use static_cast
is dangerous. Implements ISparseMatrix< T >.
Definition at line 106 of file SparseMatrixWrapper.hpp.
|
virtual |
If the matrix is stored in compressed column or row format, get a pointer to a derived interface supporting access specific to that format.
Else, return null.
dynamic_cast
does not work reliably across shared library boundaries, and relying on users to avoid it and only use static_cast
is dangerous. Implements ISparseMatrix< T >.
Definition at line 107 of file SparseMatrixWrapper.hpp.
|
virtual |
If the matrix elements are addressable by (row, col) pairs, get a pointer to a derived interface supporting such access.
Else, return null.
dynamic_cast
does not work reliably across shared library boundaries, and relying on users to avoid it and only use static_cast
is dangerous. Implements IMatrix< T >.
Definition at line 104 of file SparseMatrixWrapper.hpp.
|
virtual |
If the matrix is sparse, get a pointer to a derived interface giving sparse-specific access.
Else, return null. Note that a sparse matrix can still be addressable, e.g. if it is stored as a map of (row, col) –> value
pairs.
dynamic_cast
does not work reliably across shared library boundaries, and relying on users to avoid it and only use static_cast
is dangerous. Implements IMatrix< T >.
Definition at line 105 of file SparseMatrixWrapper.hpp.
|
virtual |
Get the number of columns.
Implements IMatrix< T >.
Definition at line 65 of file SparseMatrixWrapper.hpp.
|
virtual |
The integer type used to store inner indices, as per the values in NumericType.
Implements ICompressedSparseMatrix< MatrixT::value_type >.
Definition at line 89 of file SparseMatrixWrapper.hpp.
|
virtual |
Get the array of inner indices.
The array has numStoredElements() meaningful entries, but these may not be contiguous if isFullyCompressed() is false. Convert to the correct integer type using getInnerIndexType().
Implements ICompressedSparseMatrix< MatrixT::value_type >.
Definition at line 92 of file SparseMatrixWrapper.hpp.
|
virtual |
Get the array of inner indices.
The array has numStoredElements() meaningful entries, but these may not be contiguous if isFullyCompressed() is false. Convert to the correct integer type using getInnerIndexType().
Implements ICompressedSparseMatrix< MatrixT::value_type >.
Definition at line 93 of file SparseMatrixWrapper.hpp.
MatrixT const& getMatrix | ( | ) | const |
Get the wrapped matrix.
Definition at line 58 of file SparseMatrixWrapper.hpp.
MatrixT& getMatrix | ( | ) |
Get the wrapped matrix.
Definition at line 61 of file SparseMatrixWrapper.hpp.
|
virtual |
Get the array of non-zero counts.
Each entry is the number of actual non-zeros in the corresponding inner segment. The return value is undefined if isFullyCompressed() is true. Convert to the correct integer type using getNonZeroCountType().
Implements ICompressedSparseMatrix< MatrixT::value_type >.
Definition at line 96 of file SparseMatrixWrapper.hpp.
|
virtual |
Get the array of non-zero counts.
Each entry is the number of actual non-zeros in the corresponding inner segment. The return value is undefined if isFullyCompressed() is true. Convert to the correct integer type using getNonZeroCountType().
Implements ICompressedSparseMatrix< MatrixT::value_type >.
Definition at line 97 of file SparseMatrixWrapper.hpp.
|
virtual |
The integer type used to store per-segment non-zero counts, as per the values in NumericType.
Implements ICompressedSparseMatrix< MatrixT::value_type >.
Definition at line 91 of file SparseMatrixWrapper.hpp.
|
virtual |
The integer type used to store outer indices, as per the values in NumericType.
Implements ICompressedSparseMatrix< MatrixT::value_type >.
Definition at line 90 of file SparseMatrixWrapper.hpp.
|
virtual |
Get the array of outer indices.
The array has outerSize() + 1 entries. Convert to the correct integer type using getOuterIndexType().
Implements ICompressedSparseMatrix< MatrixT::value_type >.
Definition at line 94 of file SparseMatrixWrapper.hpp.
|
virtual |
Get the array of outer indices.
The array has outerSize() + 1 entries: if isFullyCompressed() is true, the last entry is the total number of non-zeros in the matrix. Convert to the correct integer type using getOuterIndexType().
Implements ICompressedSparseMatrix< MatrixT::value_type >.
Definition at line 95 of file SparseMatrixWrapper.hpp.
|
virtual |
Get the array storing the non-zero values.
The array has numStoredElements() meaningful entries, but these may not be contiguous if isFullyCompressed() is false.
Implements ICompressedSparseMatrix< MatrixT::value_type >.
Definition at line 98 of file SparseMatrixWrapper.hpp.
|
virtual |
Get the array storing the non-zero values.
The array has numStoredElements() meaningful entries, but these may not be contiguous if isFullyCompressed() is false.
Implements ICompressedSparseMatrix< MatrixT::value_type >.
Definition at line 99 of file SparseMatrixWrapper.hpp.
|
virtual |
Get the size of the matrix along the inner dimension (rows if column-major, or columns if row-major).
Implements ICompressedSparseMatrix< MatrixT::value_type >.
Definition at line 86 of file SparseMatrixWrapper.hpp.
|
virtual |
Is the matrix stored in column-major format?
Implements IRowOrColumnMajorMatrix< MatrixT::value_type >.
Definition at line 83 of file SparseMatrixWrapper.hpp.
|
virtual |
Make sure the matrix actually is fully compressed.
If not, it will be stored in Eigen's custom format which allows gaps between non-zeros. In the latter case, the array returned by getNonZeroCounts() contains the number of actual non-zeros in each inner segment.
Implements ICompressedSparseMatrix< MatrixT::value_type >.
Definition at line 88 of file SparseMatrixWrapper.hpp.
|
virtual |
Check if the matrix can be freely resized.
Implements IMatrix< T >.
Definition at line 67 of file SparseMatrixWrapper.hpp.
|
virtual |
Is the matrix stored in row-major format?
Implements IRowOrColumnMajorMatrix< MatrixT::value_type >.
Definition at line 82 of file SparseMatrixWrapper.hpp.
|
virtual |
Get the number of entries actually stored in the matrix.
These are often called "non-zeros", though they may actually have the numeric value 0.
Implements ISparseMatrix< T >.
Definition at line 79 of file SparseMatrixWrapper.hpp.
|
virtual |
Get the size of the matrix int64 the outer dimension (columns if column-major, or row if row-major).
Implements ICompressedSparseMatrix< MatrixT::value_type >.
Definition at line 87 of file SparseMatrixWrapper.hpp.
|
virtual |
Resize the matrix to new dimensions, if isResizable() returns true.
Else, if the new dimensions are identical to the old dimensions, do nothing and return true, else return false. If the dimensions are changed, existing entries will in general not be preserved in the resized matrix.
Implements IMatrix< T >.
Definition at line 68 of file SparseMatrixWrapper.hpp.
|
virtual |
Get the number of rows.
Implements IMatrix< T >.
Definition at line 64 of file SparseMatrixWrapper.hpp.
|
virtual |
Set all elements to zero.
Implements IMatrix< T >.
Definition at line 66 of file SparseMatrixWrapper.hpp.