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
polybori::BooleSet::ring_type
BoolePolyRing ring_type
Type for Boolean polynomial rings (without ordering)
Definition: BooleSet.h:76
polybori::BooleExponent
This class is just a wrapper for using variables for storing indices as interim data structure for Bo...
Definition: BooleExponent.h:34
END_NAMESPACE_PBORI
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
polybori::dd_is_pair
bool dd_is_pair(NaviType navi)
Definition: pbori_algo.h:805
polybori::stable_hash_range
void stable_hash_range(HashType &seed, NaviType navi)
Definition: pbori_routines_hash.h:28
polybori::BooleSet::BooleSet
BooleSet(idx_type idx, navigator first, navigator second, const ring_type &ring)
Construct new node (using navigator nodes)
Definition: BooleSet.h:102
BEGIN_NAMESPACE_PBORI
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
polybori::BooleSet::term_type
BooleMonomial term_type
Type of terms.
Definition: BooleSet.h:70
polybori::BooleSet::diagram
const self & diagram() const
Access internal decision diagram.
Definition: BooleSet.h:231
polybori::BooleSet::contains
bool_type contains(const self &rhs) const
Test containment.
Definition: BooleSet.h:239
polybori::BooleSet::isPair
bool_type isPair() const
Test, whether we have two terms only.
Definition: BooleSet.h:222
polybori::BooleSet::exp_type
BooleExponent exp_type
Fix type for treatment of exponent vectors.
Definition: BooleSet.h:73
polybori::BooleSet::stableHash
hash_type stableHash() const
Get stable hash value, which is reproducible.
Definition: BooleSet.h:159
polybori::BooleSet::nVariables
size_type nVariables() const
Returns number of variables in manager.
Definition: BooleSet.h:248
polybori::BooleSet::BooleSet
BooleSet(const ring_type &ring, navigator navi)
Construct new node (using navigator nodes)
Definition: BooleSet.h:111
polybori::BooleSet::BooleSet
BooleSet(const base &rhs)
Copy constructor.
Definition: BooleSet.h:95
polybori::BooleSet::exp_iterator
CGenericIter< LexOrder, navigator, exp_type > exp_iterator
Iterator type for iterating all exponent vectors.
Definition: BooleSet.h:82
polybori::BoolePolyRing
This class reinterprets decicion diagram managers as Boolean polynomial rings, adds an ordering and v...
Definition: BoolePolyRing.h:40
pbori_func.h
polybori::CAuxTypes::ostream_type
std::ostream ostream_type
Type for out-stream.
Definition: pbori_defs.h:246
polybori::operator<<
BooleSet::ostream_type & operator<<(BooleSet::ostream_type &os, const BooleSet &bset)
Stream output operator.
Definition: BooleSet.h:274
polybori::BooleSet::sizeDouble
double sizeDouble() const
Approximation of number of terms.
Definition: BooleSet.h:251
CCuddDDFacade.h
polybori::CAuxTypes::hash_type
std::size_t hash_type
Type for hashing.
Definition: pbori_defs.h:231
pbori_defs.h
polybori::dd_is_singleton
bool dd_is_singleton(NaviType navi)
Definition: pbori_algo.h:770
polybori::CCuddDDFacade
This template class defines a facade for decision diagrams.
Definition: CCuddDDFacade.h:103
polybori::PBoRiError
This class is used for polybori's exception handling.
Definition: PBoRiError.h:31
polybori::BooleSet::size
size_type size() const
Returns number of terms.
Definition: BooleSet.h:242
polybori::BooleSet::base
CCuddDDFacade< BoolePolyRing, BooleSet > base
Generic access to base type.
Definition: BooleSet.h:67
polybori::BooleSet::BooleSet
BooleSet(navigator navi, const ring_type &ring)
Construct from navigator node.
Definition: BooleSet.h:123
polybori::BooleSet::isSingleton
bool_type isSingleton() const
Test, whether we have one term only.
Definition: BooleSet.h:214
polybori::BooleSet::BooleSet
BooleSet(const ring_type &ring, node_ptr node)
Construct new node (using nodes)
Definition: BooleSet.h:107
polybori::BooleSet::emptyElement
self emptyElement() const
Get corresponding zero element (may be removed in the future)
Definition: BooleSet.h:257
polybori::CAuxTypes::idx_type
int idx_type
Type for indices.
Definition: pbori_defs.h:228
polybori::BooleSet::ownsOne
bool_type ownsOne() const
Test whether the empty set is included.
Definition: BooleSet.h:211
polybori::CReverseIter
Definition: BooleSet.h:41
polybori::CGenericIter
Definition: BoolePolynomial.h:70
polybori::BooleSet::change
self change(idx_type idx) const
Definition: BooleSet.h:169
polybori::BooleSet::BooleSet
BooleSet(const self &rhs)
Copy constructor.
Definition: BooleSet.h:92
BoolePolyRing.h
polybori::BooleSet::isSingletonOrPair
bool_type isSingletonOrPair() const
Test, whether we have one or two terms only.
Definition: BooleSet.h:217
polybori::BooleSet::print
ostream_type & print(ostream_type &) const
Print current set to output stream.
Definition: BooleSet.cc:266
polybori::BooleSet::cartesianProduct
self cartesianProduct(const self &rhs) const
Cartesean product.
Definition: BooleSet.h:234
polybori::groebner::idx_type
polybori::CTypes::idx_type idx_type
Definition: groebner_defs.h:44
polybori::CAuxTypes::size_type
std::size_t size_type
Type for lengths, dimensions, etc.
Definition: pbori_defs.h:219
polybori::CCuddNavigator
This class defines an iterator for navigating through then and else branches of ZDDs.
Definition: CCuddNavigator.h:36
polybori::BooleSet::length
size_type length() const
Returns number of terms (deprecated)
Definition: BooleSet.h:245
polybori::BooleSet::BooleSet
BooleSet(const ring_type &ring)
Construct empty set in ring.
Definition: BooleSet.h:115
polybori::BooleSet::BooleSet
BooleSet(idx_type idx, const self &rhs)
Construct new node (using navigator for then and else-branches)
Definition: BooleSet.h:119
polybori::BooleSet
Definition: BooleSet.h:57
polybori::dd_is_singleton_or_pair
bool dd_is_singleton_or_pair(NaviType navi)
Definition: pbori_algo.h:798
polybori::BooleSet::const_reverse_iterator
CReverseIter< LexOrder, navigator, term_type > const_reverse_iterator
Iterator type for iterating all monomials.
Definition: BooleSet.h:88
polybori::BooleMonomial
This class is just a wrapper for using variables from cudd's decicion diagram.
Definition: BooleMonomial.h:50
polybori::BooleSet::dd_type
self dd_type
Generic access to type of *this.
Definition: BooleSet.h:64
polybori::BooleSet::~BooleSet
~BooleSet()
Destructor.
Definition: BooleSet.h:127
polybori::CAuxTypes::bool_type
bool bool_type
Type for standard true/false statements.
Definition: pbori_defs.h:216
PBORI_UNLIKELY
#define PBORI_UNLIKELY(expression)
Definition: pbori_defs.h:59
polybori::BooleSet::BooleSet
BooleSet(idx_type idx, const self &first, const self &second)
Construct new node.
Definition: BooleSet.h:98
polybori::BooleSet::const_iterator
CGenericIter< LexOrder, navigator, term_type > const_iterator
Iterator type for iterating all monomials.
Definition: BooleSet.h:79
polybori::BooleSet::reverse_exp_iterator
CReverseIter< LexOrder, navigator, exp_type > reverse_exp_iterator
Iterator type for iterating all exponent vectors.
Definition: BooleSet.h:85
polybori::BooleSet::hash
hash_type hash() const
Get unique hash value (valid only per runtime)
Definition: BooleSet.h:154
polybori::CApplyNodeFacade< BooleSet, DdNode * >::node_ptr
DdNode * node_ptr
Definition: CApplyNodeFacade.h:50
polybori::owns_one
bool owns_one(NaviType navi)
Test whether the empty set is included.
Definition: pbori_algo.h:318