-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonomial_ordering.hpp
189 lines (178 loc) · 6.7 KB
/
monomial_ordering.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#ifndef __MONOMIAL_ORDERING_HPP_
#define __MONOMIAL_ORDERING_HPP_
/*****************************************************************************\
* This file is part of DynGB. *
* *
* DynGB is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* DynGB is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with DynGB. If not, see <http://www.gnu.org/licenses/>. *
\*****************************************************************************/
#include <cstdlib>
#include "system_constants.hpp"
class Monomial;
/**
@defgroup orderinggroup Monomial Orderings
@brief classes defining monomial orderings
*/
/**
@ingroup orderinggroup
@class Monomial_Order_Data
@author John Perry
@date 2015
@brief data for a monomial ordering: optional, but stored in @c Monomial
*/
class Monomial_Order_Data {
public:
/** @name Construction */
///@{
/** @brief default clone returns @c nullptr */
virtual Monomial_Order_Data * clone() { return nullptr; }
///@}
/** @name Basic data */
///@{
/** @brief default value is useless; orderings that supply gradings should redefine */
virtual DEG_TYPE grading(NVAR_TYPE) const { return 0; }
///@}
/** @name Destruction */
///@{
/** @brief does nothing but guarantee polymorphism (stupid, stupid C++) */
virtual ~Monomial_Order_Data() {}
///@}
};
/**
@ingroup orderinggroup
@class Monomial_Ordering
@author John Perry
@date 2015
@brief interface to a monomial ordering
@warning Avoid changing the monomial ordering data in the comparison functions,
as the user may wish to compare
two monomials according to a different ordering than the current value.
This is the reason those functions are marked to leave the Monomials constant.
The expected behavior is that first_larger() does whatever the ordering
wants, so if you need monomial data check first to decide whether it exists,
and applies to this ordering!
Use set_data() if you want to change the monomials first.
@warning There is no strict need to check whether the monomials
are associated to the same ordering, but if the ordering uses
Monomial_Order_Data one would be foolhardy not to check first.
*/
class Monomial_Ordering {
public:
/** @name Destruction */
///@{
/** @brief needs virtual destructor for polymorphic @c delete */
virtual ~Monomial_Ordering();
///@}
/** @name Utility */
///@{
/**
@brief sets monomial ordering’s data; default is to do nothing
@details Child classes that override this function are strongly recommended
to use set_ordering_degree() of the Monomial class to set a primary
degree. For weighted/graded degree orderings, this typically improves
performance nontrivially.
*/
virtual void set_data(Monomial &) const;
///@}
/** @name Comparison */
///{@
/**
@param t a Monomial to compare to @f$ u @f$
@param u a Monomial to compare to @f$ t @f$
@return 0 if the Monomials are like; negative if smaller, positive
if larger -- for efficiency, you probably want to redefine this
*/
virtual int cmp(const Monomial & t, const Monomial & u) const = 0;/*{
int result = 0;
if (first_larger(t, u)) result = 1;
else if (first_larger(u, t)) result = -1;
else result = 0;
return result;
}*/
/**
@return @c true iff the first Monomial is larger than the second
*/
virtual bool first_larger(const Monomial &, const Monomial &) const = 0;
/**
@return @c true iff the first Monomial is larger or equal to the second
@see first_larger()
@warning Do not override unless you know what you’re doing
*/
bool first_larger_or_equal(const Monomial &, const Monomial &) const;
/**
@return @c true iff the first Monomial is smaller than the second
@warning Do not override unless you know what you’re doing
*/
virtual bool first_smaller(const Monomial &, const Monomial &) const = 0;
/**
@return @c true iff the first Monomial is smaller or equal
to the second
@see first_larger()
@warning Do not override unless you know what you’re doing
*/
bool first_smaller_or_equal(const Monomial &, const Monomial &) const;
/**
@brief returns @c true iff the first Monomial is larger than the specified
multiple of the second
*/
virtual bool first_larger_than_multiple(
const Monomial &, const Monomial &, const Monomial &
) const = 0;
/**
@return @c true iff the first Monomial is larger or equal to
the specified multiple of the second
@see first_larger()
@warning Do not override unless you know what you’re doing
*/
bool first_larger_or_equal_than_multiple(
const Monomial &, const Monomial &, const Monomial &
) const;
/**
@return @c true iff the first Monomial is smaller than the specified
multiple of the second
@warning Do not override unless you know what you’re doing
*/
bool first_smaller_than_multiple(
const Monomial &, const Monomial &, const Monomial &
) const;
/**
@return @c true iff the first Monomial is smaller or equal to
the specified multiple of the second
@see first_larger()
@warning Do not override unless you know what you’re doing
*/
bool first_smaller_or_equal_than_multiple(
const Monomial &, const Monomial &, const Monomial &
) const;
///@}
};
/**
@ingroup orderinggroup
@class Weighted_Ordering
@author John Perry
@date 2016
@brief interface to a weighted monomial ordering
@see Monomial_Ordering
@details This class adds all of one method to Monomial_Ordering.
*/
class Weighted_Ordering : public Monomial_Ordering {
public:
/** @name Basic properties */
///@{
/** @brief returns the weights used by this orderings */
virtual const WT_TYPE * order_weights() const = 0;
/** @brief returns the number of weights (same as number of indeterminates) */
virtual NVAR_TYPE number_of_weights() const = 0;
///@}
};
#endif