Thea
Public Types | Public Member Functions | List of all members
IAddressableMatrix< T > Class Template Referenceabstract

Interface for a 2D matrix with elements that may be directly accessed via a (row, column) pair. More...

#include <IAddressableMatrix.hpp>

Inheritance diagram for IAddressableMatrix< T >:
IMatrix< T > IDenseMatrix< T > ImageMatrix< T > MappedMatrix< T, IndexT > VariantMatrix< T, DenseMatrixT, SparseMatrixT >

Public Types

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...
 

Public Member Functions

virtual IAddressableMatrix< T > const * asAddressable () const =0
 If the matrix elements are addressable by (row, col) pairs, get a pointer to a derived interface supporting such access. More...
 
virtual IAddressableMatrix< T > * asAddressable ()=0
 If the matrix elements are addressable by (row, col) pairs, get a pointer to a derived interface supporting such access. More...
 
virtual IDenseMatrix< T > const * asDense () const =0
 If the matrix is stored as a dense array, get a pointer to a derived interface supporting dense-specific access. More...
 
virtual IDenseMatrix< T > * asDense ()=0
 If the matrix is stored as a dense array, get a pointer to a derived interface supporting dense-specific access. More...
 
virtual ISparseMatrix< T > const * asSparse () const =0
 If the matrix elements are addressable by (row, col) pairs, get a pointer to a derived interface supporting such access. More...
 
virtual ISparseMatrix< T > * asSparse ()=0
 If the matrix is sparse, get a pointer to a derived interface giving sparse-specific access. More...
 
virtual T const & at (int64 row, int64 col) const =0
 Get a read-only element. More...
 
virtual int64 cols () const =0
 Get the number of columns. More...
 
virtual void getColumn (int64 col, T *values) const =0
 Get a column of the matrix. More...
 
virtual void getRow (int64 row, T *values) const =0
 Get a row of the matrix. More...
 
virtual int8 isResizable () const =0
 Check if the matrix can be freely resized. More...
 
virtual T & mutableAt (int64 row, int64 col)=0
 Get an element that can be directly modified. More...
 
virtual int8 resize (int64 nrows, int64 ncols)=0
 Resize the matrix to new dimensions, if isResizable() returns true. More...
 
virtual int64 rows () const =0
 Get the number of rows. More...
 
virtual void setColumn (int64 col, T const *values)=0
 Set a column of the matrix. More...
 
virtual void setRow (int64 row, T const *values)=0
 Set a row of the matrix. More...
 
virtual void setZero ()=0
 Set all elements to zero. More...
 

Detailed Description

template<typename T>
class Thea::IAddressableMatrix< T >

Interface for a 2D matrix with elements that may be directly accessed via a (row, column) pair.

Useful for passing matrices across shared library boundaries.

Definition at line 30 of file IAddressableMatrix.hpp.

Member Typedef Documentation

typedef T Value
inherited

Type of values stored in the matrix.

Definition at line 33 of file IMatrix.hpp.

typedef T value_type
inherited

Type of values stored in the matrix (STL convention).

Definition at line 34 of file IMatrix.hpp.

Member Function Documentation

virtual IAddressableMatrix<T> const* asAddressable ( ) const
pure virtualinherited

If the matrix elements are addressable by (row, col) pairs, get a pointer to a derived interface supporting such access.

Else, return null.

Note
dynamic_cast does not work reliably across shared library boundaries, and relying on users to avoid it and only use static_cast is dangerous.

Implemented in MappedMatrix< T, IndexT >, VariantMatrix< T, DenseMatrixT, SparseMatrixT >, MatrixWrapper< MatrixT >, MatrixWrapper< VertexMatrix >, MatrixWrapper< Dense >, MatrixWrapper< TriangleMatrix >, SparseMatrixWrapper< MatrixT >, SparseMatrixWrapper< Sparse >, and ImageMatrix< T >.

virtual IAddressableMatrix<T>* asAddressable ( )
pure virtualinherited

If the matrix elements are addressable by (row, col) pairs, get a pointer to a derived interface supporting such access.

Else, return null.

Note
dynamic_cast does not work reliably across shared library boundaries, and relying on users to avoid it and only use static_cast is dangerous.

Implemented in MappedMatrix< T, IndexT >, VariantMatrix< T, DenseMatrixT, SparseMatrixT >, MatrixWrapper< MatrixT >, MatrixWrapper< VertexMatrix >, MatrixWrapper< Dense >, MatrixWrapper< TriangleMatrix >, SparseMatrixWrapper< MatrixT >, SparseMatrixWrapper< Sparse >, and ImageMatrix< T >.

virtual IDenseMatrix<T> const* asDense ( ) const
pure virtual

If the matrix is stored as a dense array, get a pointer to a derived interface supporting dense-specific access.

Else, return null.

Note
dynamic_cast does not work reliably across shared library boundaries, and relying on users to avoid it and only use static_cast is dangerous.

Implemented in MappedMatrix< T, IndexT >, VariantMatrix< T, DenseMatrixT, SparseMatrixT >, MatrixWrapper< MatrixT >, MatrixWrapper< VertexMatrix >, MatrixWrapper< Dense >, MatrixWrapper< TriangleMatrix >, and ImageMatrix< T >.

virtual IDenseMatrix<T>* asDense ( )
pure virtual

If the matrix is stored as a dense array, get a pointer to a derived interface supporting dense-specific access.

Else, return null.

Note
dynamic_cast does not work reliably across shared library boundaries, and relying on users to avoid it and only use static_cast is dangerous.

Implemented in MappedMatrix< T, IndexT >, VariantMatrix< T, DenseMatrixT, SparseMatrixT >, MatrixWrapper< MatrixT >, MatrixWrapper< VertexMatrix >, MatrixWrapper< Dense >, MatrixWrapper< TriangleMatrix >, and ImageMatrix< T >.

virtual ISparseMatrix<T> const* asSparse ( ) const
pure virtualinherited

If the matrix elements are addressable by (row, col) pairs, get a pointer to a derived interface supporting such access.

Else, return null.

Note
dynamic_cast does not work reliably across shared library boundaries, and relying on users to avoid it and only use static_cast is dangerous.

Implemented in MappedMatrix< T, IndexT >, VariantMatrix< T, DenseMatrixT, SparseMatrixT >, MatrixWrapper< MatrixT >, MatrixWrapper< VertexMatrix >, MatrixWrapper< Dense >, MatrixWrapper< TriangleMatrix >, SparseMatrixWrapper< MatrixT >, SparseMatrixWrapper< Sparse >, and ImageMatrix< T >.

virtual ISparseMatrix<T>* asSparse ( )
pure virtualinherited

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.

Note
dynamic_cast does not work reliably across shared library boundaries, and relying on users to avoid it and only use static_cast is dangerous.

Implemented in MappedMatrix< T, IndexT >, VariantMatrix< T, DenseMatrixT, SparseMatrixT >, MatrixWrapper< MatrixT >, MatrixWrapper< VertexMatrix >, MatrixWrapper< Dense >, MatrixWrapper< TriangleMatrix >, SparseMatrixWrapper< MatrixT >, SparseMatrixWrapper< Sparse >, and ImageMatrix< T >.

virtual T const& at ( int64  row,
int64  col 
) const
pure virtual

Get a read-only element.

Most derived/underlying classes define operator() to access an element quicker, without the virtual function overhead. Use this function only in generic algorithms that need polymorphic access to matrices without using templates, or when accessing matrices across shared library boundaries.

Implemented in MappedMatrix< T, IndexT >, VariantMatrix< T, DenseMatrixT, SparseMatrixT >, MatrixWrapper< MatrixT >, MatrixWrapper< VertexMatrix >, MatrixWrapper< Dense >, MatrixWrapper< TriangleMatrix >, and ImageMatrix< T >.

virtual int64 cols ( ) const
pure virtualinherited
virtual void getColumn ( int64  col,
T *  values 
) const
pure virtual
virtual void getRow ( int64  row,
T *  values 
) const
pure virtual
virtual int8 isResizable ( ) const
pure virtualinherited
virtual T& mutableAt ( int64  row,
int64  col 
)
pure virtual

Get an element that can be directly modified.

Most derived/underlying classes define operator() to access an element quicker, without the virtual function overhead. Use this function only in generic algorithms that need polymorphic access to matrices without using templates, or when accessing matrices across shared library boundaries.

Implemented in MappedMatrix< T, IndexT >, VariantMatrix< T, DenseMatrixT, SparseMatrixT >, MatrixWrapper< MatrixT >, MatrixWrapper< VertexMatrix >, MatrixWrapper< Dense >, MatrixWrapper< TriangleMatrix >, and ImageMatrix< T >.

virtual int8 resize ( int64  nrows,
int64  ncols 
)
pure virtualinherited

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.

Returns
True if the final dimensions of the matrix are identical to the desired dimensions, else false.

Implemented in VariantMatrix< T, DenseMatrixT, SparseMatrixT >, MappedMatrix< T, IndexT >, MatrixWrapper< MatrixT >, MatrixWrapper< VertexMatrix >, MatrixWrapper< Dense >, MatrixWrapper< TriangleMatrix >, SparseMatrixWrapper< MatrixT >, SparseMatrixWrapper< Sparse >, and ImageMatrix< T >.

virtual int64 rows ( ) const
pure virtualinherited
virtual void setColumn ( int64  col,
T const *  values 
)
pure virtual
virtual void setRow ( int64  row,
T const *  values 
)
pure virtual
virtual void setZero ( )
pure virtualinherited

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