Gröbner basis project
Codebase for research into Gröbner basis computation
reduction_support.cpp
1 #ifndef __REDUCTION_SUPPORT_CPP_
2 #define __REDUCTION_SUPPORT_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 "reduction_support.hpp"
22 
33  bool verbose = false;
34  bool very_verbose = false;
35  Monomial & u = g->leading_monomial();
36  while ((not s->is_zero()) and g->leading_monomial() | (s->leading_monomial())) {
37  Monomial t(s->leading_monomial());
38  if (verbose) cout << "top-reducing " << s->leading_coefficient() << ' ' << t << " by " << g->leading_monomial() << endl;
39  if (very_verbose) cout << "top-reducing\n\t" << *s << "\nby\n\t" << *g << endl;
40  t /= g->leading_monomial();
43  a /= b;
44  // s = s - atg
45  //if (verbose) cout << comm_id << " entering pre-reduction tasks\n";
46  if (s->strategy() != nullptr)
47  s->strategy()->pre_reduction_tasks(t, *g);
48  //if (verbose) cout << comm_id << " finished pre-reduction tasks\n";
49  s->add_polynomial_multiple(a, t, *g, true);
50  }
51 }
52 
53 #endif
The general class of a polynomial.
Definition: polynomial.hpp:101
virtual bool is_zero() const =0
is this polynomial zero?
virtual Monomial & leading_monomial() const =0
leading monomial – call after sort_by_order()!
virtual Prime_Field_Element leading_coefficient() const =0
leading coefficient – call after sort_by_order()!
Polynomials that need arithmetic typically descend from this class.
Definition: polynomial.hpp:305
Implementation of monomials.
Definition: monomial.hpp:69
Element of a field of prime characteristic.
Definition: fields.hpp:137
void top_reduce(Mutable_Polynomial *s, Abstract_Polynomial *g, int comm_id)
reduce the polynomial **sp by *g
virtual void add_polynomial_multiple(const Prime_Field_Element &, const Monomial &, const Abstract_Polynomial &, bool subtract=false)=0
add monomial multiple of other
virtual Poly_Strategy_Data * strategy() const
strategy related information
Definition: polynomial.hpp:144