Fleet  0.0.9
Inference in the LOT
Functions
Vectors.h File Reference
#include <vector>
Include dependency graph for Vectors.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T >
std::vector< T > slice (const std::vector< T > &v, const size_t start, const int len)
 
template<typename T >
std::vector< T > slice (const std::vector< T > &v, const size_t start)
 
template<typename T >
void increment (std::vector< T > &v, const size_t idx, T count=1)
 
template<typename T >
void glom (std::vector< std::vector< T > *> &X, std::vector< T > *&v)
 Glom here takes a vector of pointers to vectors. It searches through X to find if anything matches the beginning of v, and if so, it will append the additional elements, and use the existing data. It then MODIFIES the v pointer (which is passed by reference). If no match can be found, glom will append v into x. More...
 

Function Documentation

◆ glom()

template<typename T >
void glom ( std::vector< std::vector< T > *> &  X,
std::vector< T > *&  v 
)

Glom here takes a vector of pointers to vectors. It searches through X to find if anything matches the beginning of v, and if so, it will append the additional elements, and use the existing data. It then MODIFIES the v pointer (which is passed by reference). If no match can be found, glom will append v into x.

Thus, at the end of this, v points to something in X, but preferentially re-uses data in X. This is especially useful when we're compiling incremental data for learning models.

NOTE: that sizes must be stored externally, since if a vector is stored in here, it may be appended to (so whatever is using X can't just compute the size)

This is used primarily for GrammarHypothesis storage of MCMC data, where we want to load multiple datasets and share overlap whenever possible (so we don't duplicate MCMC sampling)

Parameters
X
v
Returns
This returns a (possibly) new pointer for v. That is, it will either leave v unchanged or it will point to something in x

◆ increment()

template<typename T >
void increment ( std::vector< T > &  v,
const size_t  idx,
count = 1 
)

◆ slice() [1/2]

template<typename T >
std::vector<T> slice ( const std::vector< T > &  v,
const size_t  start,
const int  len 
)

Take a slice of a vector v starting at start of length len

Parameters
v
start
len
Returns

◆ slice() [2/2]

template<typename T >
std::vector<T> slice ( const std::vector< T > &  v,
const size_t  start 
)

Take a slice of a vector until its end

Parameters
v
start
Returns