PolyBoRi
BooleSet.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
14 //*****************************************************************************
15 
16 #ifndef polybori_BooleSet_h_
17 #define polybori_BooleSet_h_
18 
19 // include basic definitions
20 #include <polybori/pbori_defs.h>
21 
22 // include polybori functionals
24 
26 
27 #include "BoolePolyRing.h"
28 
30 
32 class BooleMonomial;
33 class BooleExponent;
34 
35 template<class OrderType, class NavigatorType, class MonomType>
36 class CGenericIter;
37 // temporarily
38 class LexOrder;
39 
40 template<class OrderType, class NavigatorType, class MonomType>
42 
43 
44 #define PBORI_CONST_DDFUNCS(func) \
45  self func(const self& rhs) const { return self(base::func(rhs.diagram())); }
46 
47 #define PBORI_DDFUNCS(func) \
48  self& func(const self& rhs) { base::func(rhs.diagram()); return *this; }
49 
50 #define PBORI_CONST_DDFUNCS_IDX(func) \
51  self func(idx_type idx) const { return self(base::func(idx)); }
52 
53 #define PBORI_DDFUNCS_IDX(func) \
54  self& func(idx_type idx) { base::func(idx); return *this; }
55 
56 
57 class BooleSet:
58  public CCuddDDFacade<BoolePolyRing, BooleSet> {
60  typedef BooleSet self;
61 
62 public:
64  typedef self dd_type;
65 
68 
71 
74 
77 
80 
83 
86 
89 
90 public:
92  BooleSet(const self& rhs): base(rhs) {}
93 
95  BooleSet(const base& rhs): base(rhs) {}
96 
98  BooleSet(idx_type idx, const self& first, const self& second):
99  base(idx, first, second) { }
100 
102  BooleSet(idx_type idx, navigator first, navigator second,
103  const ring_type& ring):
104  base(ring, idx, first, second) { }
105 
107  BooleSet(const ring_type& ring, node_ptr node):
108  base(ring, node) { }
109 
111  BooleSet(const ring_type& ring, navigator navi):
112  base(ring, navi.getNode()) { }
113 
115  BooleSet(const ring_type& ring):
116  base(ring.zero()) { };
117 
119  BooleSet(idx_type idx, const self& rhs):
120  base(idx, rhs, rhs) { }
121 
123  BooleSet(navigator navi, const ring_type& ring):
124  base(ring, navi) { }
125 
128 
130  const_iterator begin() const;
131 
133  const_iterator end() const;
134 
136  const_reverse_iterator rbegin() const;
137 
139  const_reverse_iterator rend() const;
140 
142  reverse_exp_iterator rExpBegin() const;
143 
145  reverse_exp_iterator rExpEnd() const;
146 
148  exp_iterator expBegin() const;
149 
151  exp_iterator expEnd() const;
152 
154  hash_type hash() const {
155  return static_cast<hash_type>(reinterpret_cast<std::ptrdiff_t>(getNode()));
156  }
157 
160  return stable_hash_range(navigation());
161  }
162 
164  term_type usedVariables() const;
165 
167  exp_type usedVariablesExp() const;
168 
169  self change(idx_type idx) const {
170  if PBORI_UNLIKELY(size_type(idx) >= ring().nVariables())
171  throw PBoRiError(CTypes::out_of_bounds);
172  return base::change(idx);
173  }
174 
175 
177  self add(const term_type& rhs) const;
178 
179  // Check whether rhs is included in *this
180  bool_type owns(const term_type& rhs) const;
181 
183  bool_type owns(const exp_type&) const;
184 
186  term_type lastLexicographicalTerm() const;
187 
189  self divisorsOf(const term_type& rhs) const;
190 
192  self divisorsOf(const exp_type& rhs) const;
193 
195  self firstDivisorsOf(const self& rhs) const;
196 
198  self multiplesOf(const term_type& rhs) const;
199 
201  self divide(const term_type& rhs) const;
202 
205  bool_type hasTermOfVariables(const term_type& rhs) const;
206 
208  self minimalElements() const;
209 
211  bool_type ownsOne() const { return owns_one(navigation()); }
212 
214  bool_type isSingleton() const { return dd_is_singleton(navigation()); }
215 
218  return dd_is_singleton_or_pair(navigation());
219  }
220 
222  bool_type isPair() const { return dd_is_pair(navigation()); }
223 
228  self existAbstract(const term_type& rhs) const;
229 
231  const self& diagram() const { return *this; } // to be removed
232 
234  self cartesianProduct(const self& rhs) const {
235  return unateProduct(rhs);
236  };
237 
239  bool_type contains(const self& rhs) const { return rhs.implies(*this); }
240 
242  size_type size() const { return count(); }
243 
245  size_type length() const { return size(); }
246 
248  size_type nVariables() const { return ring().nVariables(); }
249 
251  double sizeDouble() const { return countDouble(); }
252 
254  ostream_type& print(ostream_type&) const;
255 
257  self emptyElement() const { return ring().zero(); }
258 
260  size_type countIndex(idx_type idx) const;
261 
263  double countIndexDouble(idx_type idx) const ;
264 
266  bool_type containsDivisorsOfDecDeg(const term_type& rhs) const;
267 
269  bool_type containsDivisorsOfDecDeg(const exp_type& rhs) const;
270 };
271 
273 inline BooleSet::ostream_type&
275  return bset.print(os);
276 }
277 
278 
280 
281 #endif