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 {
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 
184  bool_type inSameBlockInternal(idx_type, idx_type,
185  invalid_tag) const { // not a block order
186  return true;
187  }
188 
190  bool_type inSameBlockInternal(idx_type first, idx_type second,
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