PolyBoRi
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
libpolybori
include
polybori
orderings
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
22
#include <
polybori/BoolePolynomial.h
>
23
#include <
polybori/BooleMonomial.h
>
24
#include <
polybori/BooleExponent.h
>
25
26
#include "
COrderingBase.h
"
27
#include "
COrderingTags.h
"
28
#include <
polybori/iterators/COrderedIter.h
>
29
// include ordering tags
30
#include <
polybori/common/tags.h
>
31
#include "
order_traits.h
"
32
// include polybori functionals
33
#include <
polybori/routines/pbori_func.h
>
34
35
BEGIN_NAMESPACE_PBORI
36
42
template
<
class
OrderType,
class
OrderTag>
43
class
COrderingFacade
:
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
61
typedef
CCacheTypes::lead_tag<OrderTag>
order_lead_tag
;
62
typedef
COrderingTags<OrderTag>
ordering_tags
;
64
COrderingFacade
():
65
base_type
() { }
66
68
COrderingFacade
(
const
self
& rhs):
69
base_type
(rhs) { }
70
72
~COrderingFacade
() { }
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
85
bool_type
isLexicographical
()
const
{
86
return
is_valid<typename ordering_tags::lex_property>::result
;
87
}
88
90
bool_type
orderedStandardIteration
()
const
{
91
return
is_valid<typename ordering_tags::ordered_property>::result
;
92
}
93
95
bool_type
isSymmetric
()
const
{
96
return
is_valid<typename ordering_tags::symmetry_property>::result
;
97
}
98
100
bool_type
isDegreeOrder
()
const
{
101
return
is_valid<typename ordering_tags::degorder_property>::result
;
102
}
103
105
bool_type
isBlockOrder
()
const
{
106
return
is_valid<typename ordering_tags::blockorder_property>::result
;
107
}
108
110
bool_type
isTotalDegreeOrder
()
const
{
111
return
is_valid<typename ordering_tags::totaldegorder_property>::result
;
112
}
113
115
bool_type
isDegreeReverseLexicographical
()
const
{
116
return
is_valid<typename ordering_tags::degrevlexorder_property>::result
;
117
}
118
120
bool_type
ascendingVariables
()
const
{
121
return
is_valid<typename ordering_tags::ascending_property>::result
;
122
}
123
125
bool_type
descendingVariables
()
const
{
126
return
is_valid<typename ordering_tags::descending_property>::result
;
127
}
128
130
ordercode_type
getOrderCode
()
const
{
131
return
order_traits<OrderTag>::order_code
;
132
}
133
135
ordercode_type
getBaseOrderCode
()
const
{
136
return
order_traits<OrderTag>::baseorder_code
;
137
}
138
141
bool_type
lieInSameBlock
(
idx_type
first,
idx_type
second)
const
{
142
return
inSameBlockInternal(first, second,
143
typename
ordering_tags::blockorder_property
());
144
}
145
146
148
idx_type
lastBlockStart
()
const
{
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
{
167
return
CGenericOrderedIter<order_type, navigator, monom_type>
(
navigator
(), poly.
ring
());
168
}
169
170
// Initialize iterator corresponding to leading term
171
ordered_exp_iterator
172
leadExpIteratorBegin
(
const
poly_type
& poly)
const
{
173
return
CGenericOrderedIter<order_type, navigator, exp_type>
(poly.
navigation
(), poly.
ring
());
174
}
175
176
ordered_exp_iterator
177
leadExpIteratorEnd
(
const
poly_type
& poly)
const
{
178
return
CGenericOrderedIter<order_type, navigator, exp_type>
(
navigator
(), poly.
ring
());
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
208
END_NAMESPACE_PBORI
209
210
#endif
Generated by
1.8.3.1