Gröbner basis project
Codebase for research into Gröbner basis computation
f4_reduction.hpp
1 #ifndef __F4_REDUCTION_HPP__
2 #define __F4_REDUCTION_HPP__
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 "system_constants.hpp"
22 
23 #include "fields.hpp"
24 #include "monomial.hpp"
25 #include "monomial_ordering.hpp"
26 #include "polynomial.hpp"
27 #include "critical_pair.hpp"
28 
29 #include <set>
30 #include <list>
31 #include <vector>
32 #include <cstdlib>
33 
34 using std::set;
35 using std::list;
36 using std::vector;
37 
45 list<Constant_Polynomial *> f4_control(const list<Abstract_Polynomial *> &F);
46 
54 public:
56 
65  const list<Critical_Pair_Basic *> & P,
66  const list<Abstract_Polynomial *> & B
67  );
89  void add_monomials(
90  list<Monomial *>::iterator & ti,
91  list<Abstract_Polynomial *>::iterator & ri,
92  const Abstract_Polynomial *g,
93  const Monomial & u,
94  bool new_row = false
95  );
102  void initialize_many(const list<Critical_Pair_Basic *> & P);
104 
105 
112 
113 
117  bool is_zero();
121  vector<Poly_Sugar_Data *> get_strategies() { return strategies; }
123 
124 
126  vector<Constant_Polynomial *> finalize();
128 
129 
131  void clear_strategy(unsigned i) { strategies[i] = nullptr; }
133 
134 
136  inline void advance_head(unsigned i) {
137  while (heads[i] < cols and A[heads[i] + i*cols].is_zero()) ++heads[i];
138  }
140  void reduce_by_old();
142  void reduce_by_new();
144 
145 
147  void list_reducers();
152  void print_matrix(bool show_data=false);
154 protected:
156  void reduce_my_rows(const set<unsigned> &);
158  vector<unsigned> heads;
160  unsigned cols;
162  unsigned rows;
164  vector<Monomial *> M;
168  list<Monomial *> M_build;
170  list<Abstract_Polynomial *> R_build;
172  vector<Abstract_Polynomial *> R;
174  const list<Abstract_Polynomial *> & G;
178  vector<unsigned> nonzero_entries;
182  vector<Poly_Sugar_Data *> strategies;
183 };
184 
185 #endif
The general class of a polynomial.
Definition: polynomial.hpp:101
unsigned rows
number of rows in the polynomial
vector< Monomial * > M
monomials for each column
bool is_zero()
returns true iff all the entries are 0
vector< Abstract_Polynomial * > R
finalized list of indices of reducers for the corresponding monomials of f
list< Monomial * > M_build
monomials while building
void print_matrix(bool show_data=false)
prints the matrix
vector< Poly_Sugar_Data * > strategies
strategy data for each polynomial
void reduce_my_rows(const set< unsigned > &)
reduces the specified set of rows, suitable for multithreading
void advance_head(unsigned i)
advances head; useful after a computation
list< Abstract_Polynomial * > R_build
indices of reducers for the corresponding elements of M
void reduce_by_old()
reduces polynomials
void clear_strategy(unsigned i)
clears the strategy; do this if you have saved it elsewhere
~F4_Reduction_Data()
releases space for the matrix and deletes any strategies not already set to nullptr ...
vector< Constant_Polynomial * > finalize()
converts this to a Constant_Polynomial and returns the result
unsigned cols
number of columns in the polynomial
Implementation of monomials.
Definition: monomial.hpp:69
Element of a field of prime characteristic.
Definition: fields.hpp:137
interface to a monomial ordering
F4_Reduction_Data(const list< Critical_Pair_Basic *> &P, const list< Abstract_Polynomial *> &B)
encapsulation of one step of the F4 algorithm for the polynomials indicated by P and B ...
Encapsulates information about a polynomial ring for easy access: ground field, number of indetermina...
const Monomial_Ordering * mord
how the monomials are ordered
void add_monomials(list< Monomial *>::iterator &ti, list< Abstract_Polynomial *>::iterator &ri, const Abstract_Polynomial *g, const Monomial &u, bool new_row=false)
adds monomials of to M_build
void initialize_many(const list< Critical_Pair_Basic *> &P)
creates the matrix
void list_reducers()
lists the reducers selected for each column, in order
list< Constant_Polynomial * > f4_control(const list< Abstract_Polynomial *> &F)
equivalent to buchberger(), but for Faugère’s F4 algorithm
void reduce_by_new()
reduces polynomials
Implementation of Faugère’s F4 algorithm.
Prime_Field_Element * A
coefficient data
Polynomial_Ring & Rx
polynomial ring
vector< Poly_Sugar_Data * > get_strategies()
returns the strategy currently in use
vector< unsigned > nonzero_entries
number of nonzero entries of each row of A
vector< unsigned > heads
head of the polynomial (location of leading term)
const list< Abstract_Polynomial * > & G
current basis of ideal