PolyBoRi
BooleExponent.h
Go to the documentation of this file.
1 
2 // -*- c++ -*-
3 //*****************************************************************************
15 //*****************************************************************************
16 
17 #ifndef polybori_BooleExponent_h_
18 #define polybori_BooleExponent_h_
19 
20 // include basic definitions
21 #include <polybori/pbori_defs.h>
22 
23 // get definition of BoolePolynomial, BooleMonomial, and BooleVariable
24 #include <polybori/BooleMonomial.h>
25 #include <polybori/BooleVariable.h>
26 
28 
35  public CAuxTypes {
36 
37  public:
38 
39  //-------------------------------------------------------------------------
40  // types definitions
41  //-------------------------------------------------------------------------
42 
44  typedef std::vector<idx_type> data_type;
45 
47  typedef data_type::value_type value_type;
48 
50 
51  typedef data_type::iterator iterator;
52  typedef data_type::const_iterator const_iterator;
53  typedef data_type::reverse_iterator reverse_iterator;
54  typedef data_type::const_reverse_iterator const_reverse_iterator;
56 
58  typedef BooleExponent self;
59 
62 
65 
68 
71 
74 
77 
80 
82  BooleExponent();
83 
85  BooleExponent(const self&);
86 
87  // explicit BooleExponent(bool);
88 
90  self& get(const monom_type&);
91  explicit BooleExponent(const monom_type& rhs);
92 
94  ~BooleExponent();
95 
97  const_iterator begin() const { return m_data.begin(); }
98 
100  const_iterator end() const { return m_data.end(); }
101 
103  const_reverse_iterator rbegin() const { return m_data.rbegin(); }
104 
106  const_reverse_iterator rend() const { return m_data.rend(); }
107 
109  size_type size() const { return m_data.size(); }
110 
112  void reserve(size_type nsize) { m_data.reserve(nsize); }
113 
115  void resize(size_type nsize) { m_data.resize(nsize); }
116 
118  deg_type deg() const { return size(); }
119 
121  set_type divisors(const ring_type&) const;
122 
124  set_type multiples(const self&, const ring_type&) const;
125 
127  set_type multiples(const monom_type&) const;
128 
131  return stable_term_hash(begin(), end());
132  }
133 
135  hash_type hash() const { return stableHash(); }
136 
138  self& changeAssign(idx_type);
139 
141  self change(idx_type) const;
142 
144  self& insert(idx_type);
145 
147  self& push_back(idx_type idx);
148 
150  self& remove(idx_type);
151 
153  self insertConst(idx_type) const;
154 
156  self removeConst(idx_type) const;
157 
159  self divide(const self&) const;
160  self divideByIndex(const idx_type& rhs) const {
161  return (reducibleBy(rhs)? removeConst(rhs) : self() ); }
162 
163  self divide(const var_type& rhs) const { return divideByIndex(rhs.index()); }
164  self divide(const monom_type&) const;
165 
167  self multiply(const self&) const;
168 
169  self multiply(const idx_type& rhs) const { return insertConst(rhs); }
170  self multiply(const var_type& rhs) const { return multiply(rhs.index()); }
171  self multiply(const monom_type&) const;
172  self multiplyFirst(const set_type&) const;
173 
174 
175 // /// @name Arithmetical operations
176 // //@{
177 // self& operator*=(const self&);
178 // self& operator/=(const self&);
179 // self& operator*=(const var_type&);
180 // self& operator/=(const var_type&);
181 // //@}
182 
184 
185  bool_type operator==(const self& rhs) const { return m_data == rhs.m_data; }
186  bool_type operator!=(const self& rhs) const { return m_data != rhs.m_data; }
188 
190  self& operator=(const self& rhs) { m_data = rhs.m_data; return *this; }
191  self& operator=(const monom_type& rhs) {
192  m_data.resize(rhs.size());
193  std::copy(rhs.begin(), rhs.end(), internalBegin());
194  return *this;
195  }
196 
198  bool_type reducibleBy(const self& rhs) const;
199  bool_type reducibleBy(const monom_type& rhs) const;
200  bool_type reducibleBy(const idx_type& rhs) const;
201  bool_type reducibleBy(const var_type& rhs) const {
202  return reducibleBy(rhs.index()); }
203 
204 
205 // /// Test for reducibility wrt. to a given variable
206 // bool_type reducibleBy(const var_type& rhs) const;
207 
209  deg_type LCMDeg(const self&) const;
210 
213 
215  self LCM(const self&) const;
216 
218  //self& GCDAssign(const self&);
219 
221  self GCD(const self&) const;
222 
224  self& popFirst() {
225  if(!m_data.empty())
226  m_data.erase(m_data.begin());
227  return *this;
228  }
229 
231  ostream_type& print(ostream_type&) const;
232 
233 protected:
235  iterator internalBegin() { return m_data.begin(); }
236 
238  iterator internalEnd() { return m_data.end(); }
239 
241  reverse_iterator rInternalBegin() { return m_data.rbegin(); }
242 
244  reverse_iterator rInternalEnd() { return m_data.rend(); }
245 
247  data_type m_data;
248 };
249 
250 
252 template <class RHSType>
253 inline BooleExponent
254 operator+(const BooleExponent& lhs, const RHSType& rhs) {
255  return lhs.multiply(rhs);
256 }
257 
259 template <class RHSType>
260 inline BooleExponent
261 operator-(const BooleExponent& lhs, const RHSType& rhs) {
262  return lhs.divide(rhs);
263 }
264 
266 inline BooleExponent
267 GCD(const BooleExponent& lhs, const BooleExponent& rhs ){
268 
269  return lhs.GCD(rhs);
270 }
271 
273 inline BooleExponent
274 LCM(const BooleExponent& lhs, const BooleExponent& rhs ){
275 
276  return lhs.LCM(rhs);
277 }
278 
279 
281 inline BooleExponent::ostream_type&
282 operator<<(BooleExponent::ostream_type& os, const BooleExponent& rhs) {
283  return rhs.print(os);
284 }
285 
287 
288 #endif // of polybori_BooleExponent_h_
This class shows, whether a property of an order is invalid.
Definition: tags.h:27
poly_type::set_type set_type
Type of sets of Boolean variables.
Definition: BooleExponent.h:73
self divide(const var_type &rhs) const
Definition: BooleExponent.h:163
This class is just a wrapper for using variables for storing indices as interim data structure for Bo...
Definition: BooleExponent.h:34
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
hash_type stableHash() const
Hash value for the exponent.
Definition: BooleExponent.h:130
self GCD(const self &) const
Compute the greatest common divisor and assign.
Definition: BooleExponent.cc:303
reverse_iterator rInternalBegin()
Start reverse iteration over indices (constant access)
Definition: BooleExponent.h:241
BoolePolynomial poly_type
Type of Boolean polynomials.
Definition: BooleExponent.h:61
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
const_iterator begin() const
Start iteration over indices (constant access)
Definition: BooleExponent.h:97
poly_type::monom_type monom_type
Type of Boolean variables.
Definition: BooleExponent.h:70
self multiply(const var_type &rhs) const
Definition: BooleExponent.h:170
self LCM(const self &) const
Compute the greatest common divisor.
Definition: BooleExponent.cc:319
int deg_type
Type for polynomial degrees (ranges from -1 to maxint)
Definition: pbori_defs.h:222
self & operator=(const self &rhs)
Assignment operation.
Definition: BooleExponent.h:190
data_type::value_type value_type
Generic access to actual data.
Definition: BooleExponent.h:47
int deg_type
Definition: groebner_defs.h:42
BooleExponent LCM(const BooleExponent &lhs, const BooleExponent &rhs)
Compute the greatest common divisor of two monomials.
Definition: BooleExponent.h:274
const_iterator begin() const
Start iteration over indices.
Definition: BooleMonomial.h:130
BooleExponent operator+(const BooleExponent &lhs, const RHSType &rhs)
Multiplication of monomials.
Definition: BooleExponent.h:254
void stable_term_hash(HashType &seed, Iterator start, Iterator finish)
Definition: pbori_routines_hash.h:83
Accessing .push_back()
Definition: pbori_func.h:48
data_type::iterator iterator
Definition: BooleExponent.h:51
invalid_tag easy_equality_property
This type has no easy equality check.
Definition: BooleExponent.h:79
self & popFirst()
Removes the first index from exponent.
Definition: BooleExponent.h:224
self divideByIndex(const idx_type &rhs) const
Definition: BooleExponent.h:160
poly_type::ring_type ring_type
Type of Boolean variables.
Definition: BooleExponent.h:64
This class reinterprets decicion diagram managers as Boolean polynomial rings, adds an ordering and v...
Definition: BoolePolyRing.h:40
const_iterator end() const
Finish iteration over indices.
Definition: BooleMonomial.h:133
BooleExponent operator-(const BooleExponent &lhs, const RHSType &rhs)
Division of monomials.
Definition: BooleExponent.h:261
iterator internalEnd()
Finish iteration over indices (constant access)
Definition: BooleExponent.h:238
ostream_type & print(ostream_type &) const
Print current polynomial to output stream.
Definition: BooleExponent.cc:428
Accessing .change()
This struct contains auxiliary type definitions.
Definition: pbori_defs.h:210
bool_type operator==(const self &rhs) const
Definition: BooleExponent.h:185
idx_type index() const
Get index of the variable.
Definition: BooleVariable.h:74
self & operator=(const monom_type &rhs)
Definition: BooleExponent.h:191
This class wraps the underlying decicion diagram type and defines the necessary operations.
Definition: BoolePolynomial.h:85
bool_type reducibleBy(const var_type &rhs) const
Definition: BooleExponent.h:201
std::size_t hash_type
Type for hashing.
Definition: pbori_defs.h:231
BooleExponent::ostream_type & operator<<(BooleExponent::ostream_type &os, const BooleExponent &rhs)
Stream output operator.
Definition: BooleExponent.h:282
generate_index_map< self >::type idx_map_type
Type for index maps.
Definition: BooleExponent.h:76
Polynomial multiply(const Polynomial &p, const Polynomial &q)
Definition: ll_red_nf.h:34
void resize(size_type nsize)
Drop compoents from the nsize-th element on.
Definition: BooleExponent.h:115
self divide(const self &) const
Corresponds to division of monomials.
Definition: BooleExponent.cc:268
reverse_iterator rInternalEnd()
Finish reverse iteration over indices (constant access)
Definition: BooleExponent.h:244
int idx_type
Type for indices.
Definition: pbori_defs.h:228
hash_type hash() const
For the exponent we only have one type of hashes.
Definition: BooleExponent.h:135
const_iterator end() const
Finish iteration over indices (constant access)
Definition: BooleExponent.h:100
std::map< Type, idx_type > type
Type for index maps.
Definition: pbori_func.h:642
const_reverse_iterator rend() const
Finish reverse iteration over indices (constant access)
Definition: BooleExponent.h:106
data_type::const_reverse_iterator const_reverse_iterator
Definition: BooleExponent.h:54
Accessing .insert()
data_type::reverse_iterator reverse_iterator
Definition: BooleExponent.h:53
size_type size() const
Size of the exponents.
Definition: BooleMonomial.h:151
poly_type::var_type var_type
Type of Boolean variables.
Definition: BooleExponent.h:67
polybori::CTypes::idx_type idx_type
Definition: groebner_defs.h:44
data_type m_data
The actual exponent indices.
Definition: BooleExponent.h:247
std::size_t size_type
Type for lengths, dimensions, etc.
Definition: pbori_defs.h:219
void reserve(size_type nsize)
Prepare memory for exponents.
Definition: BooleExponent.h:112
data_type::const_iterator const_iterator
Definition: BooleExponent.h:52
BooleExponent GCD(const BooleExponent &lhs, const BooleExponent &rhs)
Compute the greatest common divisor of two monomials.
Definition: BooleExponent.h:267
const_reverse_iterator rbegin() const
Start reverse iteration over indices (constant access)
Definition: BooleExponent.h:103
Definition: BooleSet.h:57
self multiply(const idx_type &rhs) const
Definition: BooleExponent.h:169
This class is just a wrapper for using variables from cudd's decicion diagram.
Definition: BooleMonomial.h:50
size_type size() const
Degree of the corresponding monomial.
Definition: BooleExponent.h:109
bool_type operator!=(const self &rhs) const
Definition: BooleExponent.h:186
bool bool_type
Type for standard true/false statements.
Definition: pbori_defs.h:216
iterator internalBegin()
Start iteration over indices (constant access)
Definition: BooleExponent.h:235
This class is just a wrapper for using variables from cudd's decicion diagram.
Definition: BooleVariable.h:39
std::vector< idx_type > data_type
Define the underlying data structure.
Definition: BooleExponent.h:44
deg_type deg() const
Degree of the corresponding monomial.
Definition: BooleExponent.h:118
self multiply(const self &) const
Corresponds to multiplication of monomials.
Definition: BooleExponent.cc:349