PolyBoRi
COrderingFacade.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
14 //*****************************************************************************
15 
16 #ifndef polybori_orderings_COrderingFacade_h_
17 #define polybori_orderings_COrderingFacade_h_
18 
19 // include basic definitions
20 #include <polybori/pbori_defs.h>
21 
23 #include <polybori/BooleMonomial.h>
24 #include <polybori/BooleExponent.h>
25 
26 #include "COrderingBase.h"
27 #include "COrderingTags.h"
29 // include ordering tags
30 #include <polybori/common/tags.h>
31 #include "order_traits.h"
32 // include polybori functionals
34 
36 
42 template <class OrderType, class OrderTag>
44  public COrderingBase,
45  public COrderingTags<OrderTag>, public order_traits<OrderTag> {
46 
48  typedef COrderingFacade self;
49 
51  typedef COrderingBase base_type;
52 
53 public:
55  typedef self base;
56 
58  typedef OrderType order_type;
59 
65  base_type() { }
66 
68  COrderingFacade(const self& rhs):
69  base_type(rhs) { }
70 
73 
74 
76  poly_type leadFirst(const poly_type& poly) const {
77 
78  if(orderedStandardIteration())
79  return poly;
80  else
81  return lead(poly);
82  }
83 
87  }
88 
92  }
93 
97  }
98 
102  }
103 
107  }
108 
112  }
113 
117  }
118 
122  }
123 
127  }
128 
132  }
133 
137  }
138 
141  bool_type lieInSameBlock(idx_type first, idx_type second) const {
142  return inSameBlockInternal(first, second,
144  }
145 
146 
149  if (isBlockOrder()) {
150  return *(blockEnd() - 2);
151  }
152  else if (isLexicographical()) {
153  return CTypes::max_idx;
154  }
155  return 0;
156  }
157 
158  // Initialize iterator corresponding to leading term
159  ordered_iterator
160  leadIteratorBegin(const poly_type& poly) const {
161  return CGenericOrderedIter<order_type, navigator,
162  monom_type>(poly.navigation(), poly.ring());
163  }
164 
165  ordered_iterator
166  leadIteratorEnd(const poly_type& poly) const {
168  }
169 
170  // Initialize iterator corresponding to leading term
171  ordered_exp_iterator
172  leadExpIteratorBegin(const poly_type& poly) const {
174  }
175 
176  ordered_exp_iterator
177  leadExpIteratorEnd(const poly_type& poly) const {
179  }
180 
181 protected:
182 
185  invalid_tag) const { // not a block order
186  return true;
187  }
188 
191  valid_tag) const { // is block order
192  // todo: throw here if first,second >=CTypes::max_idx
193  if(PBORI_UNLIKELY(first > CTypes::max_idx || second > CTypes::max_idx ||
194  first < 0 || second < 0))
195  throw std::runtime_error("Variable index out of range.");
196 
197  if (second < first)
198  std::swap(first, second);
199 
200  block_iterator upper(blockBegin());
201  while (first >= *upper) // Note: convention, last element is max_idx
202  ++upper;
203  return (second < *upper);
204  }
205 
206 };
207 
209 
210 #endif
This class shows, whether a property of an order is invalid.
Definition: tags.h:27
bool_type isTotalDegreeOrder() const
Test whether we deal with a total degree-ordering.
Definition: COrderingFacade.h:110
ordered_exp_iterator leadExpIteratorEnd(const poly_type &poly) const
End marker for exponent iterator corresponding to leading term.
Definition: COrderingFacade.h:177
idx_type lastBlockStart() const
Generic procedure to get index, where last block starts.
Definition: COrderingFacade.h:148
ordered_iterator leadIteratorBegin(const poly_type &poly) const
Initialize iterator corresponding to leading term.
Definition: COrderingFacade.h:160
navigator navigation() const
Navigate through structure.
Definition: BoolePolynomial.h:441
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
bool_type lieInSameBlock(idx_type first, idx_type second) const
Definition: COrderingFacade.h:141
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
OrderType order_type
Variable ordering definiton functional type.
Definition: COrderingFacade.h:58
This class initialize the interface for orderings of CDynamicOrderBase for a given OrderType...
Definition: COrderingFacade.h:43
poly_type leadFirst(const poly_type &poly) const
Generates polynomial with leading term first (other terms may be skipped)
Definition: COrderingFacade.h:76
Definition: order_traits.h:41
CCacheTypes::lead_tag< OrderTag > order_lead_tag
Tag for for leading monomial cache.
Definition: COrderingFacade.h:61
bool_type ascendingVariables() const
Test whether variables are in ascending order.
Definition: COrderingFacade.h:120
const ring_type & ring() const
Access ring, where this belongs to.
Definition: BoolePolynomial.h:478
COrderingTags< OrderTag > ordering_tags
Definition: COrderingFacade.h:62
bool_type isLexicographical() const
Check whether ring is lexicographical.
Definition: COrderingFacade.h:85
self base
*this is to be used as base for OrderType only
Definition: COrderingFacade.h:55
Definition: COrderingBase.h:43
ordercode_type getOrderCode() const
Get numerical code for ordering.
Definition: COrderingFacade.h:130
This class wraps the underlying decicion diagram type and defines the necessary operations.
Definition: BoolePolynomial.h:85
bool_type isDegreeReverseLexicographical() const
Test whether ordering is deg-rev-lex ordering.
Definition: COrderingFacade.h:115
bool_type descendingVariables() const
Test whether variables are in descending order.
Definition: COrderingFacade.h:125
block_idx_type::const_iterator block_iterator
Type for block iterators.
Definition: COrderingBase.h:68
~COrderingFacade()
Destructor.
Definition: COrderingFacade.h:72
bool_type isDegreeOrder() const
Test whether we deal with a degree-ordering.
Definition: COrderingFacade.h:100
COrderingFacade(const self &rhs)
Construct new decision diagramm manager.
Definition: COrderingFacade.h:68
bool_type isBlockOrder() const
Test whether we deal with a degree-ordering.
Definition: COrderingFacade.h:105
bool_type orderedStandardIteration() const
Test whether iterators respect order.
Definition: COrderingFacade.h:90
int idx_type
Type for indices.
Definition: pbori_defs.h:228
This tempalte class is base for classes which define ordering tags and properties.
Definition: COrderingTags.h:69
ordered_exp_iterator leadExpIteratorBegin(const poly_type &poly) const
Initialize exponent iterator corresponding to leading term.
Definition: COrderingFacade.h:172
ordered_iterator leadIteratorEnd(const poly_type &poly) const
End marker for iterator corresponding to leading term.
Definition: COrderingFacade.h:166
bool_type isSymmetric() const
Test whether variable pertubation do not change the order.
Definition: COrderingFacade.h:95
ordercode_type getBaseOrderCode() const
Get numerical code for base ordering (the same for non-block orderings)
Definition: COrderingFacade.h:135
This class defines an iterator for navigating through then and else branches of ZDDs.
Definition: CCuddNavigator.h:36
bool_type inSameBlockInternal(idx_type, idx_type, invalid_tag) const
trivial case for non-block orderings
Definition: COrderingFacade.h:184
This class is just a wrapper for using variables from cudd's decicion diagram.
Definition: BooleMonomial.h:50
bool_type inSameBlockInternal(idx_type first, idx_type second, valid_tag) const
complicated case for block orderings
Definition: COrderingFacade.h:190
bool bool_type
Type for standard true/false statements.
Definition: pbori_defs.h:216
Definition: CCacheManagement.h:41
#define PBORI_UNLIKELY(expression)
Definition: pbori_defs.h:59
Definition: COrderedIter.h:203
This class shows, whether a property of an order is valid.
Definition: tags.h:32
Definition: pbori_func.h:582
int ordercode_type
Type for ordering codes.
Definition: pbori_defs.h:240
COrderingFacade()
Construct new decision diagramm manager.
Definition: COrderingFacade.h:64