BoolePolyRing.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_BoolePolyRing_h_
#define polybori_BoolePolyRing_h_
// load PolyBoRi settings
# include <polybori/pbori_defs.h>
// include basic decision diagram manager interface
#include "ring/CCuddCore.h"
#include "except/PBoRiError.h"
#include "common/CCheckedIdx.h"
#include <boost/intrusive_ptr.hpp>
#include "common/CWeakPtr.h"
#include <list>
BEGIN_NAMESPACE_PBORI
class WeakRingPtr; // forward declaration
class BoolePolyRing:
public CTypes::orderenums_type, public CTypes::compenums_type,
public CTypes::auxtypes_type {
typedef BoolePolyRing self;
public:
friend class WeakRingPtr;
typedef class BooleExponent exp_type;
typedef class BooleMonomial monom_type;
typedef class BooleVariable var_type;
typedef class BooleSet dd_type;
typedef class BoolePolynomial poly_type;
typedef CTypes::ordercode_type ordercode_type;
typedef CTypes::vartext_type vartext_type;
typedef CCheckedIdx checked_idx_type;
typedef CCuddCore core_type;
typedef core_type::const_varname_reference const_varname_reference;
typedef boost::intrusive_ptr<core_type> core_ptr;
typedef core_type::order_type order_type;
typedef core_type::order_ptr order_ptr;
typedef order_type& order_reference;
typedef DdManager mgr_type;
using CTypes::orderenums_type::ordercodes;
typedef std::vector<idx_type> block_idx_type;
typedef block_idx_type::const_iterator block_iterator;
protected:
BoolePolyRing(const core_ptr& rhs): p_core(rhs) {}
explicit BoolePolyRing(const CWeakPtr<core_type>& rhs):
p_core(rhs.operator->()) { PBORI_ASSERT(p_core != NULL); }
public:
explicit BoolePolyRing(size_type nvars = 1,
ordercode_type order = lp);
BoolePolyRing(size_type nvars, const order_ptr& order):
p_core(new core_type(nvars, order)) {}
BoolePolyRing(const self& rhs): p_core(rhs.p_core) {}
~BoolePolyRing() {}
size_type nVariables() const { return p_core->m_mgr.nVariables(); }
vartext_type getVariableName(checked_idx_type idx) const {
return p_core->m_names[idx];
}
void setVariableName(checked_idx_type idx, vartext_type varname) {
p_core->m_names.set(idx, varname);
}
void clearCache() { p_core->m_mgr.cacheFlush(); }
ostream_type& print(ostream_type&) const;
hash_type hash() const {
return static_cast<hash_type>(reinterpret_cast<std::ptrdiff_t
>(getManager()));
}
hash_type id() const {
return static_cast<hash_type>(reinterpret_cast<std::ptrdiff_t>(p_core.operator->()));
}
order_reference ordering() const { return *(p_core->pOrder); }
mgr_type* getManager() const { return p_core->m_mgr.getManager(); }
self clone() const { return self(core_ptr(new core_type(*p_core))); }
void changeOrdering(ordercode_type);
poly_type coerce(const poly_type& rhs) const;
monom_type coerce(const monom_type& rhs) const;
var_type coerce(const var_type& rhs) const;
dd_type variableDiagram(checked_idx_type nvar) const;
var_type variable(checked_idx_type nvar) const;
dd_type zero() const;
dd_type one() const;
dd_type constant(bool is_one) const;
protected:
core_ptr core() const { return p_core; };
core_ptr p_core;
};
inline BoolePolyRing::ostream_type&
operator<<(BoolePolyRing::ostream_type& os, const BoolePolyRing& ring) {
return ring.print(os);
}
END_NAMESPACE_PBORI
#endif // of #ifndef polybori_BoolePolyRing_h_