Gröbner basis project
Codebase for research into Gröbner basis computation
f4_reduction_old.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 
42 list<Constant_Polynomial *> f4_control(
43  const list<Abstract_Polynomial *> &F,
44  SPolyCreationFlags method,
45  StrategyFlags strategy,
46  WT_TYPE * strategy_weights
47 );
48 
55 class F4_Reduction_Data {
56 public:
61  list<Abstract_Polynomial *> & B
62  );
64  const list<Critical_Pair_Basic *> & P,
65  const list<Abstract_Polynomial *> & B
66  );
80  void add_monomials(
81  list<Monomial *>::iterator * ti,
82  list<Abstract_Polynomial *>::iterator & ri,
83  const Abstract_Polynomial *g,
84  const Monomial * u = nullptr
85  );
90  void initialize(Abstract_Polynomial * p, const Monomial & t);
91  void initialize_many(const list<Critical_Pair_Basic *> & P);
93 
97 
98 
102  bool is_zero();
108 
109 
113 
114 
116  void clear_strategy() { strategy = nullptr; }
118 
119 
121  inline void advance_head() {
122  while (head < len and A[head].is_zero()) ++head;
123  }
129  void reduce();
131 
132  void list_reducers();
135 protected:
137  unsigned head;
139  unsigned len;
145  list<Monomial *> * M_build;
147  list<Abstract_Polynomial *> * R_build;
149  vector<Abstract_Polynomial *> R;
151  const list<Abstract_Polynomial *> & G;
153  const Monomial_Ordering * mord;
155  unsigned nonzero_entries;
161  list<Poly_Strategy_Data *> strategies;
162 };
163 
164 #endif
void advance_head()
advances head; useful after a computation
The general class of a polynomial.
Definition: polynomial.hpp:101
Poly_Strategy_Data * get_strategy()
returns the strategy currently in use
A Constant_Polynomial is a polynomial that should not change.
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
unsigned len
length of the polynomial
list< Poly_Strategy_Data * > strategies
strategy data for each polynomial
polynomial-related strategy data
Definition: strategies.hpp:49
unsigned nonzero_entries
number of nonzero entries of A
vector< Constant_Polynomial * > finalize()
converts this to a Constant_Polynomial and returns the result
list< Monomial * > * M_build
monomials of f
StrategyFlags
flag indicating which strategy to use for computation
Definition: strategies.hpp:34
list< Abstract_Polynomial * > * R_build
indices of reducers for the corresponding elements of M
SPolyCreationFlags
flag indicating which structure to use for an s-polynomial
void reduce()
reduces polynomial
void initialize(Abstract_Polynomial *p, const Monomial &t)
copy temporary to permanent reducers; free list of monomials; insert p&#39;s coefficients, aligned with multiples of t
Implementation of monomials.
Definition: monomial.hpp:69
Element of a field of prime characteristic.
Definition: fields.hpp:137
Monomial ** M
polynomial data
interface to a monomial ordering
Poly_Strategy_Data * strategy
strategy in use
Encapsulates information about a polynomial ring for easy access: ground field, number of indetermina...
list< Constant_Polynomial * > f4_control(const list< Abstract_Polynomial *> &F, SPolyCreationFlags method, StrategyFlags strategy, WT_TYPE *strategy_weights)
equivalent to buchberger(), but for Faugère’s F4 algorithm
void clear_strategy()
clears the strategy; do this if you have saved it elsewhere
const Monomial_Ordering * mord
how the monomials are ordered
Polynomial_Ring * Rx
polynomial ring
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
unsigned head
head of the polynomial (location of leading term)
Implementation of Faugère’s F4 algorithm.
Controls the creation of s-polynomials.
Prime_Field_Element * A
coefficient data
const list< Abstract_Polynomial * > & G
current basis of ideal