barry: Your go-to motif accountant  0.0-1
Full enumeration of sample space and fast count of sufficient statistics for binary arrays
counters-bones.hpp
Go to the documentation of this file.
1 #ifndef BARRY_COUNTERS_BONES_HPP
2 #define BARRY_COUNTERS_BONES_HPP 1
3 
34 template <typename Array_Type = BArray<>, typename Data_Type = bool>
35 class Counter {
36 public:
37 
41 
42  Data_Type data;
43  std::string name = "";
44  std::string desc = "";
45 
57  Counter() : count_fun(nullptr), init_fun(nullptr), hasher_fun(nullptr) {};
58 
63  Data_Type data_,
64  std::string name_ = "",
65  std::string desc_ = ""
67  name(name_), desc(desc_) {};
68 
74 
75  ~Counter() {};
76 
77  /***
78  * ! Main functions.
79  */
80  double count(Array_Type & Array, size_t i, size_t j);
81  double init(Array_Type & Array, size_t i, size_t j);
82  std::string get_name() const;
83  std::string get_description() const;
84 
97 
98 };
99 
107 template <typename Array_Type = BArray<>, typename Data_Type = bool>
108 class Counters {
109 
110 private:
111  std::vector< Counter<Array_Type,Data_Type > > data;
113 
114 public:
115 
116  // Constructors
118 
119  // Destructor needs to deal with the pointers
120  ~Counters() {};
121 
127 
134 
142 
150 
158 
164  std::size_t size() const noexcept {
165  return data.size();
166  };
167 
168  // Functions to add counters
174  Data_Type data_,
175  std::string name_ = "",
176  std::string desc_ = ""
177  );
178 
179  std::vector< std::string > get_names() const;
180  std::vector< std::string > get_descriptions() const;
181 
190  std::vector< double > gen_hash(
191  const Array_Type & array,
192  bool add_dims = true
193  );
194 
195  void add_hash(
197  );
198 
199 };
200 
201 #endif
202 
A counter function based on change statistics.
std::string desc
double init(Array_Type &Array, size_t i, size_t j)
Hasher_fun_type< Array_Type, Data_Type > hasher_fun
Counter< Array_Type, Data_Type > operator=(const Counter< Array_Type, Data_Type > &counter_)
Copy assignment.
Counter< Array_Type, Data_Type > & operator=(Counter< Array_Type, Data_Type > &&counter_) noexcept
Move assignment.
Counter_fun_type< Array_Type, Data_Type > count_fun
std::string get_description() const
Counter(const Counter< Array_Type, Data_Type > &counter_)
Copy constructor.
double count(Array_Type &Array, size_t i, size_t j)
std::string get_name() const
void set_hasher(Hasher_fun_type< Array_Type, Data_Type > fun)
Get and set the hasher function.
Counter_fun_type< Array_Type, Data_Type > init_fun
Hasher_fun_type< Array_Type, Data_Type > get_hasher()
Counter(Counter_fun_type< Array_Type, Data_Type > count_fun_, Counter_fun_type< Array_Type, Data_Type > init_fun_, Hasher_fun_type< Array_Type, Data_Type > hasher_fun_, Data_Type data_, std::string name_="", std::string desc_="")
Data_Type data
std::string name
Counter(Counter< Array_Type, Data_Type > &&counter_) noexcept
Move constructor.
Vector of counters.
void add_counter(Counter_fun_type< Array_Type, Data_Type > count_fun_, Counter_fun_type< Array_Type, Data_Type > init_fun_, Hasher_fun_type< Array_Type, Data_Type > hasher_fun_, Data_Type data_, std::string name_="", std::string desc_="")
Counters(const Counters< Array_Type, Data_Type > &counter_)
Copy constructor.
Counter< Array_Type, Data_Type > & operator[](size_t idx)
Returns a pointer to a particular counter.
void add_hash(Hasher_fun_type< Array_Type, Data_Type > fun_)
Counters< Array_Type, Data_Type > & operator=(Counters< Array_Type, Data_Type > &&counter_) noexcept
Move assignment constructor.
std::vector< std::string > get_descriptions() const
Counters< Array_Type, Data_Type > operator=(const Counters< Array_Type, Data_Type > &counter_)
Copy assignment constructor.
std::vector< std::string > get_names() const
Counters(Counters< Array_Type, Data_Type > &&counters_) noexcept
Move constructor.
std::size_t size() const noexcept
Number of counters in the set.
void add_counter(Counter< Array_Type, Data_Type > counter)
std::vector< double > gen_hash(const Array_Type &array, bool add_dims=true)
Generates a hash for the given array according to the counters.
Data_Type & counter_
Data_Type fun
Data_Type count_fun_
Data_Type &&counter_ data(std::move(counter_.data))
Data_Type Counter_fun_type< Array_Type, Data_Type > init_fun_
Data_Type fun_
Data_Type Counter_fun_type< Array_Type, Data_Type > Hasher_fun_type< Array_Type, Data_Type > hasher_fun_
Data_Type Counter_fun_type< Array_Type, Data_Type > Hasher_fun_type< Array_Type, Data_Type > Data_Type std::string std::string desc_
Data_Type Counter_fun_type< Array_Type, Data_Type > Hasher_fun_type< Array_Type, Data_Type > Data_Type std::string name_
size_t size_t j
bool add_dims
Data_Type counter
size_t i
Data_Type &&counter_ noexcept
Data_Type Counter_fun_type< Array_Type, Data_Type > Hasher_fun_type< Array_Type, Data_Type > Data_Type data_
Data_Type * counters_
std::function< std::vector< double >(const Array_Type &, Data_Type *)> Hasher_fun_type
Hasher function used by the counter.
Definition: typedefs.hpp:200
std::function< double(const Array_Type &, size_t, size_t, Data_Type &)> Counter_fun_type
Counter and rule functions.
Definition: typedefs.hpp:187