Fleet  0.0.9
Inference in the LOT
Public Types | Public Member Functions | Public Attributes | List of all members
TopN< T > Class Template Reference

#include <Top.h>

Public Types

using Hypothesis_t = T
 

Public Member Functions

 TopN (size_t n=FleetArgs::ntop)
 
 TopN (const TopN< T > &x)
 
 TopN (TopN< T > &&x)
 
void operator= (const TopN< T > &x)
 
void operator= (TopN< T > &&x)
 
void set_size (size_t n)
 
void set_print_best (bool b)
 
size_t size () const
 
bool empty () const
 
const std::multiset< T > & values () const
 
bool contains (const T &x) const
 Does this contain x? More...
 
void add (const T &x, size_t count=1)
 
void operator<< (const T &x)
 
void add (const TopN< T > &x)
 
void operator<< (const TopN< T > &x)
 
void operator() (T &x)
 
size_t operator[] (const T &x)
 
void pop ()
 Pops off the top – you usually won't want to do this and it's not efficient. More...
 
const T & best () const
 
const T & worst () const
 
double Z ()
 
void print (std::string prefix="")
 
void clear ()
 
unsigned long count (const T x)
 
template<typename data_t >
TopN compute_posterior (data_t &data)
 

Public Attributes

std::map< T, unsigned long > cnt
 
std::multiset< T > s
 
bool print_best
 
std::atomic< size_t > N
 

Detailed Description

template<class T>
class TopN< T >

Author
steven piantadosi
Date
03/02/20

Member Typedef Documentation

§ Hypothesis_t

template<class T>
using TopN< T >::Hypothesis_t = T

Constructor & Destructor Documentation

§ TopN() [1/3]

template<class T>
TopN< T >::TopN ( size_t  n = FleetArgs::ntop)
inline

§ TopN() [2/3]

template<class T>
TopN< T >::TopN ( const TopN< T > &  x)
inline

§ TopN() [3/3]

template<class T>
TopN< T >::TopN ( TopN< T > &&  x)
inline

Member Function Documentation

§ add() [1/2]

template<class T>
void TopN< T >::add ( const T &  x,
size_t  count = 1 
)
inline

Add x. If count is set, that will add that many counts. NOTE that we do not add objects x such that x.posterior == -infinity or NaN

Parameters
x
count

§ add() [2/2]

template<class T>
void TopN< T >::add ( const TopN< T > &  x)
inline

Add everything in x to this one.

Parameters
x

§ best()

template<class T>
const T& TopN< T >::best ( ) const
inline

Returns a reference to the best element currently stored

Returns

§ clear()

template<class T>
void TopN< T >::clear ( )
inline

Remove everything

§ compute_posterior()

template<class T>
template<typename data_t >
TopN TopN< T >::compute_posterior ( data_t &  data)
inline

Returns a NEW TopN where each current hypothesis is evaluated on the data. NOTE: If a hypothesis has a new posterior of -inf or NaN, it won't be added.

Parameters
data
Returns

§ contains()

template<class T>
bool TopN< T >::contains ( const T &  x) const
inline

Does this contain x?

Parameters
x
Returns

§ count()

template<class T>
unsigned long TopN< T >::count ( const T  x)
inline

How many times have we seen x?

Parameters
x
Returns

§ empty()

template<class T>
bool TopN< T >::empty ( ) const
inline

Is it empty?

Returns

§ operator()()

template<class T>
void TopN< T >::operator() ( T &  x)
inline

§ operator<<() [1/2]

template<class T>
void TopN< T >::operator<< ( const T &  x)
inline

Friendlier syntax for adding.

Parameters
x

§ operator<<() [2/2]

template<class T>
void TopN< T >::operator<< ( const TopN< T > &  x)
inline

§ operator=() [1/2]

template<class T>
void TopN< T >::operator= ( const TopN< T > &  x)
inline

§ operator=() [2/2]

template<class T>
void TopN< T >::operator= ( TopN< T > &&  x)
inline

§ operator[]()

template<class T>
size_t TopN< T >::operator[] ( const T &  x)
inline

Access the counts for a given element x

Parameters
x
Returns

§ pop()

template<class T>
void TopN< T >::pop ( )
inline

Pops off the top – you usually won't want to do this and it's not efficient.

§ print()

template<class T>
void TopN< T >::print ( std::string  prefix = "")
inline

Sort and print from worst to best

Parameters
prefix- an optional prefix to print before each line

§ set_print_best()

template<class T>
void TopN< T >::set_print_best ( bool  b)
inline

As I add things, should I print the best I've seen so far?

Parameters
b

§ set_size()

template<class T>
void TopN< T >::set_size ( size_t  n)
inline

Set the size of n that I cna have. NOTE: this does not resize the existing data.

Parameters
n

§ size()

template<class T>
size_t TopN< T >::size ( ) const
inline

How many are currently in the set? (NOT the total number allowed)

Returns

§ values()

template<class T>
const std::multiset<T>& TopN< T >::values ( ) const
inline

Return a multiset of all the values in TopN

Returns

§ worst()

template<class T>
const T& TopN< T >::worst ( ) const
inline

Returns a reference to the worst element currently stored

Returns

§ Z()

template<class T>
double TopN< T >::Z ( )
inline

Compute the logsumexp of all of the elements stored.

Returns

Member Data Documentation

§ cnt

template<class T>
std::map<T,unsigned long> TopN< T >::cnt

§ N

template<class T>
std::atomic<size_t> TopN< T >::N

§ print_best

template<class T>
bool TopN< T >::print_best

§ s

template<class T>
std::multiset<T> TopN< T >::s

The documentation for this class was generated from the following file: