Gröbner basis project
Codebase for research into Gröbner basis computation
|
Polynomials implemented using double buffers.A double-buffered polynomial maintains at all times two arrays to store its terms. (Technically, it retains four arrays: two for the monomials, and two for the coefficients.) Any operation that might change the length of the polynomials reads the data in one buffer and writes the result to the other buffer. The goal of this approach is to avoid the penalties associated with allocating, deallocating, and traversing the nodes of a linked list. More...
#include <polynomial_double_buffered.hpp>
Public Member Functions | |
Construction | |
Double_Buffered_Polynomial (Polynomial_Ring &R, Monomial_Ordering *order=generic_grevlex_ptr) | |
Double_Buffered_Polynomial (Abstract_Polynomial const &p) | |
Destruction | |
~Double_Buffered_Polynomial () | |
Basic properties | |
virtual Monomial & | leading_monomial () const |
leading monomial – call after sort_by_order()! | |
virtual Prime_Field_Element | leading_coefficient () const |
leading coefficient – call after sort_by_order()! | |
virtual unsigned | length () const |
number of monomials | |
virtual bool | is_zero () const |
is this polynomial zero? | |
virtual bool | can_reduce (Abstract_Polynomial &other) const |
can this reduce other ? | |
virtual Double_Buffered_Polynomial * | zero_polynomial () const |
zero polynomial of this type | |
virtual void | set_monomial_ordering (Monomial_Ordering *order, bool sort_anew=true) |
set the monomial ordering and sort the polynomials (optionally, but by default) More... | |
Computation | |
virtual Double_Buffered_Polynomial * | monomial_multiple (const Monomial &t) const |
multiple of this and u | |
virtual Double_Buffered_Polynomial * | scalar_multiple (const Prime_Field_Element &c) const |
multiple of this and c | |
virtual Mutable_Polynomial & | operator+= (const Abstract_Polynomial &p) |
add another polynomial | |
virtual Mutable_Polynomial & | operator-= (const Abstract_Polynomial &p) |
subtract another polynomial | |
virtual void | add_polynomial_multiple (const Prime_Field_Element &a, const Monomial &u, const Abstract_Polynomial &p, bool subtract) |
add monomial multiple of other | |
virtual void | sort_by_order () |
sort according to the leading monomial’s ordering More... | |
Iteration | |
virtual DB_Polynomial_Iterator * | new_iterator () const |
An iterator that poses no risk of modifying the polynomial. | |
virtual DB_Polynomial_Iterator * | new_mutable_iterator () |
An iterator that may modify the current position. | |
virtual Polynomial_Iterator * | begin () const |
virtual Polynomial_Iterator * | end () const |
Modification | |
virtual void | add_last (const Prime_Field_Element &a, const Monomial &t) |
Attach a new monomial to the tail – check that it belongs at tail! | |
virtual Polynomial_Linked_List * | detach_head () |
Remove and return the head. | |
![]() | |
Mutable_Polynomial (Polynomial_Ring &R, Monomial_Ordering *ordering=generic_grevlex_ptr) | |
constructor | |
virtual | ~Mutable_Polynomial ()=0 |
destructor | |
virtual void | multiply_by_scalar (const Prime_Field_Element &a) |
multiply by scalar | |
virtual void | multiply_by_monomial (const Monomial &t) |
multiply by monomial | |
virtual void | reduce_by (const Abstract_Polynomial &p) |
reduce by \(p\) until no further reduction possible | |
![]() | |
Abstract_Polynomial (Polynomial_Ring &ring, Monomial_Ordering *ordering) | |
virtual | ~Abstract_Polynomial () |
Polynomial_Ring & | base_ring () const |
ring in which this polynomial resides | |
Prime_Field & | ground_field () |
ground field – all coefficients should be in this field | |
unsigned | number_of_variables () const |
number of variables – all monomials should agree with this (though it is never tested by the class) | |
Monomial_Ordering * | monomial_ordering () const |
reports leading monomial’s monomial ordering | |
virtual Poly_Strategy_Data * | strategy () const |
strategy related information | |
virtual DEG_TYPE | standard_degree () const |
maximum sum of exponents for any monomial | |
virtual DEG_TYPE | weighted_degree (const WT_TYPE *w=nullptr) const |
weighted sum of exponents for any monomial More... | |
void | set_strategy (Poly_Strategy_Data *psd) |
sets the polynomial’s strategy to psd | |
virtual void | print (ostream &os=cout) const |
virtual void | println (ostream &os=cout) const |
virtual void | printlncout () const |
Protected Member Functions | |
Buffering | |
bool | test_buffer (unsigned b, unsigned n) |
true iff buffer b has space to hold n elements; expand other buffer if not. | |
void | expand_buffer (unsigned b, unsigned n) |
Expand buffer b to hold \( 2n \) elements. More... | |
Friends | |
class | DB_Polynomial_Iterator |
Additional Inherited Members | |
![]() | |
Polynomial_Ring & | R |
data about polynomial ring | |
Poly_Strategy_Data * | strat = nullptr |
data for computational strategies | |
Polynomials implemented using double buffers.
A double-buffered polynomial maintains at all times two arrays to store its terms. (Technically, it retains four arrays: two for the monomials, and two for the coefficients.) Any operation that might change the length of the polynomials reads the data in one buffer and writes the result to the other buffer. The goal of this approach is to avoid the penalties associated with allocating, deallocating, and traversing the nodes of a linked list.
Definition at line 93 of file polynomial_double_buffered.hpp.
|
inlineprotected |
Expand buffer b
to hold \( 2n \) elements.
This does not test to see if the space is already available.
Definition at line 196 of file polynomial_double_buffered.hpp.
|
virtual |
set the monomial ordering and sort the polynomials (optionally, but by default)
Implements Abstract_Polynomial.
Definition at line 128 of file polynomial_double_buffered.cpp.
|
virtual |
sort according to the leading monomial’s ordering
Note that it makes sense to sort even Constant_Polynomial’s, as it is not the polynomial that changes, only the order of its monomials.
Implements Abstract_Polynomial.
Definition at line 329 of file polynomial_double_buffered.cpp.