PolyBoRi
CBlockOrderingFacade.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
14 //*****************************************************************************
15 
16 #ifndef polybori_orderings_CBlockOrderingFacade_h_
17 #define polybori_orderings_CBlockOrderingFacade_h_
18 
19 #include "COrderingFacade.h"
20 
22 
27 template <class OrderType, class OrderTag>
29  public COrderingFacade <OrderType, OrderTag> {
30 
31  typedef CBlockOrderingFacade self;
33 
34 public:
35 
37  typedef self base;
38 
40 
42  typedef typename base_type::poly_type poly_type;
44  typedef typename base_type::exp_type exp_type;
45  typedef typename base_type::deg_type deg_type;
46  typedef typename base_type::set_type set_type;
47  typedef typename base_type::comp_type comp_type;
49 
51  CBlockOrderingFacade(): base_type(), m_indices() {
52  m_indices.push_back(0);
53  m_indices.push_back(CTypes::max_index());
54  };
55 
57  CBlockOrderingFacade(const self& rhs): base_type(rhs), m_indices(rhs.m_indices) {};
58 
60  ~CBlockOrderingFacade() = 0;
61 
63 
64  COrderingBase::block_iterator blockBegin() const { return m_indices.begin() + 1; }
65  COrderingBase::block_iterator blockEnd() const { return m_indices.end(); }
66 
68 
69  // by checked_idx_type idx should always be <= max(int) (== blockEnd() - 1)
70  PBORI_ASSERT(idx <= *(blockEnd() - 1));
71 
72  if PBORI_UNLIKELY((idx >= CTypes::max_index()) || (idx <= *(blockEnd() - 2)))
73  throw std::runtime_error("Blocks must be positive and have to be "
74  "added in a strictly increasing order.");
75 
76  m_indices.back() = idx;
77  m_indices.push_back(CTypes::max_index());
78  }
79 
80  void clearBlocks() {
81  m_indices.clear();
82  m_indices.push_back(0);
83  m_indices.push_back(CTypes::max_index());
84  }
86 
88  monom_type lead(const poly_type& poly) const {
89 
90  CBlockDegreeCache<set_type> blockDegCache(poly.ring());
91  CacheManager<order_lead_tag> cache_mgr(poly.ring());
92  typename base_type::descending_property descending;
93 
94  return base_type::monom( dd_block_degree_lead(cache_mgr, blockDegCache,
95  poly.navigation(), m_indices.begin(),
96  set_type(poly.ring()), descending) );
97  }
98 
101  monom_type lead(const poly_type& poly, deg_type) const {
102  return lead(poly);
103  }
104 
106  exp_type leadExp(const poly_type& poly) const {
107  return lead(poly).exp();
108  }
109 
112  exp_type leadExp(const poly_type& poly, deg_type) const {
113  return leadExp(poly);
114  }
115 
116 protected:
117 
119  template <class TermType, class BinOpType>
120  comp_type compare_terms(const TermType& lhs, const TermType& rhs,
121  const BinOpType& idx_comparer) const {
122 
123  return block_dlex_compare(lhs.begin(), lhs.end(),rhs.begin(), rhs.end(),
124  blockBegin(), blockEnd(), idx_comparer);
125  }
126 
129 };
130 
131 template <class OrderType, class OrderTag>
133 
135 
136 #endif
This class shows, whether a property of an order is invalid.
Definition: tags.h:27
COrderingBase::block_idx_type m_indices
index data
Definition: CBlockOrderingFacade.h:128
CTypes::comp_type block_dlex_compare(LhsIterator lhsStart, LhsIterator lhsFinish, RhsIterator rhsStart, RhsIterator rhsFinish, Iterator start, Iterator finish, BinaryPredicate idx_comp)
Definition: pbori_routines_order.h:414
base_type::poly_type poly_type
Definition: CBlockOrderingFacade.h:42
base_type::exp_type exp_type
Definition: CBlockOrderingFacade.h:44
This class is just a wrapper for using variables for storing indices as interim data structure for Bo...
Definition: BooleExponent.h:34
navigator navigation() const
Navigate through structure.
Definition: BoolePolynomial.h:441
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
This class initialize the interface for orderings of CDynamicOrderBase for a given OrderType...
Definition: COrderingFacade.h:43
Definition: CacheManager.h:31
int deg_type
Type for polynomial degrees (ranges from -1 to maxint)
Definition: pbori_defs.h:222
const ring_type & ring() const
Access ring, where this belongs to.
Definition: BoolePolynomial.h:478
self base
*this is to be used as base for OrderType only
Definition: CBlockOrderingFacade.h:37
This class implements block orderings for COrderingFacade. OrderType must inherit from COrderingFacad...
Definition: CBlockOrderingFacade.h:28
short int comp_type
Type for comparisons.
Definition: pbori_defs.h:237
base_type::order_lead_tag order_lead_tag
Definition: CBlockOrderingFacade.h:41
monom_type lead(const poly_type &poly) const
generic block lead
Definition: CBlockOrderingFacade.h:88
CBlockOrderingFacade(const self &rhs)
Copy Constructor.
Definition: CBlockOrderingFacade.h:57
base_type::deg_type deg_type
Definition: CBlockOrderingFacade.h:45
base_type::monom_type monom_type
Definition: CBlockOrderingFacade.h:43
This class wraps the underlying decicion diagram type and defines the necessary operations.
Definition: BoolePolynomial.h:85
exp_type leadExp(const poly_type &poly) const
Extraction of leading exponent - just using lead.
Definition: CBlockOrderingFacade.h:106
block_idx_type::const_iterator block_iterator
Type for block iterators.
Definition: COrderingBase.h:68
base_type::set_type set_type
Definition: CBlockOrderingFacade.h:46
COrderingBase::block_iterator blockBegin() const
Definition: CBlockOrderingFacade.h:64
monom_type lead(const poly_type &poly, deg_type) const
Definition: CBlockOrderingFacade.h:101
std::vector< idx_type > block_idx_type
Type for block indices.
Definition: COrderingBase.h:65
#define PBORI_ASSERT(arg)
Definition: pbori_defs.h:118
base_type::comp_type comp_type
Definition: CBlockOrderingFacade.h:47
Definition: CDegreeCache.h:258
void appendBlock(COrderingBase::checked_idx_type idx)
Definition: CBlockOrderingFacade.h:67
CBlockOrderingFacade()
Default Constructor.
Definition: CBlockOrderingFacade.h:51
TermType dd_block_degree_lead(const CacheType &cache_mgr, const DegCacheMgr &deg_mgr, NaviType navi, Iterator block_iter, TermType init, SizeType degree, DescendingProperty prop)
Definition: pbori_routines_order.h:325
Definition: BooleSet.h:57
COrderingBase::block_iterator blockEnd() const
Definition: CBlockOrderingFacade.h:65
This class is just a wrapper for using variables from cudd's decicion diagram.
Definition: BooleMonomial.h:50
comp_type compare_terms(const TermType &lhs, const TermType &rhs, const BinOpType &idx_comparer) const
Comparison of monomials/expoinents template.
Definition: CBlockOrderingFacade.h:120
Definition: CCacheManagement.h:41
#define PBORI_UNLIKELY(expression)
Definition: pbori_defs.h:59
void clearBlocks()
Definition: CBlockOrderingFacade.h:80
This class defines CCheckedIdx.
Definition: CCheckedIdx.h:29
exp_type leadExp(const poly_type &poly, deg_type) const
Definition: CBlockOrderingFacade.h:112