|
SpECTRE
v2025.08.19
|
A simple fast sparse matrix. More...
#include <SimpleSparseMatrix.hpp>
Public Member Functions | |
| void | fill (const std::vector< SparseMatrixElement > &data) |
| Fills with data. Normally called only by SparseMatrixFiller. ASSUMES that data has already been sorted by row, then column. | |
| template<typename T > | |
| void | increment_multiply_on_right (gsl::not_null< T * > a, size_t a_offset, const T &b, size_t b_offset) const |
| Does a += m*b where m is the sparse matrix. T is a container of doubles, like a std::vector<double>. Assumes b points into contiguous storage that allows one to access b[i] for b_offset <= i <= b_offset+max(column_indices). Assumes a points into contiguous storage that allows one to access a[i] for a_offset <= a <= a_offset+max(row_indices). | |
| size_t | size () const |
| Number of nonzero elements. | |
| double | operator() (size_t row_dest_index, size_t column_src_index) const |
| Obtains element at (destindex,srcindex). Slow, should not use very often in critical situations. | |
A simple fast sparse matrix.
Supports only a limited number of operations to keep it simple: filling the matrix, accessing elements, and multiplication by a vector on the right.
We use SimpleSparseMatrix because filling a Blaze sparse matrix is enormously slow. For example, here are timings for creating a rank-one TensorYlmFilter sparse matrix using SimpleSparseMatrix (column labeled "this") and using blaze::CompressedMatrix (column labeled "Blaze"). The column "Blaze-wo-blaze" is the same as the "Blaze" column (which includes timing of all the TensorYlmFilter code that doesn't explicitly depend on blaze) minus the timings of the blaze calls that 1. resize the matrix, 2. reserve elements, and
8 0ms 5ms 1ms 1ms 2ms 0ms 18 1ms 101ms 2ms 39ms 51ms 8ms 28 3ms 479ms 3ms 181ms 246ms 48ms 38 4ms 1555ms 4ms 571ms 822ms 157ms 48 5ms 3668ms 6ms 1395ms 1873ms 393ms 58 6ms 7604ms 6ms 2908ms 3855ms 832ms 68 7ms 14176ms 8ms 5416ms 7214ms 1536ms 78 8ms 24234ms 8ms 9288ms 12304ms 2632ms