Gröbner basis project
Codebase for research into Gröbner basis computation
polynomial_array.hpp
1 #ifndef __ARRAY_POLYNOMIALS_H_
2 #define __ARRAY_POLYNOMIALS_H_
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 <cstdlib>
22 #include <iostream>
23 #include <list>
24 using std::list;
25 
26 #include "polynomial.hpp"
27 
29 
38 {
39 public:
41 
47  Constant_Polynomial_Iterator(const Constant_Polynomial *q, bool at_end=false);
49 
53 
54  virtual void restart_iteration() override;
56  virtual void moveRight() override;
57  virtual void moveLeft() override;
58  virtual bool canMoveRight() const override;
59  virtual bool canMoveLeft() const override;
60  virtual bool fellOff() const override;
62 
63  virtual const Monomial & currMonomial() const override;
65  virtual const Prime_Field_Element & currCoeff() const override;
67 protected:
71  long i;
72 };
73 
88 {
89 public:
91 
106  unsigned length,
107  Polynomial_Ring & R,
108  const Monomial *mons,
109  const Prime_Field_Element *coeffs,
110  const Monomial_Ordering * order = nullptr
111  );
125  Polynomial_Ring & R,
126  const list<Monomial> & mons,
127  const list<Prime_Field_Element> & coeffs,
128  const Monomial_Ordering * order = nullptr
129  );
140  unsigned length,
141  Polynomial_Ring & R,
142  const Monomial_Ordering * order = generic_grevlex_ptr
143  );
149  Constant_Polynomial(Polynomial_Ring &, const Monomial_Ordering *, uint64_t, uint64_t *);
151 
155 
156 
162  virtual void set_monomial_ordering(
163  const Monomial_Ordering * order, bool sort_anew = true
164  ) override;
169  virtual void sort_by_order() override;
171  virtual Monomial & leading_monomial() const override;
173  virtual Prime_Field_Element leading_coefficient() const override;
175  virtual unsigned length() const override;
177  virtual bool is_zero() const override;
179 
180 
184  virtual Constant_Polynomial * zero_polynomial() const override;
189  virtual Constant_Polynomial * monomial_multiple(const Monomial &t) const override;
194  virtual Constant_Polynomial * scalar_multiple(const Prime_Field_Element &c)
195  const override;
197 
198 
200  virtual Constant_Polynomial_Iterator * new_iterator() const override;
202  virtual Polynomial_Iterator * begin() const override;
204  virtual Polynomial_Iterator * end() const override;
206 
207 
217  uint64_t * serialized(uint64_t & size);
219 
223 protected:
231  unsigned m;
233  unsigned head;
234 };
235 
255 {
256 public:
258 
265 
269 
270  virtual void restart_iteration() override;
272  virtual void moveRight() override;
273  virtual void moveLeft() override;
274  virtual bool fellOff() const override;
276 
277  virtual const Monomial & currMonomial() const override;
279  virtual const Prime_Field_Element & currCoeff() const override;
281 
282  virtual void set_currCoeff(const Prime_Field_Element & a) override;
284  virtual void set_currMonomial(const Monomial & t) override;
286 protected:
290  long long i;
291 };
292 
293 #endif
The general class of a polynomial.
Definition: polynomial.hpp:101
virtual bool canMoveLeft() const override
Monomial * M
array of monomials, in one-to-one correspondence with A
Constant_Polynomial_Iterator(const Constant_Polynomial *q, bool at_end=false)
Creates an iterator for poly and starts at the leading term.
A Constant_Polynomial is a polynomial that should not change.
virtual void moveRight() override
Moves right in the polynomial, to the next smaller monomial.
virtual bool fellOff() const override
virtual const Monomial & currMonomial() const override
Reports the monomial at the current position.
const Constant_Polynomial * p
the polynomial we iterate on
Prime_Field_Element * A
array of coefficients, in one-to-one correspondence with M
virtual const Prime_Field_Element & currCoeff() const override
Reports the coefficient at the current position.
Constant_Polynomial * p
the polynomial over which we iterate
Implementation of monomials.
Definition: monomial.hpp:69
Element of a field of prime characteristic.
Definition: fields.hpp:137
interface to a monomial ordering
Encapsulates information about a polynomial ring for easy access: ground field, number of indetermina...
virtual bool canMoveRight() const override
Can this iterator move right, or would it fall off?
A Mutable_Polynomial_Iterator allows one to modify the terms of a polynomial.
Definition: polynomial.hpp:283
Iterates through a Constant_Polynomial.
long i
current position in p’s array
Used to iterate through a polynomial.
Definition: polynomial.hpp:224
virtual void restart_iteration() override
This should move the iterator to the leading term.
An iterator to modify monomials and coefficients of a Constant_Polynomial.
virtual void moveLeft() override
Moves left in the polynomial, to the next larger monomial.
long long i
the monomial we currently point to
unsigned m
position after last monomial
unsigned head
location of leading term in array (always farther left)