Gröbner basis project
Codebase for research into Gröbner basis computation
particular_orderings.cpp
1 #ifndef __PARTICULAR_ORDERINGS_CPP_
2 #define __PARTICULAR_ORDERINGS_CPP_
3 
4 /*****************************************************************************\
5 * This file is part of DynGB. *
6 * *
7 * DynGB is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * Foobar is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with DynGB. If not, see <http://www.gnu.org/licenses/>. *
19 \*****************************************************************************/
20 
21 #include <cstring>
22 
23 #include "system_constants.hpp"
24 
25 #include "goda.hpp"
26 #include "particular_orderings.hpp"
27 
35 
43 
44 void * WGrevlex_Order_Data::operator new(size_t size) {
45  if (woda == nullptr) woda = new Grading_Order_Data_Allocator<WGrevlex_Order_Data>(size);
46  WGrevlex_Order_Data * result = woda->get_new_block();
47  return result;
48 }
49 
50 void WGrevlex_Order_Data::operator delete(void *t) {
51  woda->return_used_block(static_cast<WGrevlex_Order_Data *>(t));
52 }
53 
55  t.set_ordering_data(nullptr);
56  NVAR_TYPE n = t.num_vars();
57  const EXP_TYPE * a = t.log();
58  DEG_TYPE d = 0;
59  NVAR_TYPE k;
60  // small speedup by going in twos
61  for (k = 0; k < n; ++k) {
62  d += a[k];
63  }
65 }
66 
68  const Monomial & t, const Monomial & u
69 ) const {
70  DEG_TYPE dtk = t.ordering_degree();
71  DEG_TYPE duk = u.ordering_degree();
72  bool searching = dtk == duk;
73  if (searching) {
74  NVAR_TYPE n = t.num_vars();
75  const EXP_TYPE * a = t.log();
76  const EXP_TYPE * b = u.log();
77  NVAR_TYPE k = 0;
78  for (/* */; searching and k < n; ++k) {
79  dtk -= a[n - k - 1];
80  duk -= b[n - k - 1];
81  searching = dtk == duk;
82  }
83  }
84  return dtk > duk;
85 }
86 
88  const Monomial & t, const Monomial & u
89 ) const {
90  DEG_TYPE dtk = t.ordering_degree();
91  DEG_TYPE duk = u.ordering_degree();
92  bool searching = dtk == duk;
93  if (searching) {
94  NVAR_TYPE n = t.num_vars();
95  const EXP_TYPE * a = t.log();
96  const EXP_TYPE * b = u.log();
97  NVAR_TYPE k = 0;
98  for (/* */; searching and k < n; ++k) {
99  dtk -= a[n - k - 1];
100  duk -= b[n - k - 1];
101  searching = dtk == duk;
102  }
103  }
104  return dtk < duk;
105 }
106 
108  const Monomial & t, const Monomial & u, const Monomial & v
109 ) const {
110  DEG_TYPE dtk = t.ordering_degree();
111  DEG_TYPE duk = u.ordering_degree();
112  DEG_TYPE dvk = v.ordering_degree();
113  bool searching = dtk == duk + dvk;
114  if (searching) {
115  NVAR_TYPE n = t.num_vars();
116  const EXP_TYPE * a = t.log();
117  const EXP_TYPE * b = u.log();
118  const EXP_TYPE * c = v.log();
119  NVAR_TYPE k = 0;
120  for (/* */; searching and k < n; ++k) {
121  dtk -= a[n - k - 1];
122  duk -= b[n - k - 1];
123  dvk -= c[n - k - 1];
124  searching = dtk == duk + dvk;
125  }
126  }
127  return dtk > duk + dvk;
128 }
129 
130 Generic_Grevlex generic_grevlex;
131 Monomial_Ordering * generic_grevlex_ptr = &generic_grevlex;
132 
133 WGrevlex::WGrevlex(NVAR_TYPE num_vars, WT_TYPE * wts, bool thorough) :
134  n(num_vars), weights(wts), thorough_weighting(thorough)
135 {}
136 
137 void WGrevlex::set_data(Monomial & t) const {
138  t.set_ordering_data(nullptr);
139  const EXP_TYPE * a = t.log();
140  DEG_TYPE d = 0;
141  NVAR_TYPE k;
142  // small speedup by setting two at a time
143  for (k = 0; k + 1 < n; k += 2) {
144  d += a[k] * weights[k];
145  d += a[k + 1] * weights[k + 1];
146  }
147  // using n % 2 seems smarter than k < n
148  if (n % 2) d += a[k] * weights[k];
149  t.set_ordering_degree(d);
150 }
151 
153  const Monomial & t, const Monomial & u
154 ) const {
155  DEG_TYPE dtk = t.ordering_degree();
156  DEG_TYPE duk = u.ordering_degree();
157  bool searching = dtk == duk;
158  if (searching) {
159  NVAR_TYPE n = t.num_vars();
160  const EXP_TYPE * a = t.log();
161  const EXP_TYPE * b = u.log();
162  NVAR_TYPE k = 0;
163  for (/* */; searching and k < n; ++k) {
164  dtk -= a[n - k - 1] * weights[n - k - 1];
165  duk -= b[n - k - 1] * weights[n - k - 1];
166  searching = dtk == duk;
167  }
168  }
169  return dtk > duk;
170 }
171 
173  const Monomial & t, const Monomial & u
174 ) const {
175  DEG_TYPE dtk = t.ordering_degree();
176  DEG_TYPE duk = u.ordering_degree();
177  bool searching = dtk == duk;
178  if (searching) {
179  NVAR_TYPE n = t.num_vars();
180  const EXP_TYPE * a = t.log();
181  const EXP_TYPE * b = u.log();
182  NVAR_TYPE k = 0;
183  for (/* */; searching and k < n; ++k) {
184  dtk -= a[n - k - 1] * weights[n - k - 1];
185  duk -= b[n - k - 1] * weights[n - k - 1];
186  searching = dtk == duk;
187  }
188  }
189  return dtk < duk;
190 }
191 
193  const Monomial & t, const Monomial & u, const Monomial & v
194 ) const {
195  DEG_TYPE dtk = t.ordering_degree();
196  DEG_TYPE duk = u.ordering_degree();
197  DEG_TYPE dvk = v.ordering_degree();
198  bool searching = dtk == duk + dvk;
199  if (searching) {
200  NVAR_TYPE n = t.num_vars();
201  const EXP_TYPE * a = t.log();
202  const EXP_TYPE * b = u.log();
203  const EXP_TYPE * c = v.log();
204  NVAR_TYPE k = 0;
205  for (/* */; searching and k < n; ++k) {
206  dtk -= a[n - k - 1] * weights[n - k - 1];
207  duk -= b[n - k - 1] * weights[n - k - 1];
208  dvk -= c[n - k - 1] * weights[n - k - 1];
209  searching = dtk == duk + dvk;
210  }
211  }
212  return dtk > duk + dvk;
213 }
214 
216  DEG_TYPE value = 0;
217  for (NVAR_TYPE l = 0; l < number_of_gradings; ++l) {
218  value += t.degree(l);
219  gradings[number_of_gradings-l-1] = value;
220  }
221 }
222 
224  : number_of_gradings(t.num_vars())
225 {
226  const NVAR_TYPE n = number_of_gradings;
227  if (goda == nullptr) goda = new Grading_Order_Data_Allocator<WT_TYPE>(n);
228  gradings = goda->get_new_block();
229  assign_gradings(t);
230 }
231 
234 {
235  gradings = goda->get_new_block();
236  memcpy(gradings, other.gradings, number_of_gradings*sizeof(DEG_TYPE));
237 }
238 
240  return new Grevlex_Order_Data(*this);
241 }
242 
244 
245 DEG_TYPE Grevlex_Order_Data::operator [] (NVAR_TYPE i) const {
246  return gradings[i];
247 }
248 
249 Grevlex_Ordering::Grevlex_Ordering(NVAR_TYPE number_of_variables)
250  : n(number_of_variables)
251 {}
252 
253 bool Grevlex_Ordering::first_larger(const Monomial & t, const Monomial & u) const
254 {
255  bool still_tied = true;
256  bool result = false;
257  for (NVAR_TYPE k = 0; still_tied and k < n; ++k) {
258  DEG_TYPE dtk = partial_degree(t, k);
259  DEG_TYPE duk = partial_degree(u, k);
260  if (dtk < duk)
261  still_tied = false;
262  else if (dtk > duk) {
263  result = true;
264  still_tied = false;
265  }
266  }
267  return result;
268 }
269 
270 bool Grevlex_Ordering::first_smaller(const Monomial & t, const Monomial & u) const
271 {
272  bool still_tied = true;
273  bool result = false;
274  for (NVAR_TYPE k = 0; still_tied and k < n; ++k) {
275  DEG_TYPE dtk = partial_degree(t, k);
276  DEG_TYPE duk = partial_degree(u, k);
277  if (dtk > duk)
278  still_tied = false;
279  else if (dtk < duk) {
280  result = true;
281  still_tied = false;
282  }
283  }
284  return result;
285 }
286 
288  const Monomial & t, const Monomial & u, const Monomial & v
289 ) const {
290  bool still_tied = true;
291  bool result = false;
292  for (NVAR_TYPE k = 0; still_tied and k < n; ++k) {
293  DEG_TYPE dtk = partial_degree(t, k);
294  DEG_TYPE duk = partial_degree(u, k);
295  DEG_TYPE dvk = partial_degree(v, k);
296  if (dtk < duk + dvk)
297  still_tied = false;
298  else if (dtk > duk + dvk) {
299  result = true;
300  still_tied = false;
301  }
302  }
303  return result;
304 }
305 
307  const Monomial & t, NVAR_TYPE i
308 ) const {
309  return (*(static_cast<Grevlex_Order_Data *>(t.monomial_ordering_data())))[i];
310 }
311 
313  const Monomial & t, NVAR_TYPE i
314 ) const {
315  DEG_TYPE result = 0;
316  for (NVAR_TYPE k = 0; k < n - i; ++k)
317  result += t.degree(k);
318  return result;
319 }
320 
322  if (t.monomial_ordering_data() == nullptr)
324  else {
325  (static_cast<Grevlex_Order_Data *>(t.monomial_ordering_data()))->assign_gradings(t);
326  }
327 }
328 
329 Lex_Ordering::Lex_Ordering(NVAR_TYPE number_of_variables) : n(number_of_variables)
330 {}
331 
332 bool Lex_Ordering::first_larger(const Monomial & t, const Monomial & u) const {
333  bool still_tied = true;
334  bool result = false;
335  const EXP_TYPE * a = t.log();
336  const EXP_TYPE * b = u.log();
337  for (NVAR_TYPE k = 0; still_tied and k < n; ++k) {
338  if (a[k] < b[k])
339  still_tied = false;
340  else if (a[k] > b[k]) {
341  result = true;
342  still_tied = false;
343  }
344  }
345  return result;
346 }
347 
348 bool Lex_Ordering::first_smaller(const Monomial & t, const Monomial & u) const {
349  bool still_tied = true;
350  bool result = false;
351  const EXP_TYPE * a = t.log();
352  const EXP_TYPE * b = u.log();
353  for (NVAR_TYPE k = 0; still_tied and k < n; ++k) {
354  if (a[k] > b[k])
355  still_tied = false;
356  else if (a[k] < b[k]) {
357  result = true;
358  still_tied = false;
359  }
360  }
361  return result;
362 }
363 
365  const Monomial & t, const Monomial & u, const Monomial & v
366 ) const {
367  bool still_tied = true;
368  bool result = false;
369  const EXP_TYPE * a = t.log();
370  const EXP_TYPE * b = u.log();
371  const EXP_TYPE * c = v.log();
372  for (NVAR_TYPE k = 0; still_tied and k < n; ++k) {
373  if (a[k] < b[k] + c[k])
374  still_tied = false;
375  else if (a[k] > b[k] + c[k]) {
376  result = true;
377  still_tied = false;
378  }
379  }
380  return result;
381 }
382 
384  DEG_TYPE value = 0;
385  const WT_TYPE * w
386  = (
387  static_cast<const CachedWGrevlex_Ordering *>(t.monomial_ordering())
388  )->order_weights();
389  const EXP_TYPE * a = t.log();
390  for (NVAR_TYPE l = 0; l < number_of_gradings; ++l) {
391  value += w[l] * a[l];
392  gradings[number_of_gradings-l-1] = value;
393  }
394  t.set_ordering_degree(gradings[0]);
395 }
396 
398  : number_of_gradings(t.num_vars())
399 {
400  const NVAR_TYPE n = number_of_gradings;
401  if (goda == nullptr) goda = new Grading_Order_Data_Allocator<WT_TYPE>(n);
402  gradings = goda->get_new_block();
403  assign_gradings(t);
404 }
405 
408 {
409  gradings = goda->get_new_block();
410  memcpy(gradings, other.gradings, number_of_gradings*sizeof(DEG_TYPE));
411 }
412 
414  return new WGrevlex_Order_Data(*this);
415 }
416 
418 
419 DEG_TYPE WGrevlex_Order_Data::operator [] (NVAR_TYPE i) const {
420  return gradings[i];
421 }
422 
424  NVAR_TYPE number_of_variables, WT_TYPE * w, bool thorough
425 ) : n(number_of_variables), weights(w), fully_apply(thorough)
426 {}
427 
428 int CachedWGrevlex_Ordering::cmp(const Monomial & t, const Monomial & u) const {
429  int result;
430  long long cmp = t.ordering_degree() - u.ordering_degree();
431  if (cmp < 0) result = -1;
432  else if (cmp > 0) result = 1;
433  for (NVAR_TYPE k = 1; result == 0 and k < n; ++k) {
434  DEG_TYPE dtk = partial_degree(t, k);
435  DEG_TYPE duk = partial_degree(u, k);
436  result = dtk - duk;
437  }
438  return result;
439 }
440 
442 const {
443  bool still_tied = true;
444  bool result = false;
445  if (t.ordering_degree() > u.ordering_degree()) {
446  result = true;
447  still_tied = false;
448  } else if (t.ordering_degree() < u.ordering_degree()) {
449  result = false;
450  still_tied = false;
451  }
452  for (NVAR_TYPE k = 1; still_tied and k < n; ++k) {
453  DEG_TYPE dtk = partial_degree(t, k);
454  DEG_TYPE duk = partial_degree(u, k);
455  if (dtk < duk)
456  still_tied = false;
457  else if (dtk > duk) {
458  result = true;
459  still_tied = false;
460  }
461  }
462  return result;
463 }
464 
466 const {
467  bool still_tied = true;
468  bool result = false;
469  if (t.ordering_degree() < u.ordering_degree()) {
470  result = true;
471  still_tied = false;
472  } else if (t.ordering_degree() > u.ordering_degree()) {
473  result = false;
474  still_tied = false;
475  }
476  for (NVAR_TYPE k = 1; still_tied and k < n; ++k) {
477  DEG_TYPE dtk = partial_degree(t, k);
478  DEG_TYPE duk = partial_degree(u, k);
479  if (dtk > duk)
480  still_tied = false;
481  else if (dtk < duk) {
482  result = true;
483  still_tied = false;
484  }
485  }
486  return result;
487 }
488 
489 const WT_TYPE * CachedWGrevlex_Ordering::order_weights() const {
490  return weights;
491 }
492 
494  const Monomial & t, const Monomial & u, const Monomial & v
495 ) const {
496  bool still_tied = true;
497  bool result = false;
498  if (t.ordering_degree() > u.ordering_degree() + v.ordering_degree()) {
499  result = true;
500  still_tied = false;
501  } else if (t.ordering_degree() < u.ordering_degree() + v.ordering_degree()) {
502  result = false;
503  still_tied = false;
504  }
505  for (NVAR_TYPE k = 1; still_tied and k < n; ++k) {
506  DEG_TYPE dtk = partial_degree(t, k);
507  DEG_TYPE duk = partial_degree(u, k);
508  DEG_TYPE dvk = partial_degree(v, k);
509  if (dtk < duk + dvk)
510  still_tied = false;
511  else if (dtk > duk + dvk) {
512  result = true;
513  still_tied = false;
514  }
515  }
516  return result;
517 }
518 
520  const Monomial & t, NVAR_TYPE i
521 ) const {
522  DEG_TYPE result = 0;
523  const EXP_TYPE * a = t.log();
524  for (NVAR_TYPE k = 0; k < n - i; ++k)
525  if (fully_apply)
526  result += weights[k]*a[k];
527  else
528  result += a[k];
529  return result;
530 }
531 
533  if (t.monomial_ordering_data() == nullptr) {
534  WGrevlex_Order_Data * new_data = new WGrevlex_Order_Data(t);
535  t.set_ordering_data(new_data);
536  }
537  else
538  (static_cast<WGrevlex_Order_Data *>(t.monomial_ordering_data()))
539  ->assign_gradings(t);
540 }
541 
542 const char * Nonsingular_Matrix_Ordering_Exception::what() const throw() {
543  return "Nonsingular matrix supplied for matrix ordering";
544 }
545 
558 bool nonsingular(NVAR_TYPE m, NVAR_TYPE n, const WT_TYPE **A) {
559  bool possibly = true;
560  // first copy A
561  long long ** M = new long long * [m];
562  for (NVAR_TYPE i = 0; i < m; ++i) {
563  M[i] = new long long [n];
564  for (NVAR_TYPE j = 0; j < n; ++j)
565  M[i][j] = A[i][j];
566  }
567  std::cout << m << ',' << n << std::endl;
568  for (NVAR_TYPE i = 0; i < m; ++i) {
569  for (NVAR_TYPE j = 0; j < n; ++j)
570  std::cout << M[i][j] << ' ';
571  std::cout << std::endl;
572  }
573  std::cout << std::endl;
574  for (NVAR_TYPE i = 0; possibly and i < m; ++i) {
575  // first find a nonzero element in this column
576  bool searching = true;
577  NVAR_TYPE j = i;
578  for (/* */; searching and j < m; ++j)
579  if (M[j][i] != 0) {
580  searching = false;
581  --j;
582  }
583  possibly = not searching;
584  if (possibly and j < m) {
585  // check if we need to swap rows
586  if (j != i) {
587  for (NVAR_TYPE k = i; k < n; ++k) {
588  long long temp = M[j][k];
589  M[j][k] = M[i][k];
590  M[i][k] = temp;
591  }
592  }
593  // clear out the rest of the column
594  for (j = i + 1; j < m; ++j) {
595  WT_TYPE header = M[j][i];
596  if (header != 0) {
597  // delete header & adjust row
598  for (NVAR_TYPE k = i; k < n; ++k)
599  M[j][k] = M[j][k] * M[i][i] - M[i][k] * header;
600  }
601  }
602  }
603  }
604  std::cout << m << ',' << n << std::endl;
605  for (NVAR_TYPE i = 0; i < m; ++i) {
606  for (NVAR_TYPE j = 0; j < n; ++j)
607  std::cout << M[i][j] << ' ';
608  std::cout << std::endl;
609  }
610  std::cout << std::endl;
611  // free memory
612  for (NVAR_TYPE i = 0; i < m; ++i)
613  delete [] M[i];
614  delete [] M;
615  // should be no need to check main diagonal explicitly;
616  // obtaining zero in a main diagonal should mean possibly is now false
617  return possibly;
618 }
619 
621  NVAR_TYPE rows, NVAR_TYPE cols, const WT_TYPE **data
622 ) : m(rows), n(cols), W(data) {
623  if (not nonsingular(m, n, W))
625 }
626 
627 bool Matrix_Ordering::first_larger(const Monomial & t, const Monomial & u) const
628 {
629  bool result = false;
630  bool searching = true;
631  const EXP_TYPE * a = t.log();
632  const EXP_TYPE * b = u.log();
633  for (NVAR_TYPE i = 0; searching and i < m; ++i) {
634  DEG_TYPE wt = 0;
635  DEG_TYPE wu = 0;
636  for (NVAR_TYPE j = 0; j < n; ++j) {
637  wt += W[i][j] * a[j];
638  wu += W[i][j] * b[j];
639  }
640  if (wt < wu)
641  searching = false;
642  else if (wt > wu) {
643  searching = false;
644  result = true;
645  }
646  }
647  return result;
648 }
649 
650 bool Matrix_Ordering::first_smaller(const Monomial & t, const Monomial & u) const
651 {
652  bool result = false;
653  bool searching = true;
654  const EXP_TYPE * a = t.log();
655  const EXP_TYPE * b = u.log();
656  for (NVAR_TYPE i = 0; searching and i < m; ++i) {
657  DEG_TYPE wt = 0;
658  DEG_TYPE wu = 0;
659  for (NVAR_TYPE j = 0; j < n; ++j) {
660  wt += W[i][j] * a[j];
661  wu += W[i][j] * b[j];
662  }
663  if (wt > wu)
664  searching = false;
665  else if (wt < wu) {
666  searching = false;
667  result = true;
668  }
669  }
670  return result;
671 }
672 
674  const Monomial & t, const Monomial & u, const Monomial & v
675 ) const {
676  bool result = false;
677  bool searching = true;
678  const EXP_TYPE * a = t.log();
679  const EXP_TYPE * b = u.log();
680  const EXP_TYPE * c = v.log();
681  for (NVAR_TYPE i = 0; searching and i < m; ++i) {
682  DEG_TYPE wt = 0;
683  DEG_TYPE wu = 0;
684  DEG_TYPE wv = 0;
685  for (NVAR_TYPE j = 0; j < n; ++j) {
686  wt += W[i][j] * a[j];
687  wu += W[i][j] * b[j];
688  wv += W[i][j] * c[j];
689  }
690  if (wt < wu + wv)
691  searching = false;
692  else if (wt > wu + wv) {
693  searching = false;
694  result = true;
695  }
696  }
697  return result;
698 }
699 
700 #endif
virtual const WT_TYPE * order_weights() const override
the weights that define this ordering
void set_ordering_data(Monomial_Order_Data *mordat)
sets the Monomial_Order_Data associated with this Monomial
Definition: monomial.cpp:218
virtual bool first_larger_than_multiple(const Monomial &t, const Monomial &u, const Monomial &v) const override
returns true iff by weighted sums of successively fewer exponents
special memory pool allocator for Grevlex_Order_Data and WGrevlex_Order_Data
Definition: goda.hpp:67
virtual bool first_smaller(const Monomial &t, const Monomial &u) const override
void assign_gradings(const Monomial &)
assigns gradings to a pre-allocated array
virtual void set_data(Monomial &t) const override
sets the Monomial’s monomial_ordering_data
virtual bool first_larger(const Monomial &t, const Monomial &u) const override
returns true iff by sums of successively fewer exponents
data for the grevlex monomial ordering
~WGrevlex_Order_Data()
deletes the array of partial weights
const NVAR_TYPE n
the number of variables, which should remain constant
virtual void set_data(Monomial &t) const override
sets the Monomial’s monomial_ordering_data
const NVAR_TYPE number_of_gradings
length of gradings
virtual bool first_smaller(const Monomial &t, const Monomial &u) const override
returns true iff by weighted sums of successively fewer exponents
virtual bool first_larger_than_multiple(const Monomial &t, const Monomial &u, const Monomial &v) const override
returns true iff by sums of successively fewer exponents
~Grevlex_Order_Data()
deletes the array creates by the constructor
virtual bool first_larger_than_multiple(const Monomial &t, const Monomial &u, const Monomial &v) const override
DEG_TYPE operator[](NVAR_TYPE i) const
returns the sum of the first variables’ exponents
WT_TYPE * weights
the weights for this ordering
DEG_TYPE ordering_degree() const
returns the ordering degree for this Monomial
Definition: monomial.hpp:177
DEG_TYPE partial_degree(const Monomial &t, NVAR_TYPE i) const
virtual bool first_larger_than_multiple(const Monomial &, const Monomial &, const Monomial &) const override
returns true iff the first Monomial is larger than the product of the second and the third ...
TYPE * get_new_block()
allocates and returns a block of memory
Definition: goda.hpp:108
const WT_TYPE ** W
the matrix that defines this ordering
virtual bool first_larger(const Monomial &, const Monomial &) const override
returns true iff the first Monomial is larger than the second
CachedWGrevlex_Ordering(NVAR_TYPE number_of_variables, WT_TYPE *w, bool thorough=true)
creates a weighted grevlex ordering specific to variables, using the weights specified by ...
virtual bool first_smaller(const Monomial &, const Monomial &) const override
returns true iff the first Monomial is smaller than the second
Lex_Ordering(NVAR_TYPE number_of_variables)
creates a lex ordering specific to variables
Grading_Order_Data_Allocator< WGrevlex_Order_Data > * woda
Memory manager for graded orderings (not their data; see goda for that).
Matrix_Ordering(NVAR_TYPE rows, NVAR_TYPE cols, const WT_TYPE **data)
checks that data defines a nonsingular matrix, and sets things up
DEG_TYPE partial_degree(const Monomial &t, NVAR_TYPE i) const
virtual bool first_larger(const Monomial &t, const Monomial &u) const override
returns true iff by sums of successively fewer exponents
const NVAR_TYPE n
the number of columns
const NVAR_TYPE m
the number of rows
WGrevlex(NVAR_TYPE, WT_TYPE *, bool=true)
Creates a grevlex ordering specific to the specified number of variables, with the given weights...
virtual bool first_smaller(const Monomial &t, const Monomial &u) const override
const WT_TYPE * weights
the weights that define this ordering
NVAR_TYPE num_vars() const
number of variables
Definition: monomial.hpp:130
WGrevlex_Order_Data(Monomial &t)
creates an array of partial weights of t
Grevlex_Order_Data(const Monomial &t)
creates an array of partial weights of t
virtual bool first_larger_than_multiple(const Monomial &t, const Monomial &u, const Monomial &v) const override
virtual bool first_larger(const Monomial &t, const Monomial &u) const override
Implementation of monomials.
Definition: monomial.hpp:69
virtual int cmp(const Monomial &, const Monomial &) const override
resturns 0 if they are alike; positive if first larger; negative otherwise
const NVAR_TYPE n
the number of variables, which should remain constant
interface to a monomial ordering
Grading_Order_Data_Allocator< WT_TYPE > * goda
Memory manager for graded ordering data.
virtual void set_data(Monomial &t) const override
sets monomial ordering’s data; default is to do nothing
bool nonsingular(NVAR_TYPE m, NVAR_TYPE n, const WT_TYPE **A)
verifies that a matrix supplied for an ordering is not nonsingular
DEG_TYPE * gradings
list of partial sums of exponents
const NVAR_TYPE n
the number of variables, which should remain constant
DEG_TYPE degree(NVAR_TYPE i) const
Degree of th variable.
Definition: monomial.cpp:183
virtual Grevlex_Order_Data * clone() override
clone “constructor”
const EXP_TYPE * log() const
Direct access to the exponents, for whatever reason.
Definition: monomial.hpp:157
generic grevlex ordering, works with any number of variables
Monomial_Order_Data * monomial_ordering_data() const
the Monomial_Order_Data associated with this Monomial
Definition: monomial.hpp:167
const Monomial_Ordering * monomial_ordering() const
the Monomial_Ordering associated with this Monomial
Definition: monomial.hpp:165
virtual bool first_larger_than_multiple(const Monomial &t, const Monomial &u, const Monomial &v) const override
virtual WGrevlex_Order_Data * clone() override
clone constructor
virtual void set_data(Monomial &t) const override
sets the Monomial’s monomial_ordering_data
void return_used_block(TYPE *freed_block)
returns a block of memory that is no longer needed to the pool
Definition: goda.hpp:121
virtual bool first_smaller(const Monomial &t, const Monomial &u) const override
returns true iff by sums of successively fewer exponents
void assign_gradings(Monomial &t)
assigns gradings to a pre-allocated array
DEG_TYPE compute_ith_weight(const Monomial &t, NVAR_TYPE i) const
computes the sum of the first i exponents
virtual bool first_larger(const Monomial &t, const Monomial &u) const override
data for the weighted grevlex monomial ordering
the weighted grevlex ordering for a specified number of variables, with cached weights for each monom...
const NVAR_TYPE n
the number of variables, which should remain constant
const bool fully_apply
whether to apply the weights to more than the first sum
virtual bool first_larger(const Monomial &t, const Monomial &u) const override
returns true iff by weighted sums of successively fewer exponents
virtual bool first_smaller(const Monomial &t, const Monomial &u) const override
returns true iff by sums of successively fewer exponents
const NVAR_TYPE number_of_gradings
length of gradings
DEG_TYPE * gradings
array of partial weighted sums of exponents
void set_ordering_degree(DEG_TYPE d)
sets the ordering degree for this Monomial
Definition: monomial.hpp:175
Grevlex_Ordering(NVAR_TYPE number_of_variables)
creates a grevlex ordering specific to the specified number of variables
DEG_TYPE compute_ith_weight(const Monomial &t, NVAR_TYPE i) const