Chemical Data Processing Library C++ API - Version 1.4.0
Public Types | Public Member Functions | Friends | List of all members
CDPL::Math::SparseMatrix< T, A > Class Template Reference

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< SelfTypeReference
 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< SelfTypeClosureType
 Closure type used when this matrix appears inside another expression. More...
 
typedef const MatrixReference< const SelfTypeConstClosureType
 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< SelfTypeSharedPointer
 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...
 
ArrayTypegetData ()
 Returns a mutable reference to the underlying associative container of stored entries. More...
 
const ArrayTypegetData () const
 Returns a const reference to the underlying associative container of stored entries. More...
 
SparseMatrixoperator= (const SparseMatrix &m)
 Copy-assigns the contents of m to this sparse matrix. More...
 
SparseMatrixoperator= (SparseMatrix &&m)
 Move-assigns the contents of m to this sparse matrix. More...
 
template<typename C >
SparseMatrixoperator= (const MatrixContainer< C > &c)
 Assigns the contents of the matrix container c to this sparse matrix (no alias check needed). More...
 
SparseMatrixoperator= (InitializerListType l)
 Assigns the rows in l to this sparse matrix (resizes to match). More...
 
template<typename E >
SparseMatrixoperator= (const MatrixExpression< E > &e)
 Assigns the matrix expression e to this sparse matrix (via a temporary to handle aliasing). More...
 
template<typename C >
SparseMatrixoperator+= (const MatrixContainer< C > &c)
 Adds the contents of the matrix container c element-wise to this sparse matrix (no alias check needed). More...
 
SparseMatrixoperator+= (InitializerListType l)
 Adds the rows in l element-wise to this sparse matrix. More...
 
template<typename E >
SparseMatrixoperator+= (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 >
SparseMatrixoperator-= (const MatrixContainer< C > &c)
 Subtracts the contents of the matrix container c element-wise from this sparse matrix (no alias check needed). More...
 
SparseMatrixoperator-= (InitializerListType l)
 Subtracts the rows in l element-wise from this sparse matrix. More...
 
template<typename E >
SparseMatrixoperator-= (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 >
SparseMatrixassign (const MatrixExpression< E > &e)
 Resizes this matrix to match e and assigns its elements without intermediate temporary. More...
 
SparseMatrixassign (InitializerListType l)
 Resizes this matrix to match l and assigns its elements. More...
 
template<typename E >
SparseMatrixplusAssign (const MatrixExpression< E > &e)
 Adds the elements of the matrix expression e to this matrix without intermediate temporary. More...
 
SparseMatrixplusAssign (InitializerListType l)
 Adds the rows in l element-wise to this matrix without intermediate temporary. More...
 
template<typename E >
SparseMatrixminusAssign (const MatrixExpression< E > &e)
 Subtracts the elements of the matrix expression e from this matrix without intermediate temporary. More...
 
SparseMatrixminusAssign (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 ContainerTypeoperator() () const
 Returns a const reference to the derived matrix container. More...
 
ContainerTypeoperator() ()
 Returns a reference to the derived matrix container. More...
 
- Public Member Functions inherited from CDPL::Math::MatrixExpression< E >
const ExpressionTypeoperator() () const
 Returns a const reference to the derived matrix expression. More...
 
ExpressionTypeoperator() ()
 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 ()
 

Detailed Description

template<typename T, typename A = std::unordered_map<std::uint64_t, T>>
class CDPL::Math::SparseMatrix< T, A >

Sparse matrix that stores only non-default entries keyed by a packed (row, column) identifier.

Template Parameters
TThe scalar value type.
AThe underlying associative container type (default: std::unordered_map keyed by std::uint64_t).

Member Typedef Documentation

◆ ValueType

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
typedef T CDPL::Math::SparseMatrix< T, A >::ValueType

The scalar value type.

◆ KeyType

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
typedef A::key_type CDPL::Math::SparseMatrix< T, A >::KeyType

The packed (row, column) key type used by the underlying associative container.

◆ Reference

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
typedef SparseContainerElement<SelfType> CDPL::Math::SparseMatrix< T, A >::Reference

Mutable reference type (a proxy object that inserts on assignment to a previously-absent cell).

◆ ConstReference

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
typedef const T& CDPL::Math::SparseMatrix< T, A >::ConstReference

Constant reference type to a stored element value.

◆ SizeType

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
typedef std::uint32_t CDPL::Math::SparseMatrix< T, A >::SizeType

The unsigned size type.

◆ DifferenceType

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
typedef std::ptrdiff_t CDPL::Math::SparseMatrix< T, A >::DifferenceType

The signed difference type.

◆ ArrayType

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
typedef A CDPL::Math::SparseMatrix< T, A >::ArrayType

The underlying associative container type.

◆ Pointer

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
typedef T* CDPL::Math::SparseMatrix< T, A >::Pointer

Pointer type for raw access to stored entries.

◆ ConstPointer

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
typedef const T* CDPL::Math::SparseMatrix< T, A >::ConstPointer

Constant pointer type for raw access to stored entries.

◆ ClosureType

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
typedef MatrixReference<SelfType> CDPL::Math::SparseMatrix< T, A >::ClosureType

Closure type used when this matrix appears inside another expression.

◆ ConstClosureType

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
typedef const MatrixReference<const SelfType> CDPL::Math::SparseMatrix< T, A >::ConstClosureType

Constant closure type used when this matrix appears inside another expression.

◆ MatrixTemporaryType

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
typedef SelfType CDPL::Math::SparseMatrix< T, A >::MatrixTemporaryType

Concrete temporary matrix type used by expression-template machinery.

◆ VectorTemporaryType

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
typedef Vector<T, std::vector<T> > CDPL::Math::SparseMatrix< T, A >::VectorTemporaryType

Concrete temporary vector type used when assembling vectors from this matrix.

◆ SharedPointer

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
typedef std::shared_ptr<SelfType> CDPL::Math::SparseMatrix< T, A >::SharedPointer

A reference-counted smart pointer [SHPTR] for dynamically allocated SparseMatrix instances.

◆ InitializerListType

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
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.

Constructor & Destructor Documentation

◆ SparseMatrix() [1/6]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
CDPL::Math::SparseMatrix< T, A >::SparseMatrix ( )
inline

Constructs an empty sparse matrix (zero rows, zero columns, no stored entries).

◆ SparseMatrix() [2/6]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
CDPL::Math::SparseMatrix< T, A >::SparseMatrix ( SizeType  m,
SizeType  n 
)
inline

Constructs a sparse matrix of size \( m \times n \) with no stored entries.

Parameters
mThe number of rows.
nThe number of columns.
Exceptions
Base::SizeErrorif \( m \cdot n \) exceeds the underlying container's capacity.

◆ SparseMatrix() [3/6]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
CDPL::Math::SparseMatrix< T, A >::SparseMatrix ( const SparseMatrix< T, A > &  m)
inline

Constructs a copy of the sparse matrix m.

Parameters
mThe sparse matrix to copy.

◆ SparseMatrix() [4/6]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
CDPL::Math::SparseMatrix< T, A >::SparseMatrix ( SparseMatrix< T, A > &&  m)
inline

Move-constructs a sparse matrix from m (m is left in a valid empty state).

Parameters
mThe sparse matrix to move from.

◆ SparseMatrix() [5/6]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
CDPL::Math::SparseMatrix< T, A >::SparseMatrix ( InitializerListType  l)
inline

Constructs a sparse matrix from the initializer list of rows l.

Parameters
lThe initializer list of rows.

◆ SparseMatrix() [6/6]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
template<typename E >
CDPL::Math::SparseMatrix< T, A >::SparseMatrix ( const MatrixExpression< E > &  e)
inline

Constructs a sparse matrix from the matrix expression e.

Template Parameters
EThe source matrix expression type.
Parameters
eThe source matrix expression.
Exceptions
Base::SizeErrorif the dimensions of e exceed the underlying container's capacity.

Member Function Documentation

◆ operator()() [1/2]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
Reference CDPL::Math::SparseMatrix< T, A >::operator() ( SizeType  i,
SizeType  j 
)
inline

Returns a mutable proxy reference to the element at (i, j).

Parameters
iThe zero-based row index.
jThe zero-based column index.
Returns
A mutable proxy reference (creates a stored entry on first assignment).
Exceptions
Base::IndexErrorif either index is out of range.

◆ operator()() [2/2]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
ConstReference CDPL::Math::SparseMatrix< T, A >::operator() ( SizeType  i,
SizeType  j 
) const
inline

Returns a const reference to the element at (i, j).

Parameters
iThe zero-based row index.
jThe zero-based column index.
Returns
A const reference to the stored value, or to the zero element if no entry exists at (i, j).
Exceptions
Base::IndexErrorif either index is out of range.

◆ getNumElements()

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
SizeType CDPL::Math::SparseMatrix< T, A >::getNumElements ( ) const
inline

Returns the number of explicitly stored (non-default) entries.

Returns
The number of stored entries.

◆ isEmpty()

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
bool CDPL::Math::SparseMatrix< T, A >::isEmpty ( ) const
inline

Tells whether the matrix is empty (zero rows or zero columns).

Returns
true if either dimension is zero, and false otherwise.

◆ getSize1()

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
SizeType CDPL::Math::SparseMatrix< T, A >::getSize1 ( ) const
inline

Returns the logical number of rows.

Returns
The number of rows.

◆ getSize2()

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
SizeType CDPL::Math::SparseMatrix< T, A >::getSize2 ( ) const
inline

Returns the logical number of columns.

Returns
The number of columns.

◆ getMaxSize()

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
ArrayType::size_type CDPL::Math::SparseMatrix< T, A >::getMaxSize ( ) const
inline

Returns the maximum number of stored entries the underlying associative container can hold.

Returns
The maximum entry count.

◆ getData() [1/2]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
ArrayType& CDPL::Math::SparseMatrix< T, A >::getData ( )
inline

Returns a mutable reference to the underlying associative container of stored entries.

Returns
A mutable reference to the storage container.

◆ getData() [2/2]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
const ArrayType& CDPL::Math::SparseMatrix< T, A >::getData ( ) const
inline

Returns a const reference to the underlying associative container of stored entries.

Returns
A const reference to the storage container.

◆ operator=() [1/5]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::operator= ( const SparseMatrix< T, A > &  m)
inline

Copy-assigns the contents of m to this sparse matrix.

Parameters
mThe source sparse matrix.
Returns
A reference to itself.

◆ operator=() [2/5]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::operator= ( SparseMatrix< T, A > &&  m)
inline

Move-assigns the contents of m to this sparse matrix.

Parameters
mThe source sparse matrix (left in a valid but unspecified state).
Returns
A reference to itself.

◆ operator=() [3/5]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
template<typename C >
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::operator= ( const MatrixContainer< C > &  c)
inline

Assigns the contents of the matrix container c to this sparse matrix (no alias check needed).

Template Parameters
CThe source matrix container type.
Parameters
cThe source matrix container.
Returns
A reference to itself.

◆ operator=() [4/5]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::operator= ( InitializerListType  l)
inline

Assigns the rows in l to this sparse matrix (resizes to match).

Parameters
lThe initializer list of rows.
Returns
A reference to itself.

◆ operator=() [5/5]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
template<typename E >
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::operator= ( const MatrixExpression< E > &  e)
inline

Assigns the matrix expression e to this sparse matrix (via a temporary to handle aliasing).

Template Parameters
EThe source matrix expression type.
Parameters
eThe source matrix expression.
Returns
A reference to itself.

◆ operator+=() [1/3]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
template<typename C >
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::operator+= ( const MatrixContainer< C > &  c)
inline

Adds the contents of the matrix container c element-wise to this sparse matrix (no alias check needed).

Template Parameters
CThe source matrix container type.
Parameters
cThe source matrix container.
Returns
A reference to itself.

◆ operator+=() [2/3]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::operator+= ( InitializerListType  l)
inline

Adds the rows in l element-wise to this sparse matrix.

Parameters
lThe initializer list of rows providing the addends.
Returns
A reference to itself.

◆ operator+=() [3/3]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
template<typename E >
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::operator+= ( const MatrixExpression< E > &  e)
inline

Adds the matrix expression e element-wise to this sparse matrix (via a temporary to handle aliasing).

Template Parameters
EThe source matrix expression type.
Parameters
eThe source matrix expression.
Returns
A reference to itself.

◆ operator-=() [1/3]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
template<typename C >
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::operator-= ( const MatrixContainer< C > &  c)
inline

Subtracts the contents of the matrix container c element-wise from this sparse matrix (no alias check needed).

Template Parameters
CThe source matrix container type.
Parameters
cThe source matrix container.
Returns
A reference to itself.

◆ operator-=() [2/3]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::operator-= ( InitializerListType  l)
inline

Subtracts the rows in l element-wise from this sparse matrix.

Parameters
lThe initializer list of rows providing the subtrahends.
Returns
A reference to itself.

◆ operator-=() [3/3]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
template<typename E >
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::operator-= ( const MatrixExpression< E > &  e)
inline

Subtracts the matrix expression e element-wise from this sparse matrix (via a temporary to handle aliasing).

Template Parameters
EThe source matrix expression type.
Parameters
eThe source matrix expression.
Returns
A reference to itself.

◆ operator*=()

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
template<typename T1 >
std::enable_if<IsScalar<T1>::value, SparseMatrix>::type& CDPL::Math::SparseMatrix< T, A >::operator*= ( const T1 &  t)
inline

Multiplies every stored entry by the scalar t.

Template Parameters
T1The scalar type.
Parameters
tThe scalar multiplier.
Returns
A reference to itself.

◆ operator/=()

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
template<typename T1 >
std::enable_if<IsScalar<T1>::value, SparseMatrix>::type& CDPL::Math::SparseMatrix< T, A >::operator/= ( const T1 &  t)
inline

Divides every stored entry by the scalar t.

Template Parameters
T1The scalar type.
Parameters
tThe scalar divisor.
Returns
A reference to itself.

◆ assign() [1/2]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
template<typename E >
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::assign ( const MatrixExpression< E > &  e)
inline

Resizes this matrix to match e and assigns its elements without intermediate temporary.

Template Parameters
EThe source matrix expression type.
Parameters
eThe source matrix expression.
Returns
A reference to itself.

◆ assign() [2/2]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::assign ( InitializerListType  l)
inline

Resizes this matrix to match l and assigns its elements.

Parameters
lThe initializer list of rows providing the new elements.
Returns
A reference to itself.

◆ plusAssign() [1/2]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
template<typename E >
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::plusAssign ( const MatrixExpression< E > &  e)
inline

Adds the elements of the matrix expression e to this matrix without intermediate temporary.

Template Parameters
EThe source matrix expression type.
Parameters
eThe source matrix expression.
Returns
A reference to itself.

◆ plusAssign() [2/2]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::plusAssign ( InitializerListType  l)
inline

Adds the rows in l element-wise to this matrix without intermediate temporary.

Parameters
lThe initializer list of rows providing the addends.
Returns
A reference to itself.

◆ minusAssign() [1/2]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
template<typename E >
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::minusAssign ( const MatrixExpression< E > &  e)
inline

Subtracts the elements of the matrix expression e from this matrix without intermediate temporary.

Template Parameters
EThe source matrix expression type.
Parameters
eThe source matrix expression.
Returns
A reference to itself.

◆ minusAssign() [2/2]

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
SparseMatrix& CDPL::Math::SparseMatrix< T, A >::minusAssign ( InitializerListType  l)
inline

Subtracts the rows in l element-wise from this matrix without intermediate temporary.

Parameters
lThe initializer list of rows providing the subtrahends.
Returns
A reference to itself.

◆ swap()

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
void CDPL::Math::SparseMatrix< T, A >::swap ( SparseMatrix< T, A > &  m)
inline

Swaps the contents of this sparse matrix with those of m.

Parameters
mThe sparse matrix to swap with.

◆ clear()

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
void CDPL::Math::SparseMatrix< T, A >::clear ( )
inline

Removes all explicitly stored entries (the logical dimensions remain unchanged).

◆ resize()

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
void CDPL::Math::SparseMatrix< T, A >::resize ( SizeType  m,
SizeType  n 
)
inline

Resizes the logical dimensions to \( m \times n \), dropping any stored entries that fall outside the new bounds.

Parameters
mThe new row count.
nThe new column count.
Exceptions
Base::SizeErrorif \( m \cdot n \) exceeds the underlying container's capacity.

Friends And Related Function Documentation

◆ swap

template<typename T , typename A = std::unordered_map<std::uint64_t, T>>
void swap ( SparseMatrix< T, A > &  m1,
SparseMatrix< T, A > &  m2 
)
friend

ADL-enabled free-function form of swap().

Parameters
m1The first sparse matrix.
m2The second sparse matrix.

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