![]() |
Chemical Data Processing Library C++ API - Version 1.4.0
|
Sparse matrix that stores only non-default entries keyed by a packed (row, column) identifier. More...
#include <Matrix.hpp>
Inheritance diagram for CDPL::Math::SparseMatrix< T, A >:Public Types | |
| typedef T | ValueType |
| The scalar value type. More... | |
| typedef A::key_type | KeyType |
| The packed (row, column) key type used by the underlying associative container. More... | |
| typedef SparseContainerElement< SelfType > | Reference |
| Mutable reference type (a proxy object that inserts on assignment to a previously-absent cell). More... | |
| typedef const T & | ConstReference |
| Constant reference type to a stored element value. More... | |
| typedef std::uint32_t | SizeType |
| The unsigned size type. More... | |
| typedef std::ptrdiff_t | DifferenceType |
| The signed difference type. More... | |
| typedef A | ArrayType |
| The underlying associative container type. More... | |
| typedef T * | Pointer |
| Pointer type for raw access to stored entries. More... | |
| typedef const T * | ConstPointer |
| Constant pointer type for raw access to stored entries. More... | |
| typedef MatrixReference< SelfType > | ClosureType |
| Closure type used when this matrix appears inside another expression. More... | |
| typedef const MatrixReference< const SelfType > | ConstClosureType |
| Constant closure type used when this matrix appears inside another expression. More... | |
| typedef SelfType | MatrixTemporaryType |
| Concrete temporary matrix type used by expression-template machinery. More... | |
| typedef Vector< T, std::vector< T > > | VectorTemporaryType |
| Concrete temporary vector type used when assembling vectors from this matrix. More... | |
| typedef std::shared_ptr< SelfType > | SharedPointer |
A reference-counted smart pointer [SHPTR] for dynamically allocated SparseMatrix instances. More... | |
| typedef std::initializer_list< std::initializer_list< T > > | InitializerListType |
| The initializer-list-of-rows type accepted by constructors and assignment. More... | |
Public Types inherited from CDPL::Math::MatrixContainer< SparseMatrix< T, std::unordered_map< std::uint64_t, T > > > | |
| typedef SparseMatrix< T, std::unordered_map< std::uint64_t, T > > | ContainerType |
| The derived matrix container type. More... | |
Public Types inherited from CDPL::Math::MatrixExpression< E > | |
| typedef E | ExpressionType |
| The derived matrix expression type. More... | |
Public Types inherited from CDPL::Math::Expression< E > | |
| typedef E | ExpressionType |
| The derived expression type (made available to expression-template machinery). More... | |
Public Member Functions | |
| SparseMatrix () | |
| Constructs an empty sparse matrix (zero rows, zero columns, no stored entries). More... | |
| SparseMatrix (SizeType m, SizeType n) | |
| Constructs a sparse matrix of size \( m \times n \) with no stored entries. More... | |
| SparseMatrix (const SparseMatrix &m) | |
| Constructs a copy of the sparse matrix m. More... | |
| SparseMatrix (SparseMatrix &&m) | |
| Move-constructs a sparse matrix from m (m is left in a valid empty state). More... | |
| SparseMatrix (InitializerListType l) | |
| Constructs a sparse matrix from the initializer list of rows l. More... | |
| template<typename E > | |
| SparseMatrix (const MatrixExpression< E > &e) | |
| Constructs a sparse matrix from the matrix expression e. More... | |
| Reference | operator() (SizeType i, SizeType j) |
| Returns a mutable proxy reference to the element at (i, j). More... | |
| ConstReference | operator() (SizeType i, SizeType j) const |
Returns a const reference to the element at (i, j). More... | |
| SizeType | getNumElements () const |
| Returns the number of explicitly stored (non-default) entries. More... | |
| bool | isEmpty () const |
| Tells whether the matrix is empty (zero rows or zero columns). More... | |
| SizeType | getSize1 () const |
| Returns the logical number of rows. More... | |
| SizeType | getSize2 () const |
| Returns the logical number of columns. More... | |
| ArrayType::size_type | getMaxSize () const |
| Returns the maximum number of stored entries the underlying associative container can hold. More... | |
| ArrayType & | getData () |
| Returns a mutable reference to the underlying associative container of stored entries. More... | |
| const ArrayType & | getData () const |
Returns a const reference to the underlying associative container of stored entries. More... | |
| SparseMatrix & | operator= (const SparseMatrix &m) |
| Copy-assigns the contents of m to this sparse matrix. More... | |
| SparseMatrix & | operator= (SparseMatrix &&m) |
| Move-assigns the contents of m to this sparse matrix. More... | |
| template<typename C > | |
| SparseMatrix & | operator= (const MatrixContainer< C > &c) |
| Assigns the contents of the matrix container c to this sparse matrix (no alias check needed). More... | |
| SparseMatrix & | operator= (InitializerListType l) |
| Assigns the rows in l to this sparse matrix (resizes to match). More... | |
| template<typename E > | |
| SparseMatrix & | operator= (const MatrixExpression< E > &e) |
| Assigns the matrix expression e to this sparse matrix (via a temporary to handle aliasing). More... | |
| template<typename C > | |
| SparseMatrix & | operator+= (const MatrixContainer< C > &c) |
| Adds the contents of the matrix container c element-wise to this sparse matrix (no alias check needed). More... | |
| SparseMatrix & | operator+= (InitializerListType l) |
| Adds the rows in l element-wise to this sparse matrix. More... | |
| template<typename E > | |
| SparseMatrix & | operator+= (const MatrixExpression< E > &e) |
| Adds the matrix expression e element-wise to this sparse matrix (via a temporary to handle aliasing). More... | |
| template<typename C > | |
| SparseMatrix & | operator-= (const MatrixContainer< C > &c) |
| Subtracts the contents of the matrix container c element-wise from this sparse matrix (no alias check needed). More... | |
| SparseMatrix & | operator-= (InitializerListType l) |
| Subtracts the rows in l element-wise from this sparse matrix. More... | |
| template<typename E > | |
| SparseMatrix & | operator-= (const MatrixExpression< E > &e) |
| Subtracts the matrix expression e element-wise from this sparse matrix (via a temporary to handle aliasing). More... | |
| template<typename T1 > | |
| std::enable_if< IsScalar< T1 >::value, SparseMatrix >::type & | operator*= (const T1 &t) |
| Multiplies every stored entry by the scalar t. More... | |
| template<typename T1 > | |
| std::enable_if< IsScalar< T1 >::value, SparseMatrix >::type & | operator/= (const T1 &t) |
| Divides every stored entry by the scalar t. More... | |
| template<typename E > | |
| SparseMatrix & | assign (const MatrixExpression< E > &e) |
| Resizes this matrix to match e and assigns its elements without intermediate temporary. More... | |
| SparseMatrix & | assign (InitializerListType l) |
| Resizes this matrix to match l and assigns its elements. More... | |
| template<typename E > | |
| SparseMatrix & | plusAssign (const MatrixExpression< E > &e) |
| Adds the elements of the matrix expression e to this matrix without intermediate temporary. More... | |
| SparseMatrix & | plusAssign (InitializerListType l) |
| Adds the rows in l element-wise to this matrix without intermediate temporary. More... | |
| template<typename E > | |
| SparseMatrix & | minusAssign (const MatrixExpression< E > &e) |
| Subtracts the elements of the matrix expression e from this matrix without intermediate temporary. More... | |
| SparseMatrix & | minusAssign (InitializerListType l) |
| Subtracts the rows in l element-wise from this matrix without intermediate temporary. More... | |
| void | swap (SparseMatrix &m) |
| Swaps the contents of this sparse matrix with those of m. More... | |
| void | clear () |
| Removes all explicitly stored entries (the logical dimensions remain unchanged). More... | |
| void | resize (SizeType m, SizeType n) |
| Resizes the logical dimensions to \( m \times n \), dropping any stored entries that fall outside the new bounds. More... | |
Public Member Functions inherited from CDPL::Math::MatrixContainer< SparseMatrix< T, std::unordered_map< std::uint64_t, T > > > | |
| const ContainerType & | operator() () const |
Returns a const reference to the derived matrix container. More... | |
| ContainerType & | operator() () |
| Returns a reference to the derived matrix container. More... | |
Public Member Functions inherited from CDPL::Math::MatrixExpression< E > | |
| const ExpressionType & | operator() () const |
Returns a const reference to the derived matrix expression. More... | |
| ExpressionType & | operator() () |
| Returns a reference to the derived matrix expression. More... | |
Friends | |
| void | swap (SparseMatrix &m1, SparseMatrix &m2) |
| ADL-enabled free-function form of swap(). More... | |
Additional Inherited Members | |
Protected Member Functions inherited from CDPL::Math::MatrixContainer< SparseMatrix< T, std::unordered_map< std::uint64_t, T > > > | |
| MatrixContainer () | |
| ~MatrixContainer () | |
Protected Member Functions inherited from CDPL::Math::MatrixExpression< E > | |
| MatrixExpression () | |
| ~MatrixExpression () | |
Protected Member Functions inherited from CDPL::Math::Expression< E > | |
| Expression () | |
| ~Expression () | |
Sparse matrix that stores only non-default entries keyed by a packed (row, column) identifier.
| T | The scalar value type. |
| A | The underlying associative container type (default: std::unordered_map keyed by std::uint64_t). |
| typedef T CDPL::Math::SparseMatrix< T, A >::ValueType |
The scalar value type.
| typedef A::key_type CDPL::Math::SparseMatrix< T, A >::KeyType |
The packed (row, column) key type used by the underlying associative container.
| typedef SparseContainerElement<SelfType> CDPL::Math::SparseMatrix< T, A >::Reference |
Mutable reference type (a proxy object that inserts on assignment to a previously-absent cell).
| typedef const T& CDPL::Math::SparseMatrix< T, A >::ConstReference |
Constant reference type to a stored element value.
| typedef std::uint32_t CDPL::Math::SparseMatrix< T, A >::SizeType |
The unsigned size type.
| typedef std::ptrdiff_t CDPL::Math::SparseMatrix< T, A >::DifferenceType |
The signed difference type.
| typedef A CDPL::Math::SparseMatrix< T, A >::ArrayType |
The underlying associative container type.
| typedef T* CDPL::Math::SparseMatrix< T, A >::Pointer |
Pointer type for raw access to stored entries.
| typedef const T* CDPL::Math::SparseMatrix< T, A >::ConstPointer |
Constant pointer type for raw access to stored entries.
| typedef MatrixReference<SelfType> CDPL::Math::SparseMatrix< T, A >::ClosureType |
Closure type used when this matrix appears inside another expression.
| typedef const MatrixReference<const SelfType> CDPL::Math::SparseMatrix< T, A >::ConstClosureType |
Constant closure type used when this matrix appears inside another expression.
| typedef SelfType CDPL::Math::SparseMatrix< T, A >::MatrixTemporaryType |
Concrete temporary matrix type used by expression-template machinery.
| typedef Vector<T, std::vector<T> > CDPL::Math::SparseMatrix< T, A >::VectorTemporaryType |
Concrete temporary vector type used when assembling vectors from this matrix.
| typedef std::shared_ptr<SelfType> CDPL::Math::SparseMatrix< T, A >::SharedPointer |
A reference-counted smart pointer [SHPTR] for dynamically allocated SparseMatrix instances.
| typedef std::initializer_list<std::initializer_list<T> > CDPL::Math::SparseMatrix< T, A >::InitializerListType |
The initializer-list-of-rows type accepted by constructors and assignment.
|
inline |
Constructs an empty sparse matrix (zero rows, zero columns, no stored entries).
|
inline |
Constructs a sparse matrix of size \( m \times n \) with no stored entries.
| m | The number of rows. |
| n | The number of columns. |
| Base::SizeError | if \( m \cdot n \) exceeds the underlying container's capacity. |
|
inline |
Constructs a copy of the sparse matrix m.
| m | The sparse matrix to copy. |
|
inline |
Move-constructs a sparse matrix from m (m is left in a valid empty state).
| m | The sparse matrix to move from. |
|
inline |
Constructs a sparse matrix from the initializer list of rows l.
| l | The initializer list of rows. |
|
inline |
Constructs a sparse matrix from the matrix expression e.
| E | The source matrix expression type. |
| e | The source matrix expression. |
| Base::SizeError | if the dimensions of e exceed the underlying container's capacity. |
|
inline |
Returns a mutable proxy reference to the element at (i, j).
| i | The zero-based row index. |
| j | The zero-based column index. |
| Base::IndexError | if either index is out of range. |
|
inline |
Returns a const reference to the element at (i, j).
| i | The zero-based row index. |
| j | The zero-based column index. |
const reference to the stored value, or to the zero element if no entry exists at (i, j). | Base::IndexError | if either index is out of range. |
|
inline |
Returns the number of explicitly stored (non-default) entries.
|
inline |
Tells whether the matrix is empty (zero rows or zero columns).
true if either dimension is zero, and false otherwise.
|
inline |
Returns the logical number of rows.
|
inline |
Returns the logical number of columns.
|
inline |
Returns the maximum number of stored entries the underlying associative container can hold.
|
inline |
Returns a mutable reference to the underlying associative container of stored entries.
|
inline |
Returns a const reference to the underlying associative container of stored entries.
const reference to the storage container.
|
inline |
Copy-assigns the contents of m to this sparse matrix.
| m | The source sparse matrix. |
|
inline |
Move-assigns the contents of m to this sparse matrix.
| m | The source sparse matrix (left in a valid but unspecified state). |
|
inline |
Assigns the contents of the matrix container c to this sparse matrix (no alias check needed).
| C | The source matrix container type. |
| c | The source matrix container. |
|
inline |
Assigns the rows in l to this sparse matrix (resizes to match).
| l | The initializer list of rows. |
|
inline |
Assigns the matrix expression e to this sparse matrix (via a temporary to handle aliasing).
| E | The source matrix expression type. |
| e | The source matrix expression. |
|
inline |
Adds the contents of the matrix container c element-wise to this sparse matrix (no alias check needed).
| C | The source matrix container type. |
| c | The source matrix container. |
|
inline |
Adds the rows in l element-wise to this sparse matrix.
| l | The initializer list of rows providing the addends. |
|
inline |
Adds the matrix expression e element-wise to this sparse matrix (via a temporary to handle aliasing).
| E | The source matrix expression type. |
| e | The source matrix expression. |
|
inline |
Subtracts the contents of the matrix container c element-wise from this sparse matrix (no alias check needed).
| C | The source matrix container type. |
| c | The source matrix container. |
|
inline |
Subtracts the rows in l element-wise from this sparse matrix.
| l | The initializer list of rows providing the subtrahends. |
|
inline |
Subtracts the matrix expression e element-wise from this sparse matrix (via a temporary to handle aliasing).
| E | The source matrix expression type. |
| e | The source matrix expression. |
|
inline |
Multiplies every stored entry by the scalar t.
| T1 | The scalar type. |
| t | The scalar multiplier. |
|
inline |
Divides every stored entry by the scalar t.
| T1 | The scalar type. |
| t | The scalar divisor. |
|
inline |
Resizes this matrix to match e and assigns its elements without intermediate temporary.
| E | The source matrix expression type. |
| e | The source matrix expression. |
|
inline |
Resizes this matrix to match l and assigns its elements.
| l | The initializer list of rows providing the new elements. |
|
inline |
Adds the elements of the matrix expression e to this matrix without intermediate temporary.
| E | The source matrix expression type. |
| e | The source matrix expression. |
|
inline |
Adds the rows in l element-wise to this matrix without intermediate temporary.
| l | The initializer list of rows providing the addends. |
|
inline |
Subtracts the elements of the matrix expression e from this matrix without intermediate temporary.
| E | The source matrix expression type. |
| e | The source matrix expression. |
|
inline |
Subtracts the rows in l element-wise from this matrix without intermediate temporary.
| l | The initializer list of rows providing the subtrahends. |
|
inline |
Swaps the contents of this sparse matrix with those of m.
| m | The sparse matrix to swap with. |
|
inline |
Removes all explicitly stored entries (the logical dimensions remain unchanged).
|
inline |
Resizes the logical dimensions to \( m \times n \), dropping any stored entries that fall outside the new bounds.
| m | The new row count. |
| n | The new column count. |
| Base::SizeError | if \( m \cdot n \) exceeds the underlying container's capacity. |
|
friend |
ADL-enabled free-function form of swap().
| m1 | The first sparse matrix. |
| m2 | The second sparse matrix. |