Allocators are used to allocate and deallocate memory. The last template argument of vectors and matrices is the allocator. For a vector: Vector<double, Vect_Full, CallocAlloc<double> >. CallocAlloc is an allocator based on calloc. MallocAlloc is another allocator based on malloc. The third available allocator is NewAlloc, based on new. The last one is NaNAlloc, based on malloc and which initializes allocated elements to "not a number". If a vector or a matrix managed by NaNAlloc is not properly filled, there will still be NaNs in the vector or the matrix, which is easy to detect.

The default allocator is MallocAlloc. The default allocator may be changed thanks to SELDON_DEFAULT_ALLOCATOR:

define SELDON_DEFAULT_ALLOCATOR NewAlloc defines NewAlloc as the default allocator. This line must be put before Seldon.hxx is included. We strongly encourage beginner to set NewAlloc as the default allocator since only this allocator will call constructors of objects contained in the vector. This property is essential when the elements of the vector are C++ classes.

#include "Seldon.hxx"

using namespace Seldon;

// For vector containing integers, MallocAlloc is okay
Vector<int, Vect_Full, MallocAlloc<int> > X;

// For vector containing vectors, NewAlloc is needed
Vector<Vector<double> > Xvec;