Go to the documentation of this file.00001
00002
00073
00074
00075 #ifndef BooleExponent_h_
00076 #define BooleExponent_h_
00077
00078
00079 #include "pbori_defs.h"
00080
00081
00082 #include "BooleMonomial.h"
00083 #include "BooleVariable.h"
00084
00085 BEGIN_NAMESPACE_PBORI
00086
00092 class BooleExponent {
00093
00094 public:
00095
00096
00097
00098
00099
00101
00102 typedef CTypes::dd_type dd_type;
00103 typedef CTypes::size_type size_type;
00104 typedef CTypes::deg_type deg_type;
00105 typedef CTypes::idx_type idx_type;
00106 typedef CTypes::hash_type hash_type;
00107 typedef CTypes::bool_type bool_type;
00108 typedef CTypes::comp_type comp_type;
00109 typedef CTypes::integer_type integer_type;
00110 typedef CTypes::ostream_type ostream_type;
00112
00114 typedef std::vector<idx_type> data_type;
00115
00117 typedef data_type::value_type value_type;
00118
00120
00121 typedef data_type::iterator iterator;
00122 typedef data_type::const_iterator const_iterator;
00123 typedef data_type::reverse_iterator reverse_iterator;
00124 typedef data_type::const_reverse_iterator const_reverse_iterator;
00126
00128 typedef BooleExponent self;
00129
00131 typedef BoolePolynomial poly_type;
00132
00134 typedef BooleVariable var_type;
00135
00137 typedef BooleMonomial monom_type;
00138
00140 typedef BooleSet set_type;
00141
00143 typedef generate_index_map<self>::type idx_map_type;
00144
00146 typedef invalid_tag easy_equality_property;
00147
00149 BooleExponent();
00150
00152 BooleExponent(const self&);
00153
00154 explicit BooleExponent(bool);
00155
00157 self& get(const monom_type&);
00158
00159
00160
00161
00163 ~BooleExponent();
00164
00166 const_iterator begin() const { return m_data.begin(); }
00167
00169 const_iterator end() const { return m_data.end(); }
00170
00172 const_reverse_iterator rbegin() const { return m_data.rbegin(); }
00173
00175 const_reverse_iterator rend() const { return m_data.rend(); }
00176
00178 deg_type size() const { return (deg_type)m_data.size(); }
00179
00181 void reserve(size_type nsize) { m_data.reserve(nsize); }
00182
00184 void resize(size_type nsize) { m_data.resize(nsize); }
00185
00187 size_type deg() const { return size(); }
00188
00190 set_type divisors() const;
00191
00193 set_type multiples(const self&) const;
00194
00196 hash_type stableHash() const {
00197 return stable_term_hash(begin(), end());
00198 }
00199
00201 hash_type hash() const { return stableHash(); }
00202
00204 self& changeAssign(idx_type);
00205
00207 self change(idx_type) const;
00208
00210 self& insert(idx_type);
00211
00213 self& push_back(idx_type idx);
00214
00216 self& remove(idx_type);
00217
00219 self insertConst(idx_type) const;
00220
00222 self removeConst(idx_type) const;
00223
00225 self divide(const self&) const;
00226 self divide(const idx_type& rhs) const {
00227 return (reducibleBy(rhs)? removeConst(rhs) : self() ); }
00228
00229 self divide(const var_type& rhs) const { return divide(rhs.index()); }
00230 self divide(const monom_type&) const;
00231
00233 self multiply(const self&) const;
00234
00235 self multiply(const idx_type& rhs) const { return insertConst(rhs); }
00236 self multiply(const var_type& rhs) const { return multiply(rhs.index()); }
00237 self multiply(const monom_type&) const;
00238 self multiplyFirst(const set_type&) const;
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00250
00251 bool_type operator==(const self& rhs) const { return m_data == rhs.m_data; }
00252 bool_type operator!=(const self& rhs) const { return m_data != rhs.m_data; }
00254
00256 self& operator=(const self& rhs) { m_data = rhs.m_data; return *this; }
00257 self& operator=(const monom_type& rhs) {
00258 m_data.resize(rhs.size());
00259 std::copy(rhs.begin(), rhs.end(), internalBegin());
00260 return *this;
00261 }
00262
00264 bool_type reducibleBy(const self& rhs) const;
00265 bool_type reducibleBy(const monom_type& rhs) const;
00266 bool_type reducibleBy(const idx_type& rhs) const;
00267 bool_type reducibleBy(const var_type& rhs) const {
00268 return reducibleBy(rhs.index()); }
00269
00270
00271
00272
00273
00275 comp_type compare(const self&) const;
00276
00278 size_type LCMDeg(const self&) const;
00279
00282
00284 self LCM(const self&) const;
00285
00287
00288
00290 self GCD(const self&) const;
00291
00293 self& popFirst() {
00294 assert(!m_data.empty());
00295 m_data.erase(m_data.begin());
00296 return *this;
00297 }
00298
00300 ostream_type& print(ostream_type&) const;
00301
00302 protected:
00304 iterator internalBegin() { return m_data.begin(); }
00305
00307 iterator internalEnd() { return m_data.end(); }
00308
00310 reverse_iterator rInternalBegin() { return m_data.rbegin(); }
00311
00313 reverse_iterator rInternalEnd() { return m_data.rend(); }
00314
00316 data_type m_data;
00317 };
00318
00319
00321 template <class RHSType>
00322 inline BooleExponent
00323 operator+(const BooleExponent& lhs, const RHSType& rhs) {
00324 return lhs.multiply(rhs);
00325 }
00326
00328 template <class RHSType>
00329 inline BooleExponent
00330 operator-(const BooleExponent& lhs, const RHSType& rhs) {
00331 return lhs.divide(rhs);
00332 }
00333
00334
00336 inline BooleExponent::bool_type
00337 operator<(const BooleExponent& lhs, const BooleExponent& rhs) {
00338
00339 return (lhs.compare(rhs) == CTypes::less_than);
00340 }
00341
00343 inline BooleExponent::bool_type
00344 operator>(const BooleExponent& lhs, const BooleExponent& rhs) {
00345
00346 return (lhs.compare(rhs) == CTypes::greater_than);
00347 }
00348
00350 inline BooleExponent::bool_type
00351 operator<=(const BooleExponent& lhs, const BooleExponent& rhs) {
00352
00353 return (lhs.compare(rhs) <= CTypes::less_or_equal_max);
00354 }
00355
00357 inline BooleExponent::bool_type
00358 operator>=(const BooleExponent& lhs, const BooleExponent& rhs) {
00359
00360 return (lhs.compare(rhs) >= CTypes::greater_or_equal_min);
00361 }
00362
00363
00365 inline BooleExponent
00366 GCD(const BooleExponent& lhs, const BooleExponent& rhs ){
00367
00368 return lhs.GCD(rhs);
00369 }
00370
00372 inline BooleExponent
00373 LCM(const BooleExponent& lhs, const BooleExponent& rhs ){
00374
00375 return lhs.LCM(rhs);
00376 }
00377
00378
00380 inline BooleExponent::ostream_type&
00381 operator<<(BooleExponent::ostream_type& os, const BooleExponent& rhs) {
00382 return rhs.print(os);
00383 }
00384
00385 END_NAMESPACE_PBORI
00386
00387 #endif // of BooleExponent_h_