barry: Your go-to motif accountant  0.0-1
Full enumeration of sample space and fast count of sufficient statistics for binary arrays
barraycell-bones.hpp
Go to the documentation of this file.
1 // #include "typedefs.hpp"
2 
3 #ifndef BARRY_BARRAYCELL_BONES_HPP
4 #define BARRY_BARRAYCELL_BONES_HPP 1
5 
6 template <typename Cell_Type = bool, typename Data_Type = bool>
7 class BArrayCell {
8 private:
9 
11  size_t i;
12  size_t j;
13 
14 public:
15 
16  BArrayCell(BArray<Cell_Type,Data_Type> * Array_, size_t i_, size_t j_, bool check_bounds = true) :
17  Array(Array_), i(i_), j(j_) {
18 
19  if (check_bounds)
20  {
21 
22  if (i >= Array->nrow())
23  throw std::length_error("Row out of range.");
24  if (j >= Array->ncol())
25  throw std::length_error("Col out of range.");
26 
27  }
28 
29  };
30 
32  void operator=(const Cell_Type & val);
33  void operator+=(const Cell_Type & val);
34  void operator-=(const Cell_Type & val);
35  void operator*=(const Cell_Type & val);
36  void operator/=(const Cell_Type & val);
37 
38  operator Cell_Type() const;
39  bool operator==(const Cell_Type & val) const;
40 
41 };
42 
43 
44 
45 template <typename Cell_Type = bool, typename Data_Type = bool>
47 private:
48 
49  const BArray<Cell_Type,Data_Type> * Array;
50  size_t i;
51  size_t j;
52 
53 public:
54 
55  BArrayCell_const(const BArray<Cell_Type,Data_Type> * Array_, size_t i_, size_t j_, bool check_bounds = true) :
56  Array(Array_), i(i_), j(j_) {
57  if (check_bounds) {
58 
59  if (i >= Array->nrow())
60  throw std::length_error("Row out of range.");
61  if (j >= Array->ncol())
62  throw std::length_error("Col out of range.");
63 
64  }
65  };
66 
68 
69  operator Cell_Type() const;
70  bool operator==(const Cell_Type & val) const;
71  bool operator!=(const Cell_Type & val) const;
72  bool operator<(const Cell_Type & val) const;
73  bool operator>(const Cell_Type & val) const;
74  bool operator<=(const Cell_Type & val) const;
75  bool operator>=(const Cell_Type & val) const;
76 
77 };
78 
79 #endif
bool operator==(const Cell_Type &val) const
bool operator>(const Cell_Type &val) const
bool operator<=(const Cell_Type &val) const
BArrayCell_const(const BArray< Cell_Type, Data_Type > *Array_, size_t i_, size_t j_, bool check_bounds=true)
bool operator<(const Cell_Type &val) const
bool operator!=(const Cell_Type &val) const
bool operator>=(const Cell_Type &val) const
void operator+=(const Cell_Type &val)
void operator-=(const Cell_Type &val)
BArrayCell(BArray< Cell_Type, Data_Type > *Array_, size_t i_, size_t j_, bool check_bounds=true)
bool operator==(const Cell_Type &val) const
void operator/=(const Cell_Type &val)
void operator*=(const Cell_Type &val)
void operator=(const Cell_Type &val)
size_t ncol() const noexcept
size_t nrow() const noexcept
size_t size_t j
size_t i