libmoost
moost::algorithm Namespace Reference

Classes

struct  FastHashFunctor
 functor that uses fast_hash More...
class  ketama_partitioner
 ketama_partitioner implements consistent hashing, such that the addition or removal of buckets does not significantly change the mapping of keys to buckets. By using consistent hashing, only K/n keys need to be remapped on average, where K is the number of keys, and n is the number of buckets. More...
class  modulo_partitioner
 modulo_partitioner hashes the key then modulos the result against the number of buckets. This results in an even spread given a reasonable hasher. More...
class  partitioner
 A partitioner can assign templatized types to a specified number of buckets. More...
struct  SimpleAccumulatorPolicy
class  spline_interpolation
 Generate a spline interpolation of X and Y data points using the GNU Scientific Library. More...
struct  variable_length_encoding

Typedefs

typedef FastHashFunctor FastHash

Functions

size_t fast_hash (const void *data_in, size_t size, size_t seed=DEFAULT_SEED)
 free hash function
template<class ForwardIterator , class InputIterator >
ForwardIterator inplace_set_intersection (ForwardIterator first1, ForwardIterator last1, InputIterator first2, InputIterator last2)
template<class ForwardIterator , class InputIterator , class StrictWeakOrdering >
ForwardIterator inplace_set_intersection (ForwardIterator first1, ForwardIterator last1, InputIterator first2, InputIterator last2, StrictWeakOrdering comp)
template<typename FloatType , class ForwardIteratorX , class WeightAccessPolicyX , class ForwardIteratorY , class WeightAccessPolicyY , class AccumulatorPolicy >
FloatType cosine_similarity (ForwardIteratorX x_beg, ForwardIteratorX x_end, WeightAccessPolicyX x_weight, ForwardIteratorY y_beg, ForwardIteratorY y_end, WeightAccessPolicyY y_weight, AccumulatorPolicy &accu)
template<typename FloatType , class ForwardIteratorX , class WeightAccessPolicyX , class ForwardIteratorY , class WeightAccessPolicyY >
FloatType cosine_similarity (ForwardIteratorX x_beg, ForwardIteratorX x_end, WeightAccessPolicyX x_weight, ForwardIteratorY y_beg, ForwardIteratorY y_end, WeightAccessPolicyY y_weight)

Variables

static const size_t DEFAULT_SEED = 5381

Typedef Documentation

Definition at line 143 of file fast_hash.hpp.


Function Documentation

template<typename FloatType , class ForwardIteratorX , class WeightAccessPolicyX , class ForwardIteratorY , class WeightAccessPolicyY , class AccumulatorPolicy >
FloatType moost::algorithm::cosine_similarity ( ForwardIteratorX  x_beg,
ForwardIteratorX  x_end,
WeightAccessPolicyX  x_weight,
ForwardIteratorY  y_beg,
ForwardIteratorY  y_end,
WeightAccessPolicyY  y_weight,
AccumulatorPolicy &  accu 
)

Cosine similarity algorithm

This function template implements a generic cosine similarity algorithm for two arbitrary dimension feature vectors X and Y.

Note that this implementation requires both input vectors to be sorted and that dimensions of both vectors must be less-than comparable.

Template Parameters:
FloatTypeFloating point type used for internal computation and return value.
ForwardIteratorXIterator type of vector X.
WeightAccessPolicyXPolicy for accessing the weight of a dimension in X.
ForwardIteratorYIterator type of vector Y.
WeightAccessPolicyYPolicy for accessing the weight of a dimension in Y.
AccumulatorPolicyPolicy for summing the feature matches (dot product parts). Defaults to SimpleAccumulatorPolicy<FloatType>, but a different policy could be used e.g. for counting the number of matches.
Parameters:
x_begIterator to the start of vector X.
x_endIterator to the end of vector X.
x_weightPolicy to access the weight of a dimension in vector X.
y_begIterator to the start of vector Y.
y_endIterator to the end of vector Y.
y_weightPolicy to access the weight of a dimension in vector Y.
accuAccumulator policy.

Definition at line 83 of file similarity.hpp.

template<typename FloatType , class ForwardIteratorX , class WeightAccessPolicyX , class ForwardIteratorY , class WeightAccessPolicyY >
FloatType moost::algorithm::cosine_similarity ( ForwardIteratorX  x_beg,
ForwardIteratorX  x_end,
WeightAccessPolicyX  x_weight,
ForwardIteratorY  y_beg,
ForwardIteratorY  y_end,
WeightAccessPolicyY  y_weight 
)

Definition at line 143 of file similarity.hpp.

size_t moost::algorithm::fast_hash ( const void *  data_in,
size_t  size,
size_t  seed = DEFAULT_SEED 
) [inline]

free hash function

Definition at line 92 of file fast_hash.hpp.

Here is the caller graph for this function:

template<class ForwardIterator , class InputIterator >
ForwardIterator moost::algorithm::inplace_set_intersection ( ForwardIterator  first1,
ForwardIterator  last1,
InputIterator  first2,
InputIterator  last2 
)

Definition at line 42 of file inplace_set_intersection.hpp.

Here is the caller graph for this function:

template<class ForwardIterator , class InputIterator , class StrictWeakOrdering >
ForwardIterator moost::algorithm::inplace_set_intersection ( ForwardIterator  first1,
ForwardIterator  last1,
InputIterator  first2,
InputIterator  last2,
StrictWeakOrdering  comp 
)

Definition at line 65 of file inplace_set_intersection.hpp.


Variable Documentation

const size_t moost::algorithm::DEFAULT_SEED = 5381 [static]

Definition at line 87 of file fast_hash.hpp.