BooleSet.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_BooleSet_h_
#define polybori_BooleSet_h_
// include basic definitions
#include <polybori/pbori_defs.h>
// include polybori functionals
#include <polybori/routines/pbori_func.h>
#include <polybori/diagram/CCuddDDFacade.h>
#include "BoolePolyRing.h"
BEGIN_NAMESPACE_PBORI
class BooleMonomial;
class BooleExponent;
template<class OrderType, class NavigatorType, class MonomType>
class CGenericIter;
// temporarily
class LexOrder;
template<class OrderType, class NavigatorType, class MonomType>
class CReverseIter;
#define PBORI_CONST_DDFUNCS(func) \
self func(const self& rhs) const { return self(base::func(rhs.diagram())); }
#define PBORI_DDFUNCS(func) \
self& func(const self& rhs) { base::func(rhs.diagram()); return *this; }
#define PBORI_CONST_DDFUNCS_IDX(func) \
self func(idx_type idx) const { return self(base::func(idx)); }
#define PBORI_DDFUNCS_IDX(func) \
self& func(idx_type idx) { base::func(idx); return *this; }
class BooleSet:
public CCuddDDFacade<BoolePolyRing, BooleSet> {
typedef BooleSet self;
public:
typedef self dd_type;
typedef CCuddDDFacade<BoolePolyRing, BooleSet> base;
typedef BooleMonomial term_type;
typedef BooleExponent exp_type;
typedef BoolePolyRing ring_type;
typedef CGenericIter<LexOrder, navigator, term_type> const_iterator;
typedef CGenericIter<LexOrder, navigator, exp_type> exp_iterator;
typedef CReverseIter<LexOrder, navigator, exp_type> reverse_exp_iterator;
typedef CReverseIter<LexOrder, navigator, term_type> const_reverse_iterator;
public:
BooleSet(const self& rhs): base(rhs) {}
BooleSet(const base& rhs): base(rhs) {}
BooleSet(idx_type idx, const self& first, const self& second):
base(idx, first, second) { }
BooleSet(idx_type idx, navigator first, navigator second,
const ring_type& ring):
base(ring, idx, first, second) { }
BooleSet(const ring_type& ring, node_ptr node):
base(ring, node) { }
BooleSet(const ring_type& ring, navigator navi):
base(ring, navi.getNode()) { }
BooleSet(const ring_type& ring):
base(ring.zero()) { };
BooleSet(idx_type idx, const self& rhs):
base(idx, rhs, rhs) { }
BooleSet(navigator navi, const ring_type& ring):
base(ring, navi) { }
~BooleSet() {}
const_iterator begin() const;
const_iterator end() const;
const_reverse_iterator rbegin() const;
const_reverse_iterator rend() const;
reverse_exp_iterator rExpBegin() const;
reverse_exp_iterator rExpEnd() const;
exp_iterator expBegin() const;
exp_iterator expEnd() const;
hash_type hash() const {
return static_cast<hash_type>(reinterpret_cast<std::ptrdiff_t>(getNode()));
}
hash_type stableHash() const {
return stable_hash_range(navigation());
}
term_type usedVariables() const;
exp_type usedVariablesExp() const;
self change(idx_type idx) const {
if PBORI_UNLIKELY(size_type(idx) >= ring().nVariables())
throw PBoRiError(CTypes::out_of_bounds);
return base::change(idx);
}
self add(const term_type& rhs) const;
// Check whether rhs is included in *this
bool_type owns(const term_type& rhs) const;
bool_type owns(const exp_type&) const;
term_type lastLexicographicalTerm() const;
self divisorsOf(const term_type& rhs) const;
self divisorsOf(const exp_type& rhs) const;
self firstDivisorsOf(const self& rhs) const;
self multiplesOf(const term_type& rhs) const;
self divide(const term_type& rhs) const;
bool_type hasTermOfVariables(const term_type& rhs) const;
self minimalElements() const;
bool_type ownsOne() const { return owns_one(navigation()); }
bool_type isSingleton() const { return dd_is_singleton(navigation()); }
bool_type isSingletonOrPair() const {
return dd_is_singleton_or_pair(navigation());
}
bool_type isPair() const { return dd_is_pair(navigation()); }
self existAbstract(const term_type& rhs) const;
const self& diagram() const { return *this; } // to be removed
self cartesianProduct(const self& rhs) const {
return unateProduct(rhs);
};
bool_type contains(const self& rhs) const { return rhs.implies(*this); }
size_type size() const { return count(); }
size_type length() const { return size(); }
size_type nVariables() const { return ring().nVariables(); }
double sizeDouble() const { return countDouble(); }
ostream_type& print(ostream_type&) const;
self emptyElement() const { return ring().zero(); }
size_type countIndex(idx_type idx) const;
double countIndexDouble(idx_type idx) const ;
bool_type containsDivisorsOfDecDeg(const term_type& rhs) const;
bool_type containsDivisorsOfDecDeg(const exp_type& rhs) const;
};
inline BooleSet::ostream_type&
operator<<( BooleSet::ostream_type& os, const BooleSet& bset ) {
return bset.print(os);
}
END_NAMESPACE_PBORI
#endif