barry: Your go-to motif accountant  0.0-1
Full enumeration of sample space and fast count of sufficient statistics for binary arrays
powerset-bones.hpp
Go to the documentation of this file.
1 #ifndef BARRY_POWERSET_BONES_HPP
2 #define BARRY_POWERSET_BONES_HPP 1
3 
10 template <typename Array_Type = BArray<>, typename Data_Rule_Type = bool>
11 class PowerSet {
12 
13 private:
14  void calc_backend_sparse(size_t pos = 0u);
15  void calc_backend_dense(size_t pos = 0u);
16 
17 public:
18  Array_Type EmptyArray;
19  std::vector< Array_Type > data;
21 
22  size_t N, M;
23  bool rules_deleted = false;
24 
25  // Tempvars
26  std::vector< size_t > coordinates_free;
27  std::vector< size_t > coordinates_locked;
28  size_t n_free;
29  size_t n_locked;
30 
36  PowerSet() :
37  EmptyArray(), data(0u), rules(new Rules<Array_Type,Data_Rule_Type>()), N(0u), M(0u) {};
38  PowerSet(size_t N_, size_t M_) :
39  EmptyArray(N_, M_), data(0u),
40  rules(new Rules<Array_Type,Data_Rule_Type>()), N(N_), M(M_) {};
41  PowerSet(const Array_Type & array);
42 
43  ~PowerSet();
45 
46  void init_support();
47  void calc();
48  void reset(size_t N_, size_t M_);
49 
57  void add_rule(
59  Data_Rule_Type data_
60  );
62 
63 
66  const std::vector< Array_Type > * get_data_ptr() const {return &data;};
67  std::vector< Array_Type > get_data() const {return data;};
68  typename std::vector< Array_Type >::iterator begin() {return data.begin();};
69  typename std::vector< Array_Type >::iterator end() {return data.end();};
70  std::size_t size() const noexcept {return data.size();};
71  const Array_Type& operator[](const size_t & i) const {return data.at(i);};
73 
74 };
75 
76 #endif
Powerset of a binary array.
size_t n_free
bool rules_deleted
std::vector< size_t > coordinates_free
Array_Type EmptyArray
std::vector< Array_Type > get_data() const
size_t n_locked
void add_rule(Rule< Array_Type, Data_Rule_Type > rule)
void init_support()
const std::vector< Array_Type > * get_data_ptr() const
std::size_t size() const noexcept
const Array_Type & operator[](const size_t &i) const
std::vector< Array_Type >::iterator begin()
std::vector< Array_Type >::iterator end()
PowerSet(size_t N_, size_t M_)
std::vector< size_t > coordinates_locked
std::vector< Array_Type > data
void reset(size_t N_, size_t M_)
Rules< Array_Type, Data_Rule_Type > * rules
Rule for determining if a cell should be included in a sequence.
Definition: rules-bones.hpp:20
Vector of objects of class Rule.
Definition: rules-bones.hpp:71
Data_Type count_fun_
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_
std::function< bool(const Array_Type &, size_t, size_t, Data_Type &)> Rule_fun_type
Definition: typedefs.hpp:190