barry: Your go-to motif accountant  0.0-1
Full enumeration of sample space and fast count of sufficient statistics for binary arrays
Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type > Class Template Reference

Compute the support of sufficient statistics. More...

#include <support-bones.hpp>

Public Member Functions

 Support (const Array_Type &Array_)
 Constructor passing a reference Array. More...
 
 Support (size_t N_, size_t M_)
 Constructor specifying the dimensions of the array (empty). More...
 
 Support ()
 
 ~Support ()
 
void init_support (std::vector< Array_Type > *array_bank=nullptr, std::vector< double > *stats_bank=nullptr)
 
void calc (std::vector< Array_Type > *array_bank=nullptr, std::vector< double > *stats_bank=nullptr, size_t max_num_elements_=0u)
 Computes the entire support. More...
 
const std::vector< double > & get_counts () const
 
std::vector< double > * get_current_stats ()
 List current statistics. More...
 
void print () const
 
const FreqTable< double > & get_data () const
 
Counters< Array_Type, Data_Counter_Type > * get_counters ()
 Vector of couter functions. More...
 
Rules< Array_Type, Data_Rule_Type > * get_rules ()
 Vector of static rules (cells to iterate). More...
 
Rules< Array_Type, Data_Rule_Dyn_Type > * get_rules_dyn ()
 Vector of dynamic rules (to include/exclude a realizaton). More...
 
Resets the support calculator

If needed, the counters of a support object can be reused.

Parameters
Array_New array over which the support will be computed.
void reset_array ()
 
void reset_array (const Array_Type &Array_)
 
Manage counters
Parameters
f_A counter to be added.
counters_A vector of counters to be added.
void add_counter (Counter< Array_Type, Data_Counter_Type > f_)
 
void set_counters (Counters< Array_Type, Data_Counter_Type > *counters_)
 
Manage rules
Parameters
f_A rule to be added.
counters_A vector of rules to be added.
void add_rule (Rule< Array_Type, Data_Rule_Type > *f_)
 
void add_rule (Rule< Array_Type, Data_Rule_Type > f_)
 
void set_rules (Rules< Array_Type, Data_Rule_Type > *rules_)
 
void add_rule_dyn (Rule< Array_Type, Data_Rule_Dyn_Type > *f_)
 
void add_rule_dyn (Rule< Array_Type, Data_Rule_Dyn_Type > f_)
 
void set_rules_dyn (Rules< Array_Type, Data_Rule_Dyn_Type > *rules_)
 
bool eval_rules_dyn (const std::vector< double > &counts, const size_t &i, const size_t &j)
 

Public Attributes

size_t N
 
size_t M
 
bool delete_counters = true
 
bool delete_rules = true
 
bool delete_rules_dyn = true
 
size_t max_num_elements = BARRY_MAX_NUM_ELEMENTS
 
std::vector< double > current_stats
 
std::vector< size_t > coordinates_free
 
std::vector< size_t > coordinates_locked
 
size_t coordiantes_n_free
 
size_t coordiantes_n_locked
 
std::vector< double > change_stats
 
std::vector< size_t > hashes
 
std::vector< bool > hashes_initialized
 
size_t n_counters
 

Detailed Description

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
class Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >

Compute the support of sufficient statistics.

Given an array and a set of counters, this object iterates throughout the support set of the Array while at the same time computing the support of the sufficient statitics.

The members rule and rule_dyn allow constraining the support. The first will establish which cells of the array will be used to iterate, for example, in the case of social networks, self-loops are not allowed, so the entire diagonal would be fixed to zero, reducing the size of the support.

In the case of rule_dyn, the function will stablish dynamically whether the current state will be included in the counts or not. For example, this set of rules can be used to constrain the support to networks that have a prescribed degree sequence.

Definition at line 42 of file support-bones.hpp.

Constructor & Destructor Documentation

◆ Support() [1/3]

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::Support ( const Array_Type &  Array_)
inline

Constructor passing a reference Array.

Definition at line 89 of file support-bones.hpp.

◆ Support() [2/3]

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::Support ( size_t  N_,
size_t  M_ 
)
inline

Constructor specifying the dimensions of the array (empty).

Definition at line 98 of file support-bones.hpp.

◆ Support() [3/3]

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::Support ( )
inline

Definition at line 105 of file support-bones.hpp.

◆ ~Support()

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::~Support ( )
inline

Definition at line 112 of file support-bones.hpp.

Member Function Documentation

◆ add_counter()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::add_counter ( Counter< Array_Type, Data_Counter_Type >  f_)
inline

Definition at line 417 of file support-meat.hpp.

◆ add_rule() [1/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::add_rule ( Rule< Array_Type, Data_Rule_Type > *  f_)
inline

Definition at line 444 of file support-meat.hpp.

◆ add_rule() [2/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::add_rule ( Rule< Array_Type, Data_Rule_Type >  f_)
inline

Definition at line 454 of file support-meat.hpp.

◆ add_rule_dyn() [1/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::add_rule_dyn ( Rule< Array_Type, Data_Rule_Dyn_Type > *  f_)
inline

Definition at line 479 of file support-meat.hpp.

◆ add_rule_dyn() [2/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::add_rule_dyn ( Rule< Array_Type, Data_Rule_Dyn_Type >  f_)
inline

Definition at line 489 of file support-meat.hpp.

◆ calc()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::calc ( std::vector< Array_Type > *  array_bank = nullptr,
std::vector< double > *  stats_bank = nullptr,
size_t  max_num_elements_ = 0u 
)
inline

Computes the entire support.

Not to be used by the user. Sets the starting point in the array (column-major).

Parameters
array_bankIf specified, the counter will add to the vector each possible state of the array, as it counts.
stats_bankIf specified, the counter will add to the vector each possible set of statistics, as it counts.

Definition at line 383 of file support-meat.hpp.

◆ eval_rules_dyn()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
bool Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::eval_rules_dyn ( const std::vector< double > &  counts,
const size_t &  i,
const size_t &  j 
)
inline

Definition at line 514 of file support-meat.hpp.

◆ get_counters()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
Counters< Array_Type, Data_Counter_Type > * Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_counters
inline

Vector of couter functions.

Definition at line 593 of file support-meat.hpp.

◆ get_counts()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
const std::vector< double > & Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_counts
inline

Definition at line 557 of file support-meat.hpp.

◆ get_current_stats()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
std::vector< double > * Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_current_stats
inline

List current statistics.

Definition at line 571 of file support-meat.hpp.

◆ get_data()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
const FreqTable< double > & Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_data
inline

Definition at line 588 of file support-meat.hpp.

◆ get_rules()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
Rules< Array_Type, Data_Rule_Type > * Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_rules
inline

Vector of static rules (cells to iterate).

Definition at line 598 of file support-meat.hpp.

◆ get_rules_dyn()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
Rules< Array_Type, Data_Rule_Dyn_Type > * Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::get_rules_dyn
inline

Vector of dynamic rules (to include/exclude a realizaton).

Definition at line 603 of file support-meat.hpp.

◆ init_support()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::init_support ( std::vector< Array_Type > *  array_bank = nullptr,
std::vector< double > *  stats_bank = nullptr 
)
inline

Definition at line 5 of file support-meat.hpp.

◆ print()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::print
inline

Definition at line 576 of file support-meat.hpp.

◆ reset_array() [1/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::reset_array
inline

Definition at line 111 of file support-meat.hpp.

◆ reset_array() [2/2]

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::reset_array ( const Array_Type &  Array_)
inline

Definition at line 118 of file support-meat.hpp.

◆ set_counters()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::set_counters ( Counters< Array_Type, Data_Counter_Type > *  counters_)
inline

Definition at line 427 of file support-meat.hpp.

◆ set_rules()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::set_rules ( Rules< Array_Type, Data_Rule_Type > *  rules_)
inline

Definition at line 464 of file support-meat.hpp.

◆ set_rules_dyn()

template<typename Array_Type , typename Data_Counter_Type , typename Data_Rule_Type , typename Data_Rule_Dyn_Type >
void Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::set_rules_dyn ( Rules< Array_Type, Data_Rule_Dyn_Type > *  rules_)
inline

Definition at line 499 of file support-meat.hpp.

Member Data Documentation

◆ change_stats

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< double > Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::change_stats

Definition at line 82 of file support-bones.hpp.

◆ coordiantes_n_free

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
size_t Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::coordiantes_n_free

Definition at line 80 of file support-bones.hpp.

◆ coordiantes_n_locked

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
size_t Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::coordiantes_n_locked

Definition at line 81 of file support-bones.hpp.

◆ coordinates_free

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< size_t > Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::coordinates_free

Definition at line 78 of file support-bones.hpp.

◆ coordinates_locked

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< size_t > Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::coordinates_locked

Definition at line 79 of file support-bones.hpp.

◆ current_stats

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< double > Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::current_stats

Definition at line 77 of file support-bones.hpp.

◆ delete_counters

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
bool Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::delete_counters = true

Definition at line 71 of file support-bones.hpp.

◆ delete_rules

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
bool Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::delete_rules = true

Definition at line 72 of file support-bones.hpp.

◆ delete_rules_dyn

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
bool Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::delete_rules_dyn = true

Definition at line 73 of file support-bones.hpp.

◆ hashes

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< size_t > Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::hashes

Definition at line 83 of file support-bones.hpp.

◆ hashes_initialized

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
std::vector< bool > Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::hashes_initialized

Definition at line 84 of file support-bones.hpp.

◆ M

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
size_t Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::M

Definition at line 70 of file support-bones.hpp.

◆ max_num_elements

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
size_t Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::max_num_elements = BARRY_MAX_NUM_ELEMENTS

Definition at line 74 of file support-bones.hpp.

◆ N

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
size_t Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::N

Definition at line 70 of file support-bones.hpp.

◆ n_counters

template<typename Array_Type = BArray<bool, bool>, typename Data_Counter_Type = bool, typename Data_Rule_Type = bool, typename Data_Rule_Dyn_Type = bool>
size_t Support< Array_Type, Data_Counter_Type, Data_Rule_Type, Data_Rule_Dyn_Type >::n_counters

Definition at line 85 of file support-bones.hpp.


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