barry: Your go-to motif accountant  0.0-1
Full enumeration of sample space and fast count of sufficient statistics for binary arrays
barrayrow-meat.hpp
Go to the documentation of this file.
1 #ifndef BARRY_BARRAYROW_MEAT_HPP
2 #define BARRY_BARRAYROW_MEAT_HPP 1
3 
4 #define BROW_TYPE() BArrayRow<Cell_Type, Data_Type>
5 
6 #define BROW_TEMPLATE_ARGS() <typename Cell_Type, typename Data_Type>
7 
8 #define BROW_TEMPLATE(a,b) \
9  template BROW_TEMPLATE_ARGS() inline a BROW_TYPE()::b
10 
11 BROW_TEMPLATE(void, operator=) (const BROW_TYPE() & val) {
12 
13  // First, zeroout the row
14  this->Array->zero_row(j);
15 
16  // Then, iterate throught the values of val and add it
17  for (auto & v: val)
18  Array->inser_cell(i, v.first, v.second);
19 
20  // Return
21  return;
22 
23 }
24 
25 BROW_TEMPLATE(void, operator+=) (const BROW_TYPE() & val) {
26 
27  for (auto & v : val)
28  this->Array->operator(i, v.first) += v.second;
29 
30  return;
31 
32 }
33 
34 BROW_TEMPLATE(void, operator-=) (
35  const BROW_TYPE() & val
36 ) {
37 
38  for (auto & v : val)
39  this->Array->operator(i, v.first) -= v.second;
40 
41  return;
42 
43 }
44 
45 BROW_TEMPLATE(void, operator*=) (
46  const BROW_TYPE() & val
47 ) {
48 
49  if (!Array->is_empty(i, j, false)) {
50  Array->el_ij.at(i).at(j).value *= val;
51  }
52 
53 }
54 
55 BROW_TEMPLATE(void, operator/=) (
56  const BROW_TYPE() & val
57 ) {
58 
59  if (!Array->is_empty(i, j, false)) {
60  Array->el_ij.at(i).at(j).value /= val;
61  }
62 
63 }
64 
65 template<typename Cell_Type,typename Data_Type>
66 inline BArrayCell<Cell_Type,Data_Type>::operator Cell_Type() const {
67  return Array->get_cell(i, j, false);
68 }
69 
70 template<typename Cell_Type,typename Data_Type>
71 inline bool BArrayCell<Cell_Type,Data_Type>::operator==(const Cell_Type & val) const {
72  return Array->get_cell(i, j, false) == static_cast<Cell_Type>(val);
73 }
74 
75 template<typename Cell_Type,typename Data_Type>
76 inline BArrayCell_const<Cell_Type,Data_Type>::operator Cell_Type() const {
77  return Array->get_cell(i, j, false);
78 }
79 
80 template<typename Cell_Type,typename Data_Type>
81 inline bool BArrayCell_const<Cell_Type,Data_Type>::operator==(const Cell_Type & val) const {
82  return Array->get_cell(i, j, false) == static_cast<Cell_Type>(val);
83 }
84 
85 template<typename Cell_Type,typename Data_Type>
86 inline bool BArrayCell_const<Cell_Type,Data_Type>::operator!=(const Cell_Type & val) const {
87  return !(this->operator==(val));
88 }
89 
90 template<typename Cell_Type,typename Data_Type>
91 inline bool BArrayCell_const<Cell_Type,Data_Type>::operator<(const Cell_Type & val) const {
92  return Array->get_cell(i, j, false) < static_cast<Cell_Type>(val);
93 }
94 
95 template<typename Cell_Type,typename Data_Type>
96 inline bool BArrayCell_const<Cell_Type,Data_Type>::operator>(const Cell_Type & val) const {
97  return Array->get_cell(i, j, false) > static_cast<Cell_Type>(val);
98 }
99 
100 template<typename Cell_Type,typename Data_Type>
101 inline bool BArrayCell_const<Cell_Type,Data_Type>::operator<=(const Cell_Type & val) const {
102  return Array->get_cell(i, j, false) <= static_cast<Cell_Type>(val);
103 }
104 
105 template<typename Cell_Type,typename Data_Type>
106 inline bool BArrayCell_const<Cell_Type,Data_Type>::operator>=(const Cell_Type & val) const {
107  return Array->get_cell(i, j, false) >= static_cast<Cell_Type>(val);
108 }
109 
110 #undef BROW_TYPE
111 #undef BROW_TEMPLATE_ARGS
112 #undef BROW_TEMPLATE
113 
114 #endif
#define BROW_TYPE()
#define BROW_TEMPLATE(a, b)
bool operator==(const Cell_Type &val) const
bool operator>(const Cell_Type &val) const
bool operator<=(const Cell_Type &val) const
bool operator<(const Cell_Type &val) const
bool operator!=(const Cell_Type &val) const
bool operator>=(const Cell_Type &val) const
bool operator==(const Cell_Type &val) const
size_t size_t j
size_t i