1 #ifndef __ALGORITHM_BUCHBERGER_BASIC_CPP_ 2 #define __ALGORITHM_BUCHBERGER_BASIC_CPP_ 21 #include "algorithm_buchberger_basic.hpp" 23 #include "reduction_support.hpp" 29 for (NVAR_TYPE i = 0; result and i < t.
num_vars(); ++i)
35 list<Abstract_Polynomial *>
reduce_basis(list<Abstract_Polynomial *>G) {
36 list <Abstract_Polynomial *> result;
37 set <Abstract_Polynomial *> eliminate;
41 bool eliminated =
false;
44 if (g != f and g->leading_monomial() | f->leading_monomial()) {
53 if (g != f and g->leading_monomial() | f->leading_monomial()) {
70 cout <<
"quick check for correctness\n";
71 for (
auto fi = G.begin(); fi != G.end(); ++fi)
72 for (
auto gi = next(fi); gi != G.end(); ++gi)
76 SPolyCreationFlags::LINKED_LST, strategy
78 reduce_over_basis<list<Constant_Polynomial *>>(&s, G);
88 list<Critical_Pair_Basic *> & P,
89 list<Abstract_Polynomial *> & G,
94 list<Critical_Pair_Basic *> C;
99 list<Critical_Pair_Basic *> D;
100 while (C.size() != 0) {
114 list<Critical_Pair_Basic *> E;
115 while (D.size() != 0) {
127 list<Critical_Pair_Basic *> Q;
128 while (P.size() != 0) {
133 bool crit3 = p->
second() !=
nullptr and
135 if ( crit1 or crit2 or crit3)
156 list<Abstract_Polynomial *> G,
160 cout << G.size() <<
" polys in basis\n";
171 cout <<
"processing pair: " << *p << endl;
173 strategy == StrategyFlags::SUGAR_STRATEGY or
174 strategy == StrategyFlags::WSUGAR_STRATEGY
182 const list<Abstract_Polynomial *> &F,
185 WT_TYPE * strategy_weights
187 unsigned number_of_spolys = 0;
188 list<Abstract_Polynomial *> G;
189 list<Critical_Pair_Basic *> P;
195 case StrategyFlags::NORMAL_STRATEGY:
break;
196 case StrategyFlags::SUGAR_STRATEGY:
199 case StrategyFlags::WSUGAR_STRATEGY:
208 bool verbose =
false;
209 bool very_verbose =
false;
214 report_front_pair(p, strategy);
226 cout <<
"\treduced to zero\n";
236 if (very_verbose) { cout <<
"\tadded "; r->println(); }
240 cout << number_of_spolys <<
" s-polynomials computed and reduced\n";
242 cout << G.size() <<
" polynomials before interreduction\n";
245 cout << G.size() <<
" polynomials after interreduction\n";
247 list<Constant_Polynomial *> B;
248 unsigned long num_mons = 0;
249 unsigned long max_mons = 0;
251 unsigned long glen = g->length();
253 if (glen > max_mons) max_mons = glen;
256 cout <<
"tot # monomials: " << num_mons;
257 cout <<
"max # monomials: " << max_mons;
258 cout <<
"avg # monomials: " << num_mons / B.size() << endl;
The general class of a polynomial.
virtual bool is_zero() const =0
is this polynomial zero?
A Constant_Polynomial is a polynomial that should not change.
void sort_pairs_by_strategy(list< T *> &P)
Applies the strategy to find the “smallest” critical pair.
const Abstract_Polynomial * second() const
second polynomial in pair
void gm_update(list< Critical_Pair_Basic *> &P, list< Abstract_Polynomial *> &G, Abstract_Polynomial *r, StrategyFlags strategy)
Implementation of Gebauer-Moeller algorithm. Based on description in Becker and Weispfenning (1993)...
list< Constant_Polynomial * > buchberger(const list< Abstract_Polynomial *> &F, SPolyCreationFlags method, StrategyFlags strategy, WT_TYPE *strategy_weights)
Implementation of Buchberger’s algorithm.
virtual Monomial & leading_monomial() const =0
leading monomial – call after sort_by_order()!
const Monomial & lcm() const
lcm of leading monomials of polynomials
ordering critical pairs using the sugar strategy
void reduce_over_basis(Mutable_Polynomial **sp, const T &G, int comm_id=0)
Reduce the polynomial r over the basis G.
virtual void at_generation_tasks()
hook called while first generating polynomial
StrategyFlags
flag indicating which strategy to use for computation
list< Abstract_Polynomial * > reduce_basis(list< Abstract_Polynomial *>G)
Remove redundant polynomials from G.
SPolyCreationFlags
flag indicating which structure to use for an s-polynomial
bool lcm_alike(const Monomial &t, const Monomial &u, const Critical_Pair_Basic *p)
Checks if the lcm of t and u is like the lcm stored in p.
NVAR_TYPE num_vars() const
number of variables
Polynomials that need arithmetic typically descend from this class.
const Abstract_Polynomial * first() const
first polynomial in pair
polynomial-related data for a weighted sugar strategy
Implementation of monomials.
void check_correctness(list< Constant_Polynomial *>G, StrategyFlags strategy)
checks that G is a Gröbner basis by verifying each s-polynomial reduces to zero
polynomial-related data for a sugar strategy
virtual Mutable_Polynomial * s_polynomial()
to use only if s-polynomial is already computed by another method
bool is_coprime(const Monomial &other) const
true iff this has no common factor with other.
DEG_TYPE degree(NVAR_TYPE i) const
Degree of th variable.
unsigned lcm_degree(unsigned i) const
degree of ith variable in lcm
void set_strategy(Poly_Strategy_Data *psd)
sets the polynomial’s strategy to psd
const Pair_Strategy_Data * pair_key() const
strategy used for comparison of pairs
bool no_triplet(const T *p, const list< T *>C)
Checks whether p is in danger of forming a Buchberger triple with some pair listed in C...
Controls the creation of s-polynomials.
void report_critical_pairs(const list< T *>P, bool verbose=false)
A brief report on the number of critical pairs. If verbose is true, also lists them.
bool is_generator() const
whether this pair is from a generator
virtual Poly_Strategy_Data * strategy() const
strategy related information