barry: Your go-to motif accountant  0.0-1
Full enumeration of sample space and fast count of sufficient statistics for binary arrays
barraydensecell-meat.hpp
Go to the documentation of this file.
1 // #include "barraydensecell-bones.hpp"
2 
3 #ifndef BARRY_BARRAYDENSECELL_MEAT_HPP
4 #define BARRY_BARRAYDENSECELL_MEAT_HPP 1
5 
6 #define POS(a, b) (a) + (b) * dat->N
7 
8 template<typename Cell_Type,typename Data_Type>
11  ) {
12 
13  Cell_Type val = static_cast<Cell_Type>(other);
14  #ifdef BARRY_DEBUG
15  Cell_Type old = dat->el.at(POS(i,j));
16  dat->el.at(POS(i,j)) = val;
17  dat->el_rowsums.at(i) += (val - old);
18  dat->el_colsums.at(j) += (val - old);
19  #else
20  Cell_Type old = dat->el[POS(i,j)];
21  dat->el[POS(i,j)] = val;
22  dat->el_rowsums[i] += (val - old);
23  dat->el_colsums[j] += (val - old);
24  #endif
25 
26  return *this;
27 
28 }
29 
30 template<typename Cell_Type,typename Data_Type>
31 inline void BArrayDenseCell<Cell_Type,Data_Type>::operator=(const Cell_Type & val) {
32 
33  #ifdef BARRY_DEBUG
34  Cell_Type old = dat->el.at(POS(i,j));
35  dat->el.at(POS(i,j)) = val;
36  dat->el_rowsums.at(i) += (val - old);
37  dat->el_colsums.at(j) += (val - old);
38  #else
39  Cell_Type old = dat->el[POS(i,j)];
40  dat->el[POS(i,j)] = val;
41  dat->el_rowsums[i] += (val - old);
42  dat->el_colsums[j] += (val - old);
43  #endif
44 
45 }
46 
47 template<typename Cell_Type,typename Data_Type>
48 inline void BArrayDenseCell<Cell_Type,Data_Type>::operator+=(const Cell_Type & val) {
49 
50  #ifdef BARRY_DEBUG
51  dat->el.at(POS(i,j)) += val;
52  dat->el_rowsums.at(i) += val;
53  dat->el_colsums.at(j) += val;
54  #else
55  dat->el[POS(i,j)] += val;
56  dat->el_rowsums[i] += val;
57  dat->el_colsums[j] += val;
58  #endif
59 
60 }
61 
62 template<typename Cell_Type,typename Data_Type>
63 inline void BArrayDenseCell<Cell_Type,Data_Type>::operator-=(const Cell_Type & val) {
64 
65  #ifdef BARRY_DEBUG
66  dat->el.at(POS(i,j)) -= val;
67  dat->el_rowsums.at(i) -= val;
68  dat->el_colsums.at(j) -= val;
69  #else
70  dat->el[POS(i,j)] -= val;
71  dat->el_rowsums[i] -= val;
72  dat->el_colsums[j] -= val;
73  #endif
74 
75 }
76 
77 template<typename Cell_Type,typename Data_Type>
78 inline void BArrayDenseCell<Cell_Type,Data_Type>::operator*=(const Cell_Type & val) {
79 
80  #ifdef BARRY_DEBUG
81  Cell_Type old = dat->el.at(POS(i,j));
82  dat->el_colsums.at(j) += (old * val - old);
83  dat->el_rowsums.at(i) += (old * val - old);
84  dat->el.at(POS(i,j)) *= val;
85  #else
86  Cell_Type old = dat->el[POS(i,j)];
87  dat->el_colsums[j] += (old * val - old);
88  dat->el_rowsums[i] += (old * val - old);
89  dat->el[POS(i,j)] *= val;
90  #endif
91 
92 }
93 
94 template<typename Cell_Type,typename Data_Type>
95 inline void BArrayDenseCell<Cell_Type,Data_Type>::operator/=(const Cell_Type & val) {
96 
97  #ifdef BARRY_DEBUG
98  Cell_Type old = dat->el.at(POS(i,j));
99  dat->el_rowsums.at(i) += (old/val - old);
100  dat->el_colsums.at(j) += (old/val - old);
101  dat->el.at(POS(i,j)) /= val;
102  #else
103  Cell_Type old = dat->el[POS(i,j)];
104  dat->el_rowsums[i] += (old/val - old);
105  dat->el_colsums[j] += (old/val - old);
106  dat->el[POS(i,j)] /= val;
107  #endif
108 
109 }
110 
111 template<typename Cell_Type,typename Data_Type>
113  return dat->el[POS(i,j)];
114 }
115 
116 template<typename Cell_Type,typename Data_Type>
117 inline bool BArrayDenseCell<Cell_Type,Data_Type>::operator==(const Cell_Type & val) const {
118  return dat->el[POS(i,j)] == val;
119 }
120 
121 #undef POS
122 
123 #endif
#define POS(a, b)
void operator/=(const Cell_Type &val)
void operator+=(const Cell_Type &val)
bool operator==(const Cell_Type &val) const
BArrayDenseCell< Cell_Type, Data_Type > & operator=(const BArrayDenseCell< Cell_Type, Data_Type > &other)
void operator*=(const Cell_Type &val)
void operator-=(const Cell_Type &val)
size_t size_t j
size_t i