39 static const char* staticGetName() {
40 return Pred::staticGetName();
47 stable_sort(ideal.
begin(), ideal.
end(), pred);
53 static const char* staticGetName() {
return "random";}
56 random_shuffle(ideal.
begin(), ideal.
end());
62 static const char* staticGetName() {
return "tdeg";}
70 mutable mpz_class _degA;
71 mutable mpz_class _degB;
76 static const char* staticGetName() {
return "median";}
86 static const char* staticGetName() {
return "posMedian";}
97 static const char* staticGetName() {
return "minPos";}
108 static const char* staticGetName() {
return "max";}
118 static const char* staticGetName() {
return "support";}
129 static const char* staticGetName() {
return "strongGenericity";}
132 void orderGenericity(
Ideal& ideal,
bool strong)
const {
142 for (cit a = ideal.
begin(); a != ideal.
end(); ++a) {
143 for (cit b = a + 1; b != ideal.
end(); ++b) {
156 Pred pred(degeneracy);
157 stable_sort(ideal.
begin(), ideal.
end(), pred);
162 typedef map<const Exponent*, size_t> UnGenMap;
165 orderGenericity(ideal,
true);
170 Pred(UnGenMap& degeneracy): _degeneracy(degeneracy) {}
173 return _degeneracy[a] < _degeneracy[b];
177 UnGenMap& _degeneracy;
183 static const char* staticGetName() {
return "null";}
189 class WeakGenericityOrderer :
public StrongGenericityOrderer {
191 static const char* staticGetName() {
return "weakGenericity";}
193 virtual void doOrder(
Ideal& ideal)
const {
194 orderGenericity(ideal,
false);
202 ReverseOrderer(auto_ptr<IdealOrderer> orderer): _orderer(orderer) {}
209 reverse(ideal.
begin(), ideal.
end());
210 _orderer->order(ideal);
211 reverse(ideal.
begin(), ideal.
end());
213 auto_ptr<IdealOrderer> _orderer;
218 CompositeOrderer(): _orderersDeleter(_orderers) {}
220 void refineOrderingWith(auto_ptr<IdealOrderer> orderer) {
225 typedef vector<IdealOrderer*> Container;
226 typedef Container::const_reverse_iterator rev_cit;
232 rev_cit rbegin(_orderers.end());
233 rev_cit rend(_orderers.begin());
234 for (rev_cit it = rbegin; it != rend; ++it)
243 OrdererFactory getOrdererFactory() {
244 OrdererFactory factory(
"ordering of terms");
246 nameFactoryRegister<RandomOrderer>(factory);
247 nameFactoryRegister<NullOrderer>(factory);
248 nameFactoryRegister<IdealSorter<LexComparator> >(factory);
249 nameFactoryRegister<IdealSorter<ReverseLexComparator> >(factory);
250 nameFactoryRegister<IdealSorter<TotalDegreeComparator> >(factory);
251 nameFactoryRegister<IdealSorter<MedianComparator> >(factory);
252 nameFactoryRegister<IdealSorter<MedianPositiveComparator> >(factory);
253 nameFactoryRegister<IdealSorter<MinimumPositiveComparator> >(factory);
254 nameFactoryRegister<IdealSorter<MaximumComparator> >(factory);
255 nameFactoryRegister<IdealSorter<SupportComparator> >(factory);
256 nameFactoryRegister<StrongGenericityOrderer>(factory);
257 nameFactoryRegister<WeakGenericityOrderer>(factory);
262 auto_ptr<IdealOrderer> createNonCompositeOrderer(
const string& prefix) {
263 if (prefix.substr(0, 3) ==
"rev") {
264 auto_ptr<IdealOrderer> orderer =
266 return auto_ptr<IdealOrderer>(
new ReverseOrderer(orderer));
273 if (prefix.find(
'_') == string::npos)
274 return createNonCompositeOrderer(prefix);
276 auto_ptr<CompositeOrderer> composite(
new CompositeOrderer());
279 size_t nextUnderscore = prefix.find(
'_', pos);
280 string subPrefix = prefix.substr(pos, nextUnderscore - pos);
281 composite->refineOrderingWith(createNonCompositeOrderer(subPrefix));
283 if (nextUnderscore == string::npos)
285 pos = nextUnderscore + 1;
287 return auto_ptr<IdealOrderer>(composite.release());
void exceptionSafePushBack(Container &container, auto_ptr< Element > pointer)
auto_ptr< IdealOrderer > createIdealOrderer(const string &prefix)
auto_ptr< AbstractProduct > createWithPrefix(const NameFactory< AbstractProduct > &factory, const string &prefix)
Creates the unique product that has the indicated prefix, or create the actual product that has name ...
virtual void doOrder(Ideal &ideal) const =0
Represents a monomial ideal with int exponents.
Cont::const_iterator const_iterator
bool strictlyContains(const Exponent *term) const
const_iterator end() const
const_iterator begin() const
size_t getVarCount() const
A NameFactory takes a name and then creates an instance of a class that has been previously registere...
size_t getVarCount() const
virtual bool doPredicate(const Exponent *a, const Exponent *b) const =0
Term represents a product of variables which does not include a coefficient.
size_t getSizeOfSupport() const
static bool sharesNonZeroExponent(const Exponent *a, const Exponent *b, size_t varCount)
Returns whether there is some such that .