Gröbner basis project
Codebase for research into Gröbner basis computation
Iterators over polynomials

classes related to iterating over polynomials More...

Classes

class  Constant_Polynomial_Iterator
 Iterates through a Constant_Polynomial. More...
 
class  DB_Polynomial_Iterator
 Iterator over double-buffered polynomials. More...
 
class  Geobucket_Iterator
 Iterates through polynomials using a geobucket representation. See Mutable_Polynomial_Iterator for details on methods. More...
 
class  LLPolynomial_Iterator
 Iterator over linked list polynomials. More...
 
class  Mutable_Constant_Polynomial_Iterator
 An iterator to modify monomials and coefficients of a Constant_Polynomial. More...
 
class  Mutable_Polynomial_Iterator
 A Mutable_Polynomial_Iterator allows one to modify the terms of a polynomial. More...
 
class  Polynomial_Iterator
 Used to iterate through a polynomial. More...
 
class  Polynomial_Term
 convenience class to help iterate through polynomials More...
 

Detailed Description

classes related to iterating over polynomials


Class Documentation

◆ Constant_Polynomial_Iterator

class Constant_Polynomial_Iterator

Iterates through a Constant_Polynomial.

Author
John Perry
Date
2015

Definition at line 37 of file polynomial_array.hpp.

Inheritance diagram for Constant_Polynomial_Iterator:
Polynomial_Iterator

Public Member Functions

Construction
 Constant_Polynomial_Iterator (const Constant_Polynomial *q, bool at_end=false)
 Creates an iterator for poly and starts at the leading term. More...
 
Destruction
 ~Constant_Polynomial_Iterator ()
 
Iteration
virtual void restart_iteration () override
 This should move the iterator to the leading term.
 
virtual void moveRight () override
 Moves right in the polynomial, to the next smaller monomial.
 
virtual void moveLeft () override
 Moves left in the polynomial, to the next larger monomial.
 
virtual bool canMoveRight () const override
 Can this iterator move right, or would it fall off?
 
virtual bool canMoveLeft () const override
 
virtual bool fellOff () const override
 
Data access
virtual const MonomialcurrMonomial () const override
 Reports the monomial at the current position.
 
virtual const Prime_Field_ElementcurrCoeff () const override
 Reports the coefficient at the current position.
 
- Public Member Functions inherited from Polynomial_Iterator
virtual ~Polynomial_Iterator ()=0
 needed to avoid undefined behavior when disposing
 
const Polynomial_Iteratoroperator++ ()
 Moves right in the polynomial, to the next smaller monomial.
 
virtual const Abstract_Polynomialmy_poly () const
 Reports the polynomial on which this is iterating.
 
const Polynomial_Term operator* () const
 C++11 iteration.
 
virtual bool operator!= (const Polynomial_Iterator &other) const
 

Protected Attributes

long i
 current position in p’s array
 
const Constant_Polynomialp
 the polynomial we iterate on
 
- Protected Attributes inherited from Polynomial_Iterator
const Abstract_Polynomialp
 the polynomial this points to
 

Constructor & Destructor Documentation

◆ Constant_Polynomial_Iterator()

Constant_Polynomial_Iterator::Constant_Polynomial_Iterator ( const Constant_Polynomial q,
bool  at_end = false 
)

Creates an iterator for poly and starts at the leading term.

Parameters
at_endwhether to start at the end of the polynomial
qpolynomial to iterate over

Definition at line 23 of file polynomial_array.cpp.

Member Function Documentation

◆ canMoveLeft()

bool Constant_Polynomial_Iterator::canMoveLeft ( ) const
overridevirtual
Returns
Can this iterator move left, or would it fall off?

Implements Polynomial_Iterator.

Definition at line 49 of file polynomial_array.cpp.

◆ fellOff()

bool Constant_Polynomial_Iterator::fellOff ( ) const
overridevirtual
Returns
true iff the iterator no longer points to a valid monomial.

This is NOT the same as pointing to a monomial with coefficient zero; this is true when the iterator would probably report inaccurate data.

Implements Polynomial_Iterator.

Definition at line 51 of file polynomial_array.cpp.

◆ DB_Polynomial_Iterator

class DB_Polynomial_Iterator

Iterator over double-buffered polynomials.

Author
John Perry
Date
2015

Definition at line 38 of file polynomial_double_buffered.hpp.

Inheritance diagram for DB_Polynomial_Iterator:
Mutable_Polynomial_Iterator Polynomial_Iterator

Public Member Functions

Construction
 DB_Polynomial_Iterator (const Double_Buffered_Polynomial *f, bool at_end=false)
 
Destruction
 ~DB_Polynomial_Iterator ()
 
Iteration
virtual void restart_iteration () override
 This should move the iterator to the leading term.
 
virtual void moveRight () override
 Moves right in the polynomial, to the next smaller monomial.
 
virtual void moveLeft () override
 Moves left in the polynomial, to the next larger monomial.
 
virtual bool fellOff () const override
 
virtual bool canMoveLeft () const override
 
virtual bool canMoveRight () const override
 Can this iterator move right, or would it fall off?
 
Data access
virtual const MonomialcurrMonomial () const override
 Reports the monomial at the current position.
 
virtual const Prime_Field_ElementcurrCoeff () const override
 Reports the coefficient at the current position.
 
Data modification
virtual void set_currCoeff (const Prime_Field_Element &a) override
 change coefficient in current position
 
virtual void set_currMonomial (const Monomial &t) override
 change monomial in current position
 
Data modification
- Public Member Functions inherited from Polynomial_Iterator
virtual ~Polynomial_Iterator ()=0
 needed to avoid undefined behavior when disposing
 
const Polynomial_Iteratoroperator++ ()
 Moves right in the polynomial, to the next smaller monomial.
 
virtual const Abstract_Polynomialmy_poly () const
 Reports the polynomial on which this is iterating.
 
const Polynomial_Term operator* () const
 C++11 iteration.
 
virtual bool operator!= (const Polynomial_Iterator &other) const
 

Protected Attributes

Prime_Field_ElementA
 pointer to coefficients
 
long long current_position
 current position in the list
 
unsigned head
 position of first monomial
 
MonomialT
 pointer to monomials
 
unsigned tail
 position of last monomial
 
- Protected Attributes inherited from Polynomial_Iterator
const Abstract_Polynomialp
 the polynomial this points to
 

Member Function Documentation

◆ canMoveLeft()

bool DB_Polynomial_Iterator::canMoveLeft ( ) const
overridevirtual
Returns
Can this iterator move left, or would it fall off?

Implements Polynomial_Iterator.

Definition at line 35 of file polynomial_double_buffered.cpp.

◆ fellOff()

bool DB_Polynomial_Iterator::fellOff ( ) const
overridevirtual
Returns
true iff the iterator no longer points to a valid monomial.

This is NOT the same as pointing to a monomial with coefficient zero; this is true when the iterator would probably report inaccurate data.

Implements Polynomial_Iterator.

Definition at line 31 of file polynomial_double_buffered.cpp.

◆ Geobucket_Iterator

class Geobucket_Iterator

Iterates through polynomials using a geobucket representation. See Mutable_Polynomial_Iterator for details on methods.

Author
John Perry
Date
2015

Implementation based on [10].

Warning
A polynomial in geobucket representation may not be fully simplified. Clients must not expect the monomials to be in any sort of order, and multiple instances of a monomial are possible. Geobuckets collapse only at canonicalization.

Definition at line 58 of file polynomial_geobucket.hpp.

Inheritance diagram for Geobucket_Iterator:
Mutable_Polynomial_Iterator Polynomial_Iterator

Public Member Functions

Construction
 Geobucket_Iterator (const Polynomial_Geobucket *, bool at_end=false)
 
 Geobucket_Iterator (Polynomial_Geobucket *, bool at_end=false)
 
Destruction
 ~Geobucket_Iterator ()
 
Iteration
virtual void restart_iteration () override
 This should move the iterator to the leading term.
 
virtual void moveRight () override
 Moves right in the polynomial, to the next smaller monomial.
 
virtual void moveLeft () override
 Moves left in the polynomial, to the next larger monomial.
 
virtual bool canMoveRight () const override
 Can this iterator move right, or would it fall off?
 
virtual bool canMoveLeft () const override
 
virtual bool fellOff () const override
 
Data access
virtual const MonomialcurrMonomial () const override
 Reports the monomial at the current position.
 
virtual const Prime_Field_ElementcurrCoeff () const override
 Reports the coefficient at the current position.
 
Data modification
virtual void set_currCoeff (const Prime_Field_Element &a) override
 change coefficient in current position
 
virtual void set_currMonomial (const Monomial &t) override
 change monomial in current position
 
Data modification
- Public Member Functions inherited from Polynomial_Iterator
virtual ~Polynomial_Iterator ()=0
 needed to avoid undefined behavior when disposing
 
const Polynomial_Iteratoroperator++ ()
 Moves right in the polynomial, to the next smaller monomial.
 
virtual const Abstract_Polynomialmy_poly () const
 Reports the polynomial on which this is iterating.
 
const Polynomial_Term operator* () const
 C++11 iteration.
 
virtual bool operator!= (const Polynomial_Iterator &other) const
 

Protected Attributes

unsigned bucket_number
 the bucket number at which we’re stopped
 
Polynomial_Geobucketg
 to save myself the hassle of static_cast<const Polynomial_Geobucket *>(p) every time I turn around
 
LLPolynomial_Iteratorpi
 an iterator for the current bucket
 
- Protected Attributes inherited from Polynomial_Iterator
const Abstract_Polynomialp
 the polynomial this points to
 

Member Function Documentation

◆ canMoveLeft()

bool Geobucket_Iterator::canMoveLeft ( ) const
overridevirtual
Returns
Can this iterator move left, or would it fall off?

Implements Polynomial_Iterator.

Definition at line 23 of file polynomial_geobucket.cpp.

◆ fellOff()

bool Geobucket_Iterator::fellOff ( ) const
overridevirtual
Returns
true iff the iterator no longer points to a valid monomial.

This is NOT the same as pointing to a monomial with coefficient zero; this is true when the iterator would probably report inaccurate data.

Implements Polynomial_Iterator.

Definition at line 31 of file polynomial_geobucket.cpp.

◆ LLPolynomial_Iterator

class LLPolynomial_Iterator

Iterator over linked list polynomials.

Author
John Perry
Date
2015

Definition at line 102 of file polynomial_linked_list.hpp.

Inheritance diagram for LLPolynomial_Iterator:
Mutable_Polynomial_Iterator Polynomial_Iterator

Public Member Functions

Construction
 LLPolynomial_Iterator (Polynomial_Linked_List *poly, bool at_end=false)
 Initializes at the leading monomial.
 
 LLPolynomial_Iterator (const Polynomial_Linked_List *poly, bool at_end=false)
 Initializes at the leading monomial.
 
Iteration
virtual void restart_iteration () override
 Initializes at the leading monomial.
 
virtual void moveRight () override
 Returns the monomial the iterator currently points to. More...
 
virtual void moveLeft () override
 Moves the iterator left: to the next larger monomial.
 
virtual bool canMoveLeft () const override
 Can this iterator move left, or would it fall off?
 
virtual bool canMoveRight () const override
 Can this iterator move right, or would it fall off?
 
virtual bool fellOff () const override
 true iff the iterator no longer points to a valid monomial.
 
Data access
virtual const MonomialcurrMonomial () const override
 Reports the monomial at the current position.
 
virtual const Prime_Field_ElementcurrCoeff () const override
 Returns the coefficient of the monomial the iterator currently points to.
 
Data modification
- Public Member Functions inherited from Polynomial_Iterator
virtual ~Polynomial_Iterator ()=0
 needed to avoid undefined behavior when disposing
 
const Polynomial_Iteratoroperator++ ()
 Moves right in the polynomial, to the next smaller monomial.
 
virtual const Abstract_Polynomialmy_poly () const
 Reports the polynomial on which this is iterating.
 
const Polynomial_Term operator* () const
 C++11 iteration.
 
virtual bool operator!= (const Polynomial_Iterator &other) const
 

Data modification

Polynomial_Linked_Listp
 @ More...
 
Monomial_Nodeiter_curr
 the node at which we have stopped
 
virtual void set_currCoeff (const Prime_Field_Element &a) override
 change coefficient in current position
 
virtual void set_currMonomial (const Monomial &t) override
 change monomial in current position
 

Additional Inherited Members

- Protected Attributes inherited from Polynomial_Iterator
const Abstract_Polynomialp
 the polynomial this points to
 

Member Function Documentation

◆ moveRight()

virtual void LLPolynomial_Iterator::moveRight ( )
inlineoverridevirtual

Returns the monomial the iterator currently points to.

Moves the iterator right: to the next smaller monomial.

Implements Polynomial_Iterator.

Definition at line 128 of file polynomial_linked_list.hpp.

Member Data Documentation

◆ p

Polynomial_Linked_List* LLPolynomial_Iterator::p
protected

@

the polynomial over which we iterate

Definition at line 159 of file polynomial_linked_list.hpp.

◆ Mutable_Constant_Polynomial_Iterator

class Mutable_Constant_Polynomial_Iterator

An iterator to modify monomials and coefficients of a Constant_Polynomial.

Author
John Perry
Date
2015

Sometimes we want to be able to change particular monomials in a Constant_Polynomial. This a bit naughty, since it violates the spirit of a Constant_Polynomial. I guess I need a different name for the latter. This generally mimics a Constant_Polynomial_Iterator, but cannot inherit from it due to issues with the const keyword. This may reflect bad design.

Definition at line 253 of file polynomial_array.hpp.

Inheritance diagram for Mutable_Constant_Polynomial_Iterator:
Mutable_Polynomial_Iterator Polynomial_Iterator

Public Member Functions

Construction
 Mutable_Constant_Polynomial_Iterator (Constant_Polynomial *poly)
 Creates an iterator for poly and starts at its leading term. More...
 
Destruction
 ~Mutable_Constant_Polynomial_Iterator ()
 
Iteration
virtual void restart_iteration () override
 This should move the iterator to the leading term.
 
virtual void moveRight () override
 Moves right in the polynomial, to the next smaller monomial.
 
virtual void moveLeft () override
 Moves left in the polynomial, to the next larger monomial.
 
virtual bool fellOff () const override
 
Data access
virtual const MonomialcurrMonomial () const override
 Reports the monomial at the current position.
 
virtual const Prime_Field_ElementcurrCoeff () const override
 Reports the coefficient at the current position.
 
Data modification
virtual void set_currCoeff (const Prime_Field_Element &a) override
 change coefficient in current position
 
virtual void set_currMonomial (const Monomial &t) override
 change monomial in current position
 
Data modification
- Public Member Functions inherited from Polynomial_Iterator
virtual ~Polynomial_Iterator ()=0
 needed to avoid undefined behavior when disposing
 
const Polynomial_Iteratoroperator++ ()
 Moves right in the polynomial, to the next smaller monomial.
 
virtual bool canMoveRight () const =0
 Can this iterator move right, or would it fall off?
 
virtual bool canMoveLeft () const =0
 
virtual const Abstract_Polynomialmy_poly () const
 Reports the polynomial on which this is iterating.
 
const Polynomial_Term operator* () const
 C++11 iteration.
 
virtual bool operator!= (const Polynomial_Iterator &other) const
 

Protected Attributes

long long i
 the monomial we currently point to
 
Constant_Polynomialp
 the polynomial over which we iterate
 
- Protected Attributes inherited from Polynomial_Iterator
const Abstract_Polynomialp
 the polynomial this points to
 

Constructor & Destructor Documentation

◆ Mutable_Constant_Polynomial_Iterator()

Mutable_Constant_Polynomial_Iterator::Mutable_Constant_Polynomial_Iterator ( Constant_Polynomial poly)

Creates an iterator for poly and starts at its leading term.

Parameters
polythe polynomial this will iterate over

Definition at line 267 of file polynomial_array.cpp.

Member Function Documentation

◆ fellOff()

bool Mutable_Constant_Polynomial_Iterator::fellOff ( ) const
overridevirtual
Returns
true iff the iterator no longer points to a valid monomial.

This is NOT the same as pointing to a monomial with coefficient zero; this is true when the iterator would probably report inaccurate data.

Implements Polynomial_Iterator.

Definition at line 282 of file polynomial_array.cpp.

◆ Mutable_Polynomial_Iterator

class Mutable_Polynomial_Iterator

A Mutable_Polynomial_Iterator allows one to modify the terms of a polynomial.

Author
John Perry
Date
2015

Definition at line 283 of file polynomial.hpp.

Inheritance diagram for Mutable_Polynomial_Iterator:
Polynomial_Iterator DB_Polynomial_Iterator Geobucket_Iterator LLPolynomial_Iterator Mutable_Constant_Polynomial_Iterator

Public Member Functions

Data modification
virtual void set_currCoeff (const Prime_Field_Element &)=0
 change coefficient in current position
 
virtual void set_currMonomial (const Monomial &)=0
 change monomial in current position
 
- Public Member Functions inherited from Polynomial_Iterator
virtual ~Polynomial_Iterator ()=0
 needed to avoid undefined behavior when disposing
 
virtual void restart_iteration ()=0
 This should move the iterator to the leading term.
 
virtual void moveRight ()=0
 Moves right in the polynomial, to the next smaller monomial.
 
const Polynomial_Iteratoroperator++ ()
 Moves right in the polynomial, to the next smaller monomial.
 
virtual bool canMoveRight () const =0
 Can this iterator move right, or would it fall off?
 
virtual void moveLeft ()=0
 Moves left in the polynomial, to the next larger monomial.
 
virtual bool canMoveLeft () const =0
 
virtual bool fellOff () const =0
 
virtual const Abstract_Polynomialmy_poly () const
 Reports the polynomial on which this is iterating.
 
virtual const MonomialcurrMonomial () const =0
 Reports the monomial at the current position.
 
virtual const Prime_Field_ElementcurrCoeff () const =0
 Reports the coefficient at the current position.
 
const Polynomial_Term operator* () const
 C++11 iteration.
 
virtual bool operator!= (const Polynomial_Iterator &other) const
 

Additional Inherited Members

- Protected Attributes inherited from Polynomial_Iterator
const Abstract_Polynomialp
 the polynomial this points to
 

◆ Polynomial_Iterator

class Polynomial_Iterator

Used to iterate through a polynomial.

Author
John Perry
Date
2015

This class encapsulates the basic functionality needed to iterate through the monomials of a polynomial. A Polynomial_Iterator cannot modify a polynomial, however; to do that, you need a Mutable_Polynomial_Iterator.

Definition at line 224 of file polynomial.hpp.

Inheritance diagram for Polynomial_Iterator:
Constant_Polynomial_Iterator Mutable_Polynomial_Iterator DB_Polynomial_Iterator Geobucket_Iterator LLPolynomial_Iterator Mutable_Constant_Polynomial_Iterator

Public Member Functions

Destruction
virtual ~Polynomial_Iterator ()=0
 needed to avoid undefined behavior when disposing
 
Iteration
virtual void restart_iteration ()=0
 This should move the iterator to the leading term.
 
virtual void moveRight ()=0
 Moves right in the polynomial, to the next smaller monomial.
 
const Polynomial_Iteratoroperator++ ()
 Moves right in the polynomial, to the next smaller monomial.
 
virtual bool canMoveRight () const =0
 Can this iterator move right, or would it fall off?
 
virtual void moveLeft ()=0
 Moves left in the polynomial, to the next larger monomial.
 
virtual bool canMoveLeft () const =0
 
virtual bool fellOff () const =0
 
Data access
virtual const Abstract_Polynomialmy_poly () const
 Reports the polynomial on which this is iterating.
 
virtual const MonomialcurrMonomial () const =0
 Reports the monomial at the current position.
 
virtual const Prime_Field_ElementcurrCoeff () const =0
 Reports the coefficient at the current position.
 
const Polynomial_Term operator* () const
 C++11 iteration.
 
virtual bool operator!= (const Polynomial_Iterator &other) const
 

Protected Attributes

const Abstract_Polynomialp
 the polynomial this points to
 

Member Function Documentation

◆ canMoveLeft()

virtual bool Polynomial_Iterator::canMoveLeft ( ) const
pure virtual
Returns
Can this iterator move left, or would it fall off?

Implemented in LLPolynomial_Iterator, Geobucket_Iterator, DB_Polynomial_Iterator, and Constant_Polynomial_Iterator.

◆ fellOff()

virtual bool Polynomial_Iterator::fellOff ( ) const
pure virtual
Returns
true iff the iterator no longer points to a valid monomial.

This is NOT the same as pointing to a monomial with coefficient zero; this is true when the iterator would probably report inaccurate data.

Implemented in Mutable_Constant_Polynomial_Iterator, LLPolynomial_Iterator, Geobucket_Iterator, Constant_Polynomial_Iterator, and DB_Polynomial_Iterator.

◆ Polynomial_Term

class Polynomial_Term

convenience class to help iterate through polynomials

Author
John Perry
Date
2016

Definition at line 60 of file polynomial.hpp.

Public Member Functions

Construction
 Polynomial_Term (const Monomial &m, const Prime_Field_Element &a)
 
Basic properties
const Monomialmonomial ()
 the monomial of this term
 
const Prime_Field_Elementcoefficient ()
 the coefficient for this term
 

Protected Attributes

const Prime_Field_Elementc
 the coefficient of this term
 
const Monomialt
 the monomial part of this term