25#ifndef _GEMA_SPARSE_MATRIX_TRIPLET_DATA_H_
26#define _GEMA_SPARSE_MATRIX_TRIPLET_DATA_H_
43#if Q_BYTE_ORDER != Q_LITTLE_ENDIAN
44#error Invalid Triplet layout
47static_assert(2 *
sizeof(int) ==
sizeof(quint64),
"Unexpected int size in triplet layout");
58template <GmSparseMatrixLayoutTypes T>
74 int ptr()
const {
return _key[1]; }
77 int index()
const {
return _key[0]; }
88 return *((quint64*)(&_key[0])) < *((quint64*)(&other.
_key[0]));
95 : _key{ col, lin }, _value(val) {}
100 : _key{ lin, col }, _value(val) {}
119template <GmSparseMatrixLayoutTypes T>
137template <GmSparseMatrixLayoutTypes T>
149template <GmSparseMatrixLayoutTypes T>
A virtual class representing a buffer of T objects that can be appended in a thread-safe way,...
Definition gmAppendBuffer.h:66
An implementation of the GmAppendBuffer interface based on a "per thread" growing buffer.
Definition gmAppendBuffer.h:153
An implementation of the GmAppendBuffer interface based on synchoronized access to a shared buffer.
Definition gmAppendBuffer.h:403
Especialization of the GmPerThreadAppendBuffer class using the GmSparseMatrixTripletBuffer interface.
Definition gmSparseMatrixTripletData.h:151
GmSparseMatrixPerThreadTripletBuffer(size_t initSize, double resizeFactor=2.0, int numThreads=-1)
Buffer constructor. See the description for the GmPerThreadAppendBuffer constructor.
Definition gmSparseMatrixTripletData.h:154
virtual GmSparseMatrixTripletData< T > * sortedData(int nlin, GmSparseMatrixTripletBufferSortStrategy st)
Similar to data() but returning a sorted vector, obtained by using the given strategy....
Definition gmSparseMatrixTripletData.cpp:133
Especialization of the GmSingleAppendBuffer class using the GmSparseMatrixTripletBuffer interface.
Definition gmSparseMatrixTripletData.h:139
virtual GmSparseMatrixTripletData< T > * sortedData(int nlin, GmSparseMatrixTripletBufferSortStrategy st)
Similar to data() but returning a sorted vector, obtained by using the given strategy....
Definition gmSparseMatrixTripletData.cpp:63
GmSparseMatrixSingleTripletBuffer(size_t initSize, double resizeFactor=2.0, int numThreads=-1)
Buffer constructor. See the description for the GmSingleAppendBuffer constructor.
Definition gmSparseMatrixTripletData.h:142
An especialization of GmAppendBufffer for triplet data with an extra method for returning the buffer ...
Definition gmSparseMatrixTripletData.h:121
static const char * sortStrategyToStr(GmSparseMatrixTripletBufferSortStrategy st)
Returns the string used to define the given sort strategy.
Definition gmSparseMatrixTripletData.cpp:46
static int strToSortStrategy(const QString &str)
Returns the sort strategy associated with the given string. Returns -1 if no match was found.
Definition gmSparseMatrixTripletData.cpp:32
virtual GmSparseMatrixTripletData< T > * sortedData(int nlin, GmSparseMatrixTripletBufferSortStrategy st)=0
Similar to data() but returning a sorted vector, obtained by using the given strategy....
Declaration of the GmAppendBuffer class.
Declaration of useful configuration definitions for the Core library.
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
Declaration of the GmSparseMatrixLayout structure and its derived types.
GmSparseMatrixTripletBufferSortStrategy
The strategy used by the GmSparseMatrixTripletBuffer<T>::sortedData() methods.
Definition gmSparseMatrixTripletData.h:110
@ GM_TRIBUF_SS_ISORT_MERGE
Vectors are parallel inplace sorted, followed by a merge operation to the destination vector.
Definition gmSparseMatrixTripletData.h:112
@ GM_TRIBUF_SS_CONCAT_PCSORT
Vectors are concatenated and then parallel copy sorted. Faster when there is plenty of memory.
Definition gmSparseMatrixTripletData.h:111
Aux structure used when building sparse matrices with the help of a triplet list. The tripet structur...
Definition gmSparseMatrixTripletData.h:60
GmSparseMatrixTripletData()
Dummy constructor to allow using the structure inside a vector.
Definition gmSparseMatrixTripletData.h:71
GmSparseMatrixTripletData(int ptr, int index, double val, bool)
Alternate constructor receiving the ptr and the index values.
Definition gmSparseMatrixTripletData.h:68
bool operator<(const GmSparseMatrixTripletData< T > &other) const
Compare operator to enable sorting with standard sort routines. Not needed by integer sorting....
Definition gmSparseMatrixTripletData.h:84
double _value
The triplet value.
Definition gmSparseMatrixTripletData.h:62
GmSparseMatrixTripletData(int lin, int col, double val)
Constructor.
int index() const
Returns either the column (CSR) or line (CSC) data depending on the matrix format.
Definition gmSparseMatrixTripletData.h:77
int ptr() const
Returns either the line (CSR) or column (CSC) data depending on the matrix format.
Definition gmSparseMatrixTripletData.h:74
int _key[2]
Either column + line (CSR) or line + column (CSC), depending on the matrix format.
Definition gmSparseMatrixTripletData.h:61