barry: Your go-to motif accountant  0.0-1
Full enumeration of sample space and fast count of sufficient statistics for binary arrays
barraydensecol-bones.hpp
Go to the documentation of this file.
1 #ifndef BARRY_BARRAYDENSECOL_BONES
2 #define BARRY_BARRAYDENSECOL_BONES
3 
4 #define POS(a,b) (b)*N + (a)
5 #define POS_N(a,b,c) (b)*(c) + (a)
6 #define ZERO_CELL static_cast<Cell_Type>(0.0)
7 
8 template <typename Cell_Type = bool, typename Data_Type = bool>
10  friend class BArrayDense<Cell_Type,Data_Type>;
11  friend class BArrayDenseCell<Cell_Type,Data_Type>;
12  friend class BArrayDenseCell_const<Cell_Type,Data_Type>;
13 private:
16  size_t index;
17  bool col_filled = false;
18 
19  void fill_if_needed()
20  {
21  if (!col_filled)
22  {
23 
24  for (size_t i = 0u; i < array->N; ++i)
25  {
26 
27  if (array->el[POS_N(i, index, array->N)] != ZERO_CELL)
28  col[i] = col[POS_N(i, index, array->N)];
29 
30  }
31 
32  col_filled = true;
33 
34  }
35  }
36 
37 public:
40  size_t j
41  ) : array(&array_), index(j) {};
42 
43 
45  {
46  fill_if_needed();
47  return col.begin();
48  };
49 
51  {
52  fill_if_needed();
53  return col.end();
54  };
55 
56  size_t size() const noexcept
57  {
58  fill_if_needed();
59  return col.size();
60  };
61 
62  std::pair<size_t,Cell_Type*> & operator()(size_t i)
63  {
64  fill_if_needed();
65  return col[i];
66  }
67 
68 };
69 
70 template <typename Cell_Type = bool, typename Data_Type = bool>
72  friend class BArrayDenseCell<Cell_Type,Data_Type>;
73  friend class BArrayDenseCell_const<Cell_Type,Data_Type>;
74 private:
76  size_t index;
78 
79 public:
82  size_t j
83  ) : array(&array_), index(j)
84  {
85 
86  for (size_t i = 0u; i < array->N; ++i)
87  {
88 
89  if (array->el[POS_N(i, index, array->N)] != ZERO_CELL)
90  col[i] = col[POS_N(i, index, array->N)];
91 
92  }
93 
94  };
95 
97  {
98  return col.begin();
99  };
100 
102  {
103  return col.end();
104  };
105 
106 
107  size_t size() const noexcept
108  {
109  return col.size();
110  };
111 
112  const std::pair<size_t,Cell_Type*> operator()(size_t i) const
113  {
114  return col[i];
115  }
116 
117 };
118 
119 #undef POS
120 #undef POS_N
121 #undef ZERO_CELL
122 
123 #endif
#define POS_N(a, b, c)
#define ZERO_CELL
Col_type< Cell_Type >::iterator end()
BArrayDenseCol_const(const BArrayDense< Cell_Type, Data_Type > &array_, size_t j)
size_t size() const noexcept
const std::pair< size_t, Cell_Type * > operator()(size_t i) const
Col_type< Cell_Type >::iterator begin()
Col_type< Cell_Type >::iterator & begin()
BArrayDenseCol(BArrayDense< Cell_Type, Data_Type > &array_, size_t j)
Col_type< Cell_Type >::iterator & end()
std::pair< size_t, Cell_Type * > & operator()(size_t i)
size_t size() const noexcept
Baseline class for binary arrays.
size_t size_t j
size_t i
Data_Type &&counter_ noexcept
Map< size_t, Cell< Cell_Type > * > Col_type
Definition: typedefs.hpp:70