MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::sparse::util::sparse_accumulator< Value, SizeType > Class Template Reference

Sparse accumulator for assembling a sparse column. More...

#include <scatter.hpp>

Public Member Functions

 sparse_accumulator (SizeType n)
void clear ()
 Reset for a new column assembly. O(1) - just bumps the generation counter.
void scatter (SizeType i, const Value &val)
 Scatter value into position i: x[i] += val.
void store (SizeType i, const Value &val)
 Store value at position i (overwrite, don't accumulate).
bool is_set (SizeType i) const
 Check if position i has been touched in the current generation.
Value operator() (SizeType i) const
 Read value at position i. Returns 0 if not set.
Value & operator[] (SizeType i)
 Mutable access to value at position i.
const std::vector< SizeType > & indices () const
 Return the indices that have been touched in the current generation.
SizeType nnz () const
 Number of nonzeros currently accumulated.
SizeType size () const
 Dimension of the accumulator.

Detailed Description

template<typename Value, typename SizeType = std::size_t>
class mtl::sparse::util::sparse_accumulator< Value, SizeType >

Sparse accumulator for assembling a sparse column.

Uses a dense workspace with generation-based marking to avoid clearing. This is the "scatter" data structure from CSparse (cs_scatter).

Constructor & Destructor Documentation

◆ sparse_accumulator()

template<typename Value, typename SizeType = std::size_t>
mtl::sparse::util::sparse_accumulator< Value, SizeType >::sparse_accumulator ( SizeType n)
inlineexplicit

Member Function Documentation

◆ clear()

template<typename Value, typename SizeType = std::size_t>
void mtl::sparse::util::sparse_accumulator< Value, SizeType >::clear ( )
inline

Reset for a new column assembly. O(1) - just bumps the generation counter.

◆ indices()

template<typename Value, typename SizeType = std::size_t>
const std::vector< SizeType > & mtl::sparse::util::sparse_accumulator< Value, SizeType >::indices ( ) const
inline

Return the indices that have been touched in the current generation.

◆ is_set()

template<typename Value, typename SizeType = std::size_t>
bool mtl::sparse::util::sparse_accumulator< Value, SizeType >::is_set ( SizeType i) const
inline

Check if position i has been touched in the current generation.

◆ nnz()

template<typename Value, typename SizeType = std::size_t>
SizeType mtl::sparse::util::sparse_accumulator< Value, SizeType >::nnz ( ) const
inline

Number of nonzeros currently accumulated.

◆ operator()()

template<typename Value, typename SizeType = std::size_t>
Value mtl::sparse::util::sparse_accumulator< Value, SizeType >::operator() ( SizeType i) const
inline

Read value at position i. Returns 0 if not set.

◆ operator[]()

template<typename Value, typename SizeType = std::size_t>
Value & mtl::sparse::util::sparse_accumulator< Value, SizeType >::operator[] ( SizeType i)
inline

Mutable access to value at position i.

◆ scatter()

template<typename Value, typename SizeType = std::size_t>
void mtl::sparse::util::sparse_accumulator< Value, SizeType >::scatter ( SizeType i,
const Value & val )
inline

Scatter value into position i: x[i] += val.

If i hasn't been touched in the current generation, initializes to val.

◆ size()

template<typename Value, typename SizeType = std::size_t>
SizeType mtl::sparse::util::sparse_accumulator< Value, SizeType >::size ( ) const
inline

Dimension of the accumulator.

◆ store()

template<typename Value, typename SizeType = std::size_t>
void mtl::sparse::util::sparse_accumulator< Value, SizeType >::store ( SizeType i,
const Value & val )
inline

Store value at position i (overwrite, don't accumulate).


The documentation for this class was generated from the following file:
  • /home/runner/work/mtl5/mtl5/include/mtl/sparse/util/scatter.hpp