Gröbner basis project
Codebase for research into Gröbner basis computation
Polynomial_Geobucket Class Reference

Implementation of geobuckets. More...

#include <polynomial_geobucket.hpp>

Inheritance diagram for Polynomial_Geobucket:
Mutable_Polynomial Abstract_Polynomial

Public Member Functions

Construction
 Polynomial_Geobucket (Polynomial_Ring &R, Monomial_Ordering *order=generic_grevlex_ptr)
 Initializes a polynomial with the given number of variables, over the given field.
 
 Polynomial_Geobucket (Abstract_Polynomial &p)
 Initializes a geobucket that is a copy of \(p\).
 
Destruction
 ~Polynomial_Geobucket ()
 Deallocates buckets, if they exist.
 
Basic properties
virtual void sort_by_order ()
 Sorts each geobucket. More...
 
virtual void set_monomial_ordering (Monomial_Ordering *order, bool sort_anew=true)
 Sets the monomial ordering for each bucket. More...
 
virtual Monomialleading_monomial () const
 Returns the leading monomial. More...
 
virtual Prime_Field_Element leading_coefficient () const
 Returns the leading coefficient. More...
 
virtual unsigned length () const
 Number of monomials in this polynomial. More...
 
virtual Polynomial_Linked_Listzero_polynomial () const
 A geobucket initialized to zero.
 
virtual bool is_zero () const
 true iff all the buckets are nullptr or themselves zero. More...
 
virtual bool can_reduce (Abstract_Polynomial &other) const
 Whether this can reduce other. A geobucket should not generally be used to reduce other polynomials, so avoid this like the plague.
 
virtual Geobucket_Iteratornew_iterator () const
 An iterator that poses no risk of modifying the polynomial.
 
virtual Polynomial_Iteratorbegin () const
 
virtual Polynomial_Iteratorend () const
 
virtual Geobucket_Iteratornew_mutable_iterator ()
 An iterator that may modify the current position.
 
Computation
virtual void recompute_leading_monomial ()
 You will need to call this after every operation that might modify the leading term. More...
 
virtual Polynomial_Geobucketmonomial_multiple (const Monomial &t) const
 Returns \(\texttt{this}\times t\).
 
virtual Polynomial_Geobucketscalar_multiple (const Prime_Field_Element &a) const
 Returns \(\texttt{this}\times a\).
 
virtual Polynomial_Geobucketoperator+= (const Abstract_Polynomial &g)
 Adds \(g\) to this. Recomputes leading monomial.
 
virtual Polynomial_Geobucketoperator-= (const Abstract_Polynomial &g)
 Subtracts \(g\) from this. Recomputes leading monomial.
 
virtual void add_polynomial_multiple (const Prime_Field_Element &b, const Monomial &u, const Abstract_Polynomial &g, bool subtract=false)
 Adds \(bug\) to this. Recomputes leading monomial.
 
virtual Polynomial_Linked_Listdetach_head ()
 Detaches the head and recomputes leading monomial.
 
virtual void add_last (const Prime_Field_Element &a, const Monomial &t)
 Adds \(at\) as a monomial of this. (Not necessarily the last!) More...
 
virtual Abstract_Polynomialcanonicalize (bool constant_result=false)
 Returns a copy of this in a simplified linear form. More...
 
- Public Member Functions inherited from Mutable_Polynomial
 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
 
- Public Member Functions inherited from Abstract_Polynomial
 Abstract_Polynomial (Polynomial_Ring &ring, Monomial_Ordering *ordering)
 
virtual ~Abstract_Polynomial ()
 
Polynomial_Ringbase_ring () const
 ring in which this polynomial resides
 
Prime_Fieldground_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_Orderingmonomial_ordering () const
 reports leading monomial’s monomial ordering
 
virtual Poly_Strategy_Datastrategy () 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 println (ostream &os=cout) const
 
virtual void printlncout () const
 

Protected Member Functions

unsigned lglen (unsigned i)
 Log-length of \(i\), used to select a bucket for a polynomial of length \(i\).
 

Protected Attributes

Polynomial_Linked_List ** buckets
 Array of ptrs to linked list polys; most initialized to nullptr.
 
- Protected Attributes inherited from Abstract_Polynomial
Polynomial_RingR
 data about polynomial ring
 
Poly_Strategy_Datastrat = nullptr
 data for computational strategies
 

Friends

class Geobucket_Iterator
 

I/O

ostream & operator<< (ostream &, const Polynomial_Geobucket &)
 prints the geobucket in an explicitly geobucket form More...
 
virtual void print (unsigned i, ostream &os=cout) const
 prints the \(i\)th bucket More...
 
virtual void print (ostream &os=cout) const
 prints the polynomial with an explicitly bucket form More...
 

Detailed Description

Implementation of geobuckets.

Author
John Perry
Date
2015
Warning
After any operation that might modify the leading term (such as adding, subtracting polynomials – not, however, scalar or monomial multiplication) you will need to call recompute_leading_monomial().
Exceeding the number of buckets will raise an exception. This will occur when a partial sum’s size exceeds NUM_BUCKETS.

Definition at line 97 of file polynomial_geobucket.hpp.

Member Function Documentation

◆ add_last()

void Polynomial_Geobucket::add_last ( const Prime_Field_Element a,
const Monomial t 
)
virtual

Adds \(at\) as a monomial of this. (Not necessarily the last!)

Warning
In the case of a geobucket, add_last() doesn’t really make sense (the last monomial might not be in order, after all) so this should not be used. As in the usual case, we do assume it belongs at the tail; we simply add it to a tail bucket (i.e., not bucket[0]).

Implements Mutable_Polynomial.

Definition at line 346 of file polynomial_geobucket.cpp.

◆ canonicalize()

Abstract_Polynomial * Polynomial_Geobucket::canonicalize ( bool  constant_result = false)
virtual

Returns a copy of this in a simplified linear form.

If constant is true, the result is a Constant_Polynomial. Otherwise, the result is a Polynomial_Linked_List. Choose the latter if you anticipate further reduction, such as tail reduction. (Geobuckets by default do not reduce lower-order terms.)

Definition at line 361 of file polynomial_geobucket.cpp.

◆ is_zero()

bool Polynomial_Geobucket::is_zero ( ) const
virtual

true iff all the buckets are nullptr or themselves zero.

See also
Fixed_Length_Polynomial

Implements Abstract_Polynomial.

Definition at line 184 of file polynomial_geobucket.cpp.

◆ leading_coefficient()

Prime_Field_Element Polynomial_Geobucket::leading_coefficient ( ) const
virtual

Returns the leading coefficient.

Warning
Does not recompute the leading monomial first. Make sure the leading monomial exists and is valid.
Descendants that perform any arithemtic that might change the leading monomial should invoke recompute_leading_monomial() before this. The class’s own functions for arithmetic do this automatically (or should).

Implements Abstract_Polynomial.

Definition at line 168 of file polynomial_geobucket.cpp.

◆ leading_monomial()

Monomial & Polynomial_Geobucket::leading_monomial ( ) const
virtual

Returns the leading monomial.

Warning
Does not recompute the leading monomial first. Make sure the leading monomial exists and is valid.
Descendants that perform any arithemtic that might change the leading monomial should invoke recompute_leading_monomial() before this. The class’s own functions for arithmetic do this automatically (or should).

Implements Abstract_Polynomial.

Definition at line 164 of file polynomial_geobucket.cpp.

◆ length()

unsigned Polynomial_Geobucket::length ( ) const
virtual

Number of monomials in this polynomial.

Warning
This will not include potential simplification of monomials. A geobucket does not simplify non-leading terms until canonicalization.

Implements Abstract_Polynomial.

Definition at line 172 of file polynomial_geobucket.cpp.

◆ print() [1/2]

void Polynomial_Geobucket::print ( unsigned  i,
ostream &  os = cout 
) const
virtual

prints the \(i\)th bucket

In the context of geobuckets, this makes more sense than printing the polynomial. Practically, printing the polynomial does the same thing as printing the contents of the buckets, but the more general function can be misleading on account of the un-simplified nature of the polynomial.

Definition at line 382 of file polynomial_geobucket.cpp.

◆ print() [2/2]

void Polynomial_Geobucket::print ( ostream &  os = cout) const
virtual

prints the polynomial with an explicitly bucket form

Prints the polynomial in the form

\[(b_1) + (b_2) + \cdots + (b_\textrm{last}).\]

Parentheses separate buckets, whose sums have not (yet) been simplified. Uninitiated and nonzero buckets are not printed.

Reimplemented from Abstract_Polynomial.

Definition at line 386 of file polynomial_geobucket.cpp.

◆ recompute_leading_monomial()

void Polynomial_Geobucket::recompute_leading_monomial ( )
virtual

You will need to call this after every operation that might modify the leading term.

The assumption here is that the first bucket no longer contains a valid leading term, so we skip it and try to extract from a later one. If the other buckets are all zero, we indicate this.

Definition at line 197 of file polynomial_geobucket.cpp.

◆ set_monomial_ordering()

void Polynomial_Geobucket::set_monomial_ordering ( Monomial_Ordering order,
bool  sort_anew = true 
)
virtual

Sets the monomial ordering for each bucket.

Warning
This performs no simplification bewteen buckets.

Implements Abstract_Polynomial.

Definition at line 157 of file polynomial_geobucket.cpp.

◆ sort_by_order()

void Polynomial_Geobucket::sort_by_order ( )
virtual

Sorts each geobucket.

Warning
This performs no simplification between buckets.

Implements Abstract_Polynomial.

Definition at line 151 of file polynomial_geobucket.cpp.

Friends And Related Function Documentation

◆ operator<<

ostream& operator<< ( ostream &  os,
const Polynomial_Geobucket p 
)
friend

prints the geobucket in an explicitly geobucket form

See also
print(ostream &) const

Definition at line 400 of file polynomial_geobucket.cpp.


The documentation for this class was generated from the following files: