barry: Your go-to motif accountant  0.0-1
Full enumeration of sample space and fast count of sufficient statistics for binary arrays
statscounter-bones.hpp
Go to the documentation of this file.
1 #ifndef BARRY_STATSCOUNTER_BONES_HPP
2 #define BARRY_STATSCOUNTER_BONES_HPP 1
3 
4 class NetworkDense;
5 class NetCounterData;
6 
13 template <typename Array_Type, typename Data_Type>
14 class StatsCounter {
15 
16 private:
17 
18  // Should receive an array
19  const Array_Type * Array;
20  Array_Type EmptyArray;
21  std::vector< double > current_stats;
22 
23  // We will save the data here
25  bool counter_deleted = false;
26 
27  std::vector< double > count_all_dense();
28  std::vector< double > count_all_sparse();
29 
30 public:
31 
37  StatsCounter(const Array_Type * Array_) :
38  Array(Array_), EmptyArray(*Array_),
39  counters(new Counters<Array_Type,Data_Type>()) {
40 
41  // We are removing the entries without freeing the memory. This should
42  // make the insertion faster.
43  EmptyArray.clear(false);
44 
45  return;
46  }
47 
54 
59  StatsCounter() : Array(nullptr), EmptyArray(0u,0u),
60  counters(new Counters<Array_Type,Data_Type>()) {};
62 
68  void reset_array(const Array_Type * Array_);
69 
72 
78  void count_init(size_t i, size_t j);
79  void count_current(size_t i, size_t j);
80  std::vector< double > count_all();
81 
83  std::vector< std::string > get_names() const;
84  std::vector< std::string > get_descriptions() const;
85 
86  size_t size() const {return counters->size();};
87 
88 };
89 
90 #endif
Baseline class for binary arrays.
A counter function based on change statistics.
Data class used to store arbitrary size_t or double vectors.
Definition: network.hpp:56
Count stats for a single Array.
std::vector< std::string > get_descriptions() const
void count_current(size_t i, size_t j)
void set_counters(Counters< Array_Type, Data_Type > *counters_)
StatsCounter()
Can be created without setting the array.
std::vector< double > count_all()
void count_init(size_t i, size_t j)
Counter functions This function recurses through the entries of Array and at each step of adding a ne...
void reset_array(const Array_Type *Array_)
Changes the reference array for the counting.
std::vector< std::string > get_names() const
StatsCounter(const Array_Type *Array_)
Creator of a StatsCounter
size_t size() const
void add_counter(Counter< Array_Type, Data_Type > f_)
Counters< Array_Type, Data_Type > * get_counters()
StatsCounter(const StatsCounter< Array_Type, Data_Type > &counter)
Copy constructor.
size_t size_t j
Data_Type counter
size_t i
Data_Type * counters_
Data_Type f_