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

#include <TopN.h>

Inheritance diagram for TopN< T >:
Inheritance graph
[legend]
Collaboration diagram for TopN< T >:
Collaboration graph
[legend]

Classes

class  HasPosterior
 
struct  HasPosterior< X, decltype((void) X::posterior, 0)>
 

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::set< T > & values () const
 
bool contains (const T &x) const
 Does this contain x? More...
 
void add (const T &x)
 
void operator<< (const T &x)
 
void add (const TopN< T > &x)
 
void operator<< (const TopN< 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 (double temp=1.0)
 
void print (std::string prefix="")
 
std::vector< T > sorted (bool increasing=true) const
 Sorted values. More...
 
void clear ()
 
template<typename data_t >
TopN compute_posterior (data_t &data)
 
virtual std::string serialize () const override
 

Static Public Member Functions

static TopN< T > deserialize (const std::string &s)
 
- Static Public Member Functions inherited from Serializable< TopN< T > >
static TopN< T > deserialize (const std::string &)
 

Public Attributes

std::set< T > s
 
bool print_best
 
std::atomic< size_t > N
 

Static Public Attributes

static const size_t MAX_N = SIZE_MAX
 

Detailed Description

template<class T>
class TopN< T >

Author
steven piantadosi
Date
03/02/20

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)
inline

Add x. NOTE that we do not add objects x such that x.posterior == -infinity or NaN

Parameters
x

◆ 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

◆ deserialize()

template<class T>
static TopN<T> TopN< T >::deserialize ( const std::string &  s)
inlinestatic

◆ empty()

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

Is it empty?

Returns

◆ 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

◆ 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

◆ serialize()

template<class T>
virtual std::string TopN< T >::serialize ( ) const
inlineoverridevirtual

◆ 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

◆ sorted()

template<class T>
std::vector<T> TopN< T >::sorted ( bool  increasing = true) const
inline

Sorted values.

Parameters
increasing– do we sort increasing or decreasing?

◆ values()

template<class T>
const std::set<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 ( double  temp = 1.0)
inline

Compute the logsumexp of all of the elements stored at temperature T

Returns

Member Data Documentation

◆ MAX_N

template<class T>
const size_t TopN< T >::MAX_N = SIZE_MAX
static

◆ 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::set<T> TopN< T >::s

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