libgenua
Basic Geometry, Numerical Algorithms and Interfaces
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Public Member Functions | Private Attributes | List of all members
SparseBuilder< FloatType > Class Template Reference

Detailed Description

template<typename FloatType>
class SparseBuilder< FloatType >

Helper object for the assembly of sparse matrices.

SparseBuilder is intended to be used as a helper object for the parallel assembly of large sparse matrices, in particular in the case where the iteration over the range of generating objects is expensive so that only one single pass is to be performed. Furthermore, when the number of (row, column, value) triplets which will be generated in the process is known in advance, then the assembly procedure can be parallelized because each element can access disjoint storage locations.

The drawback is that SparseBuilder requires more temporary memory than other techniques such as the two-pass approach in ConnectMap, because matrix values are stored along with the coordinate pair, while the two- pass procedure only stores redundant column indices.

See Also
ConnectMap, CsrMatrix

#include <sparsebuilder.h>

Public Member Functions

 SparseBuilder (size_t n=0)
 initialize and reserve space
 
const_iterator begin () const
 access triplet range
 
const_iterator end () const
 access triplet range
 
void reserve (size_t n)
 reserve space
 
void resize (size_t n)
 resize triplet array
 
size_t size () const
 number of triplets present
 
Triplet & operator[] (size_t i)
 access triplet i
 
const Triplet & operator[] (size_t i) const
 access triplet i
 
void assign (size_t i, uint r, uint c, FloatType v)
 set triplet at index i
 
void append (uint row, uint col, FloatType v)
 append triplet
 
template<int M, int N>
void append (const uint row[], const uint col[], const FloatType v[])
 append MxN matrix of triplets (element assembly)
 
void merge (const SparseBuilder &a)
 merge with another builder
 
void mergeSorted (const SparseBuilder &a)
 merge with sorted builder
 
void sort (bool inparallel)
 sort in parallel, make unique
 
void clear ()
 clear values
 

Private Attributes

std::vector< Triplet > m_triplets
 collection of triplets
 

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