dune-istl 2.10
|
Stores the nonzero entries for creating a sparse matrix. More...
#include <dune/istl/matrixindexset.hh>
Public Types | |
using | size_type = Index |
Public Member Functions | |
MatrixIndexSet (size_type maxVectorSize=defaultMaxVectorSize) noexcept | |
Constructor with custom maxVectorSize. | |
MatrixIndexSet (size_type rows, size_type cols, size_type maxVectorSize=defaultMaxVectorSize) | |
Constructor setting the matrix size. | |
void | resize (size_type rows, size_type cols) |
Reset the size of an index set. | |
void | add (size_type row, size_type col) |
Add an index to the index set. | |
size_type | size () const |
Return the number of entries. | |
size_type | rows () const |
Return the number of rows. | |
size_type | cols () const |
Return the number of columns. | |
const auto & | columnIndices (size_type row) const |
Return column indices of entries in given row. | |
size_type | rowsize (size_type row) const |
Return the number of entries in a given row. | |
template<class MatrixType > | |
void | import (const MatrixType &m, size_type rowOffset=0, size_type colOffset=0) |
Import all nonzero entries of a sparse matrix into the index set. | |
template<class MatrixType > | |
void | exportIdx (MatrixType &matrix) const |
Initializes a BCRSMatrix with the indices contained in this MatrixIndexSet. | |
Static Public Attributes | |
static constexpr size_type | defaultMaxVectorSize = 2048 |
Default value for maxVectorSize. | |
Stores the nonzero entries for creating a sparse matrix.
This stores std::set-like container for the column index of each row. A sorted std::vector is used for this container up to a customizable maxVectorSize. If this size is exceeded, storage of the corresponding row is switched to std::set.
The default value for maxVectorSize works well and ensures that the slow std::set fallback is only used for very dense rows.
This class is thread safe in the sense that concurrent calls to all const methods and furthermore to add(row,col) with different rows in each thread are safe.
using Dune::MatrixIndexSet::size_type = Index |
|
inlinenoexcept |
Constructor with custom maxVectorSize.
maxVectorSize | Maximal size for stored row vector (default is defaultMaxVectorSize). |
|
inline |
Constructor setting the matrix size.
rows | Number of matrix rows |
cols | Number of matrix columns |
maxVectorSize | Maximal size for stored row vector (default is defaultMaxVectorSize). |
Add an index to the index set.
It is safe to call add(row, col) for different rows in concurrent threads, but it is not safe to do concurrent calls for the same row, even for different columns.
|
inline |
Return the number of columns.
|
inline |
Return column indices of entries in given row.
This returns a range of all column indices that have been added for the given column. Since there are different internal implementations of this range, the result is stored in a std::variant<...> which has to be accessed using std::visit
.
|
inline |
Initializes a BCRSMatrix with the indices contained in this MatrixIndexSet.
MatrixType | Needs to be BCRSMatrix<...> |
matrix | reference to the MatrixType object |
|
inline |
Import all nonzero entries of a sparse matrix into the index set.
MatrixType | Needs to be BCRSMatrix<...> |
m | reference to the MatrixType object |
rowOffset | don't write to rows<rowOffset |
colOffset | don't write to cols<colOffset |
Reset the size of an index set.
|
inline |
Return the number of rows.
Return the number of entries in a given row.
|
inline |
Return the number of entries.
|
staticconstexpr |
Default value for maxVectorSize.
This was selected after benchmarking for the worst case of reverse insertion of column indices. In many applications this works well. There's no need to use a different value unless you have many dense rows with more than defaultMaxVectorSize nonzero entries. Even in this case defaultMaxVectorSize may work well and a finding a better value may require careful benchmarking.