![]() |
Fleet
0.0.9
Inference in the LOT
|
#include <vector>
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... | |
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)
X | |
v |
void increment | ( | std::vector< T > & | v, |
const size_t | idx, | ||
T | count = 1 |
||
) |
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
v | |
start | |
len |
std::vector<T> slice | ( | const std::vector< T > & | v, |
const size_t | start | ||
) |
Take a slice of a vector until its end
v | |
start |