36#ifndef STK_MEMSALLOCATOR_H
37#define STK_MEMSALLOCATOR_H
39#include "../STK_Array1D.h"
45template<
typename Type_,
int NzMax_ = UnknownSize,
int Size_ = UnknownSize>
59template<
typename Type_,
int NzMax_,
int Size_>
181template<
typename Type_,
int NzMax_,
int Size_>
185 {
if (idx_[
t].first ==
s_idx)
return idx_[
t].second;}
194template<
typename Type_,
int NzMax_,
int Size_>
200 if (idx_[
t].first ==
s_idx)
202 if (value !=
zero_) { idx_[
t].second = value;}
210 else if (idx_[
t].first >
s_idx)
212 if (value ==
zero_)
return;
220 if (value ==
zero_)
return;
memory allocator for sparse Array classes.
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)
Allocator const & idx() const
Allocator idx_
array of pair(idx, value)
MemSAllocator()
default constructor
const Type zero_
zero value
TypeConst getValue(int p_idx, int s_idx) const
This method allows to get the element (p_idx, s_idx)
void setIdx(Allocator const &idx)
Array1D< IndexedValue, NzMax_ > Allocator
Type of the base allocator allocating data.
std::pair< int, Type > IndexedValue
values stored by pair (row/column index, value)
MemSAllocator(AllocatorRange const &I)
constructor with specified dimension
void setPtr(PtrIdx const &ptr)
TRange< Size_ > AllocatorRange
MemSAllocator(MemSAllocator const &A, Range const &I)
reference constructor
void set(PtrIdx const &ptr, Allocator const &idx)
MemSAllocator(MemSAllocator const &A, bool ref=false)
copy constructor
PtrIdx const & ptr() const
Array1D< int, size_ > PtrIdx
Type of the base allocator allocating index pointer.
PtrIdx ptr_
array of pointer
hidden::RemoveConst< Type_ >::Type const & TypeConst
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Index sub-vector region: Specialization when the size is unknown.
Range incLast(TRange< SizeI_ > const &I)
if I=a:b, return a:b+1
const int UnknownSize
This value means that an integer is not known at compile-time, and that instead the value is stored i...
const int baseIdx
base index of the containers created in STK++.
The namespace STK is the main domain space of the Statistical ToolKit project.
Arithmetic properties of STK fundamental types.
void setRef(bool ref) const
Modify the container : can become a reference or the owner of the data.