STK++ 0.9.13
|
memory allocator for sparse Array classes. More...
#include <STK_MemSAllocator.h>
Public Types | |
enum | { nzmax_ = NzMax_ , size_ = (Size_< (UnknownSize-1)) ? Size_+1 : UnknownSize } |
typedef Type_ | Type |
typedef hidden::RemoveConst< Type_ >::Type const & | TypeConst |
typedef std::pair< int, Type > | IndexedValue |
values stored by pair (row/column index, value) | |
typedef Array1D< IndexedValue, NzMax_ > | Allocator |
Type of the base allocator allocating data. | |
typedef Array1D< int, size_ > | PtrIdx |
Type of the base allocator allocating index pointer. | |
typedef TRange< Size_ > | AllocatorRange |
Public Member Functions | |
MemSAllocator () | |
default constructor | |
MemSAllocator (AllocatorRange const &I) | |
constructor with specified dimension | |
MemSAllocator (MemSAllocator const &A, bool ref=false) | |
copy constructor | |
MemSAllocator (MemSAllocator const &A, Range const &I) | |
reference constructor | |
int | begin () const |
int | end () const |
int | size () const |
PtrIdx const & | ptr () const |
Allocator const & | idx () const |
void | setPtr (PtrIdx const &ptr) |
void | setIdx (Allocator const &idx) |
void | set (PtrIdx const &ptr, Allocator const &idx) |
TypeConst | getValue (int p_idx, int s_idx) const |
This method allows to get the element (p_idx, s_idx) | |
void | addValue (int p_idx, int s_idx, Type const &value) |
This method allows to overwrite or insert an element to the position (p_idx, s_idx) | |
bool | isRef () const |
void | setRef (bool ref) const |
Modify the container : can become a reference or the owner of the data. | |
![]() | |
bool | isRef () const |
bool | ref () const |
void | exchange (TRef const &T) |
swap this with the container T. | |
void | setRef (bool ref) const |
Modify the container : can become a reference or the owner of the data. | |
Protected Attributes | |
PtrIdx | ptr_ |
array of pointer | |
Allocator | idx_ |
array of pair(idx, value) | |
Private Attributes | |
const Type | zero_ |
zero value | |
Additional Inherited Members | |
![]() | |
TRef (bool ref) | |
Default constructor We have to specify the member ref_. | |
~TRef () | |
destructor. | |
memory allocator for sparse Array classes.
The data are stored either in the compressed sparse row (CSR) format or compressed sparse column (CSC) format. This Allocator does not assume any orientation and can be used for both kind of storage.
Type_ | type of elements stored in this allocator |
NzMax_ | maximal number of element in sparse matrix |
Size_ | size (if known): number of rows (columns) |
Definition at line 60 of file STK_MemSAllocator.h.
typedef Array1D<IndexedValue, NzMax_> STK::MemSAllocator< Type_, NzMax_, Size_ >::Allocator |
Type of the base allocator allocating data.
Can be of fixed size NzMax_
Definition at line 78 of file STK_MemSAllocator.h.
Definition at line 83 of file STK_MemSAllocator.h.
values stored by pair (row/column index, value)
Definition at line 72 of file STK_MemSAllocator.h.
Type of the base allocator allocating index pointer.
Can be of fixed size Size_
Definition at line 80 of file STK_MemSAllocator.h.
typedef Type_ STK::MemSAllocator< Type_, NzMax_, Size_ >::Type |
Definition at line 69 of file STK_MemSAllocator.h.
typedef hidden::RemoveConst<Type_>::Type const& STK::MemSAllocator< Type_, NzMax_, Size_ >::TypeConst |
Definition at line 70 of file STK_MemSAllocator.h.
Enumerator | |
---|---|
nzmax_ | |
size_ |
Definition at line 63 of file STK_MemSAllocator.h.
|
inline |
default constructor
Definition at line 86 of file STK_MemSAllocator.h.
References STK::baseIdx, STK::MemSAllocator< Type_, NzMax_, Size_ >::idx_, STK::MemSAllocator< Type_, NzMax_, Size_ >::ptr_, and STK::MemSAllocator< Type_, NzMax_, Size_ >::zero_.
|
inline |
constructor with specified dimension
I | range of the rows (or columns) |
Definition at line 97 of file STK_MemSAllocator.h.
References STK::baseIdx, STK::MemSAllocator< Type_, NzMax_, Size_ >::idx_, STK::MemSAllocator< Type_, NzMax_, Size_ >::ptr_, and STK::MemSAllocator< Type_, NzMax_, Size_ >::zero_.
|
inline |
copy constructor
A | allocator to copy |
ref | true if this copy is just a reference, false otherwise |
Definition at line 109 of file STK_MemSAllocator.h.
|
inline |
reference constructor
A | allocator to copy |
I | range of the rows/columns to reference |
Definition at line 119 of file STK_MemSAllocator.h.
void STK::MemSAllocator< Type_, NzMax_, Size_ >::addValue | ( | int | p_idx, |
int | s_idx, | ||
Type const & | value | ||
) |
This method allows to overwrite or insert an element to the position (p_idx, s_idx)
p_idx | index of the row (respectively column) |
s_idx | index of the column (respectively row) |
value | value to set |
Definition at line 195 of file STK_MemSAllocator.h.
References STK::zero_.
|
inline |
Definition at line 128 of file STK_MemSAllocator.h.
References STK::IArray1D< Derived >::begin(), and STK::MemSAllocator< Type_, NzMax_, Size_ >::ptr_.
|
inline |
Definition at line 130 of file STK_MemSAllocator.h.
References STK::IArray1D< Derived >::end(), and STK::MemSAllocator< Type_, NzMax_, Size_ >::ptr_.
MemSAllocator< Type_, NzMax_, Size_ >::TypeConst STK::MemSAllocator< Type_, NzMax_, Size_ >::getValue | ( | int | p_idx, |
int | s_idx | ||
) | const |
This method allows to get the element (p_idx, s_idx)
p_idx | the index of the row (or column) |
s_idx | the index of the column (or row) |
Definition at line 182 of file STK_MemSAllocator.h.
References STK::zero_.
|
inline |
Definition at line 137 of file STK_MemSAllocator.h.
References STK::MemSAllocator< Type_, NzMax_, Size_ >::idx_.
Referenced by STK::MemSAllocator< Type_, NzMax_, Size_ >::set(), and STK::MemSAllocator< Type_, NzMax_, Size_ >::setIdx().
true
if *this is reference container, false
otherwise Definition at line 81 of file STK_IContainerRef.h.
|
inline |
Definition at line 135 of file STK_MemSAllocator.h.
References STK::MemSAllocator< Type_, NzMax_, Size_ >::ptr_.
Referenced by STK::MemSAllocator< Type_, NzMax_, Size_ >::set(), and STK::MemSAllocator< Type_, NzMax_, Size_ >::setPtr().
|
inline |
ptr | vector with the pointers on rows (or columns) |
idx | vector with the (index,value) pairs in columns (or rows) |
Definition at line 147 of file STK_MemSAllocator.h.
References STK::MemSAllocator< Type_, NzMax_, Size_ >::idx(), STK::MemSAllocator< Type_, NzMax_, Size_ >::idx_, STK::MemSAllocator< Type_, NzMax_, Size_ >::ptr(), and STK::MemSAllocator< Type_, NzMax_, Size_ >::ptr_.
idx | vector with the (index,value) pairs in columns (or rows) |
Definition at line 143 of file STK_MemSAllocator.h.
References STK::MemSAllocator< Type_, NzMax_, Size_ >::idx(), and STK::MemSAllocator< Type_, NzMax_, Size_ >::idx_.
ptr | vector with the pointers on rows (or columns) |
Definition at line 141 of file STK_MemSAllocator.h.
References STK::MemSAllocator< Type_, NzMax_, Size_ >::ptr(), and STK::MemSAllocator< Type_, NzMax_, Size_ >::ptr_.
Modify the container : can become a reference or the owner of the data.
To use with care if we want to avoid memory leak.
ref | : false if this own its own data. |
Definition at line 92 of file STK_IContainerRef.h.
|
inline |
Definition at line 132 of file STK_MemSAllocator.h.
References STK::MemSAllocator< Type_, NzMax_, Size_ >::ptr_, and STK::IArray1D< Derived >::size().
|
protected |
array of pair(idx, value)
Definition at line 168 of file STK_MemSAllocator.h.
Referenced by STK::MemSAllocator< Type_, NzMax_, Size_ >::idx(), STK::MemSAllocator< Type_, NzMax_, Size_ >::MemSAllocator(), STK::MemSAllocator< Type_, NzMax_, Size_ >::MemSAllocator(), STK::MemSAllocator< Type_, NzMax_, Size_ >::set(), and STK::MemSAllocator< Type_, NzMax_, Size_ >::setIdx().
|
protected |
array of pointer
Definition at line 166 of file STK_MemSAllocator.h.
Referenced by STK::MemSAllocator< Type_, NzMax_, Size_ >::begin(), STK::MemSAllocator< Type_, NzMax_, Size_ >::end(), STK::MemSAllocator< Type_, NzMax_, Size_ >::MemSAllocator(), STK::MemSAllocator< Type_, NzMax_, Size_ >::MemSAllocator(), STK::MemSAllocator< Type_, NzMax_, Size_ >::ptr(), STK::MemSAllocator< Type_, NzMax_, Size_ >::set(), STK::MemSAllocator< Type_, NzMax_, Size_ >::setPtr(), and STK::MemSAllocator< Type_, NzMax_, Size_ >::size().
|
private |
zero value
Definition at line 172 of file STK_MemSAllocator.h.
Referenced by STK::MemSAllocator< Type_, NzMax_, Size_ >::MemSAllocator(), and STK::MemSAllocator< Type_, NzMax_, Size_ >::MemSAllocator().