PolyBoRi
BoolePolyRing.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
15 //*****************************************************************************
16 
17 #ifndef polybori_BoolePolyRing_h_
18 #define polybori_BoolePolyRing_h_
19 
20 // load PolyBoRi settings
21 # include <polybori/pbori_defs.h>
22 
23 // include basic decision diagram manager interface
24 #include "ring/CCuddCore.h"
25 #include "except/PBoRiError.h"
26 #include "common/CCheckedIdx.h"
27 #include <boost/intrusive_ptr.hpp>
28 #include "common/CWeakPtr.h"
29 #include <list>
30 
32 
33 class WeakRingPtr; // forward declaration
34 
42  public CTypes::auxtypes_type {
43 
45  typedef BoolePolyRing self;
46 
47  public:
48 
50  friend class WeakRingPtr;
51 
53  typedef class BooleExponent exp_type;
54 
56  typedef class BooleMonomial monom_type;
57 
59  typedef class BooleVariable var_type;
60 
62  typedef class BooleSet dd_type;
63 
65  typedef class BoolePolynomial poly_type;
67 
71 
74 
79  typedef boost::intrusive_ptr<core_type> core_ptr;
80 
83 
86 
88  typedef order_type& order_reference;
89 
93 
95  typedef std::vector<idx_type> block_idx_type;
96 
98  typedef block_idx_type::const_iterator block_iterator;
99 
100 protected:
101 
104  BoolePolyRing(const core_ptr& rhs): p_core(rhs) {}
105 
107  explicit BoolePolyRing(const CWeakPtr<core_type>& rhs):
108  p_core(rhs.operator->()) { PBORI_ASSERT(p_core != NULL); }
109 
110 public:
112  explicit BoolePolyRing(size_type nvars = 1,
113  ordercode_type order = lp);
114 
116  BoolePolyRing(size_type nvars, const order_ptr& order):
117  p_core(new core_type(nvars, order)) {}
118 
120  BoolePolyRing(const self& rhs): p_core(rhs.p_core) {}
121 
124 
126  size_type nVariables() const { return p_core->m_mgr.nVariables(); }
127 
129  vartext_type getVariableName(checked_idx_type idx) const {
130  return p_core->m_names[idx];
131  }
132 
134  void setVariableName(checked_idx_type idx, vartext_type varname) {
135  p_core->m_names.set(idx, varname);
136  }
137 
139  void clearCache() { p_core->m_mgr.cacheFlush(); }
140 
142  ostream_type& print(ostream_type&) const;
143 
145  hash_type hash() const {
146  return static_cast<hash_type>(reinterpret_cast<std::ptrdiff_t
147  >(getManager()));
148  }
149 
151  hash_type id() const {
152  return static_cast<hash_type>(reinterpret_cast<std::ptrdiff_t>(p_core.operator->()));
153  }
154 
156  order_reference ordering() const { return *(p_core->pOrder); }
157 
159  mgr_type* getManager() const { return p_core->m_mgr.getManager(); }
160 
162  self clone() const { return self(core_ptr(new core_type(*p_core))); }
163 
165  void changeOrdering(ordercode_type);
166 
168  poly_type coerce(const poly_type& rhs) const;
169 
171  monom_type coerce(const monom_type& rhs) const;
172 
174  var_type coerce(const var_type& rhs) const;
175 
177  dd_type variableDiagram(checked_idx_type nvar) const;
178 
180  var_type variable(checked_idx_type nvar) const;
181 
183  dd_type zero() const;
184 
186  dd_type one() const;
187 
189  dd_type constant(bool is_one) const;
190 
191 protected:
193  core_ptr core() const { return p_core; };
194 
196  core_ptr p_core;
197 };
198 
200 inline BoolePolyRing::ostream_type&
201 operator<<(BoolePolyRing::ostream_type& os, const BoolePolyRing& ring) {
202  return ring.print(os);
203 }
204 
206 
207 
208 #endif // of #ifndef polybori_BoolePolyRing_h_
mgr_type * getManager() const
Get plain decision diagram manager.
Definition: BoolePolyRing.h:159
order_type & order_reference
Reference for handling mterm orderings.
Definition: BoolePolyRing.h:88
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
variable_names_type::const_reference const_varname_reference
Define type for getting names of variables.
Definition: CCuddCore.h:63
ordercodes
Codes For orderings.
Definition: pbori_defs.h:154
CTypes::vartext_type vartext_type
Definition: BoolePolyRing.h:69
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
core_type::const_varname_reference const_varname_reference
Definition: BoolePolyRing.h:77
CCheckedIdx checked_idx_type
Check indices bevor using.
Definition: BoolePolyRing.h:73
BoolePolyRing::ostream_type & operator<<(BoolePolyRing::ostream_type &os, const BoolePolyRing &ring)
Stream output operator.
Definition: BoolePolyRing.h:201
This struct contains type definitions and enumerations to be used for order codes.
Definition: pbori_defs.h:152
self clone() const
Construct ring with similiar properties (deep copy)
Definition: BoolePolyRing.h:162
class BooleVariable var_type
set variables type
Definition: BoolePolyRing.h:59
class BooleMonomial monom_type
set monomial type
Definition: BoolePolyRing.h:56
Definition: COrderingBase.h:43
This class reinterprets decicion diagram managers as Boolean polynomial rings, adds an ordering and v...
Definition: BoolePolyRing.h:40
CCuddCore core_type
Type of actual data.
Definition: BoolePolyRing.h:76
std::vector< idx_type > block_idx_type
Type for block indices.
Definition: BoolePolyRing.h:95
CTypes::ordercode_type ordercode_type
Definition: BoolePolyRing.h:68
order_reference ordering() const
Access ordering of *this.
Definition: BoolePolyRing.h:156
This struct contains auxiliary type definitions.
Definition: pbori_defs.h:210
This class defines WeakRingPtr.
Definition: WeakRingPtr.h:32
This class wraps the underlying decicion diagram type and defines the necessary operations.
Definition: BoolePolynomial.h:85
hash_type id() const
Get unique identifier for this ring.
Definition: BoolePolyRing.h:151
This class prepares the CUDD's raw decision diagram manager structure for the use with instrinsive po...
Definition: CCuddCore.h:50
std::size_t hash_type
Type for hashing.
Definition: pbori_defs.h:231
class BooleSet dd_type
set decision diagram type
Definition: BoolePolyRing.h:62
class BooleExponent exp_type
define exponent type
Definition: BoolePolyRing.h:53
Definition: embed.h:57
void clearCache()
Clears the function cache.
Definition: BoolePolyRing.h:139
pbori_DdManager DdManager
Definition: traits.h:33
#define PBORI_ASSERT(arg)
Definition: pbori_defs.h:118
vartext_type getVariableName(checked_idx_type idx) const
Get name of variable with index idx.
Definition: BoolePolyRing.h:129
size_type nVariables() const
Get number of ring variables.
Definition: BoolePolyRing.h:126
ostream_type & print(ostream_type &) const
Print out statistics and settings for current ring to output stream.
Definition: BoolePolyRing.cc:120
core_type::order_ptr order_ptr
Smart pointer for handling mterm orderings.
Definition: BoolePolyRing.h:85
void setVariableName(checked_idx_type idx, vartext_type varname)
Set name of variable with index idx.
Definition: BoolePolyRing.h:134
~BoolePolyRing()
Destructor.
Definition: BoolePolyRing.h:123
BoolePolyRing(const CWeakPtr< core_type > &rhs)
Get strong reference from weak pointer (used by WeakRingPtr)
Definition: BoolePolyRing.h:107
Forward declaration of friend.
Definition: CWeakPtr.h:31
const char * vartext_type
Type for setting/getting names of variables.
Definition: pbori_defs.h:249
BoolePolyRing(const self &rhs)
Copy constructor (cheap)
Definition: BoolePolyRing.h:120
hash_type hash() const
Get unique identifier for manager of *this.
Definition: BoolePolyRing.h:145
BoolePolyRing(const core_ptr &rhs)
Definition: BoolePolyRing.h:104
std::size_t size_type
Type for lengths, dimensions, etc.
Definition: pbori_defs.h:219
boost::shared_ptr< order_type > order_ptr
Smart pointer for handling mterm orderings.
Definition: CCuddCore.h:72
Definition: BooleSet.h:57
This class is just a wrapper for using variables from cudd's decicion diagram.
Definition: BooleMonomial.h:50
block_idx_type::const_iterator block_iterator
Type for block iterators.
Definition: BoolePolyRing.h:98
DdManager mgr_type
Definition: BoolePolyRing.h:90
This class is just a wrapper for using variables from cudd's decicion diagram.
Definition: BooleVariable.h:39
This struct contains type definitions and enumerations to be used for comparisons.
Definition: pbori_defs.h:193
boost::intrusive_ptr< core_type > core_ptr
Smart pointer to core.
Definition: BoolePolyRing.h:79
This class defines CCheckedIdx.
Definition: CCheckedIdx.h:29
int ordercode_type
Type for ordering codes.
Definition: pbori_defs.h:240
BoolePolyRing(size_type nvars, const order_ptr &order)
Constructor for nvars variables (and given pointer to ordering)
Definition: BoolePolyRing.h:116
core_type::order_type order_type
Type for handling mterm orderings.
Definition: BoolePolyRing.h:82
class BoolePolynomial poly_type
set polynomial type
Definition: BoolePolyRing.h:65