Gröbner basis project
Codebase for research into Gröbner basis computation
|
classes related to the structure of polynomials More...
Classes | |
class | Abstract_Polynomial |
The general class of a polynomial. More... | |
class | Constant_Polynomial |
A Constant_Polynomial is a polynomial that should not change. More... | |
class | Dense_Univariate_Integer_Polynomial |
quick-’n-dirty Dense_Univariate integer polynomial class More... | |
class | Dense_Univariate_Rational_Polynomial |
quick-’n-dirty Dense_Univariate rational polynomial class More... | |
class | Double_Buffered_Polynomial |
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... | |
class | Indeterminate |
Implementation of indeterminates, for easier building of polynomials. More... | |
class | Monomial |
Implementation of monomials. More... | |
class | Monomial_Ideal |
A class for monomial ideals. More... | |
class | Monomial_Ideal_Variables_Exception |
exceptions for Monomial Ideals More... | |
class | Monomial_Node |
Tool for Polynomial_Linked_List. More... | |
class | Mutable_Polynomial |
Polynomials that need arithmetic typically descend from this class. More... | |
class | Polynomial_Geobucket |
Implementation of geobuckets. More... | |
class | Polynomial_Linked_List |
Polynomials represented as a doubly linked list. More... | |
class | Polynomial_Ring |
Encapsulates information about a polynomial ring for easy access: ground field, number of indeterminates, …. More... | |
Functions | |
list< Monomial > | colon_ideal_without_ideals (const list< Monomial > &U, const Monomial &t) |
Computes the generators of an ideal and a new generator, given the ideal's generators. No monomial ideal machinery required. More... | |
list< Abstract_Polynomial * > | cyclic_n (NVAR_TYPE n, Prime_Field &F, bool homog, Monomial_Ordering *mord=generic_grevlex_ptr) |
generates the Cyclic- \( n \) system More... | |
classes related to the structure of polynomials
class Abstract_Polynomial |
The general class of a polynomial.
This class encapsulates the minimum feature set necessary for our application. Naturally, it must be possible to identify a leading monomial and coefficient. Every polynomial must also be able to produce an iterator; indicate its its length (number of monomials), and its number of variables; describe its ground field; and produce a zero polynomial of the same type (this has its uses).
Definition at line 101 of file polynomial.hpp.
Public Member Functions | |
Construction | |
Abstract_Polynomial (Polynomial_Ring &ring, const Monomial_Ordering *ordering) | |
Destruction | |
virtual | ~Abstract_Polynomial () |
Basic properties | |
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) | |
const Monomial_Ordering * | monomial_ordering () const |
reports leading monomial’s monomial ordering | |
virtual Monomial & | leading_monomial () const =0 |
leading monomial – call after sort_by_order()! | |
virtual Prime_Field_Element | leading_coefficient () const =0 |
leading coefficient – call after sort_by_order()! | |
virtual unsigned | length () const =0 |
number of monomials | |
virtual bool | is_zero () const =0 |
is this polynomial zero? | |
virtual bool | can_reduce (Abstract_Polynomial &other) const |
can this reduce other ? | |
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 |
Computation | |
virtual Abstract_Polynomial * | zero_polynomial () const =0 |
new zero polynomial of this same type | |
virtual Abstract_Polynomial * | monomial_multiple (const Monomial &) const =0 |
multiple of this and \(u\) | |
virtual Abstract_Polynomial * | scalar_multiple (const Prime_Field_Element &) const =0 |
multiple of this and \(c\) | |
void | set_strategy (Poly_Strategy_Data *psd) |
sets the polynomial’s strategy to psd | |
Ordering monomials | |
virtual void | set_monomial_ordering (const Monomial_Ordering *order, bool sort_anew=true)=0 |
set the monomial ordering and sort the polynomials (optionally, but by default) More... | |
virtual void | sort_by_order ()=0 |
sort according to the leading monomial’s ordering More... | |
Iteration | |
virtual Polynomial_Iterator * | new_iterator () const =0 |
An iterator that poses no risk of modifying the polynomial. | |
virtual Polynomial_Iterator * | begin () const =0 |
virtual Polynomial_Iterator * | end () const =0 |
Protected Attributes | |
Polynomial_Ring & | R |
data about polynomial ring | |
Poly_Strategy_Data * | strat = nullptr |
data for computational strategies | |
I/O | |
virtual void | print (ostream &os=cout) const |
virtual void | println (ostream &os=cout) const |
virtual void | printlncout () const |
ostream & | operator<< (ostream &os, const Abstract_Polynomial &p) |
output | |
|
inline |
ring | the polynomial ring in which this polynomial will reside |
ordering | the monomial ordering that first sorts the monomials |
Definition at line 110 of file polynomial.hpp.
|
pure virtual |
set the monomial ordering and sort the polynomials (optionally, but by default)
order | new monomial ordering |
sort_anew | whether to sort the polynomial anew |
Implemented in Polynomial_Linked_List, Constant_Polynomial, Polynomial_Geobucket, and Double_Buffered_Polynomial.
|
pure 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.
Implemented in Polynomial_Linked_List, Double_Buffered_Polynomial, Constant_Polynomial, and Polynomial_Geobucket.
|
virtual |
w | weights to use for weighted degree |
Equivalent to standard_degree() if w == nullptr
.
Definition at line 108 of file polynomial.cpp.
class Constant_Polynomial |
A Constant_Polynomial is a polynomial that should not change.
We do allow on change at this level: to resort the monomials. We do not consider this a real change (it’s still the same polynomial), and in any case even this is effectively unimplemented right now (unless you set up the polynomial with unsorted terms, in which case sorting them helps).
Definition at line 87 of file polynomial_array.hpp.
Public Member Functions | |
Construction | |
Constant_Polynomial (unsigned length, Polynomial_Ring &R, const Monomial *mons, const Prime_Field_Element *coeffs, const Monomial_Ordering *order=nullptr) | |
Constant_Polynomial (Polynomial_Ring &R, const list< Monomial > &mons, const list< Prime_Field_Element > &coeffs, const Monomial_Ordering *order=nullptr) | |
Constant_Polynomial (unsigned length, Polynomial_Ring &R, const Monomial_Ordering *order=generic_grevlex_ptr) | |
Constant_Polynomial (const Abstract_Polynomial &p) | |
Creates a constant polynomial copy of p. | |
Constant_Polynomial (Polynomial_Ring &, const Monomial_Ordering *, uint64_t, uint64_t *) | |
from serial data | |
Destruction | |
~Constant_Polynomial () | |
Basic properties | |
virtual void | set_monomial_ordering (const Monomial_Ordering *order, bool sort_anew=true) override |
sets the ordering of monomials in this polynomial More... | |
virtual void | sort_by_order () override |
sort by order More... | |
virtual Monomial & | leading_monomial () const override |
virtual Prime_Field_Element | leading_coefficient () const override |
virtual unsigned | length () const override |
virtual bool | is_zero () const override |
Computation | |
virtual Constant_Polynomial * | zero_polynomial () const override |
virtual Constant_Polynomial * | monomial_multiple (const Monomial &t) const override |
virtual Constant_Polynomial * | scalar_multiple (const Prime_Field_Element &c) const override |
Iteration | |
virtual Constant_Polynomial_Iterator * | new_iterator () const override |
an iterator that poses no risk of modifying the polynomial | |
virtual Polynomial_Iterator * | begin () const override |
iterator to the first element | |
virtual Polynomial_Iterator * | end () const override |
iterator to the last element | |
Serialization | |
uint64_t * | serialized (uint64_t &size) |
![]() | |
Abstract_Polynomial (Polynomial_Ring &ring, const 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) | |
const Monomial_Ordering * | monomial_ordering () const |
reports leading monomial’s monomial ordering | |
virtual bool | can_reduce (Abstract_Polynomial &other) const |
can this reduce other ? | |
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 |
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 Attributes | |
Prime_Field_Element * | A |
array of coefficients, in one-to-one correspondence with M | |
unsigned | head |
location of leading term in array (always farther left) | |
Monomial * | M |
array of monomials, in one-to-one correspondence with A | |
unsigned | m |
position after last monomial | |
![]() | |
Polynomial_Ring & | R |
data about polynomial ring | |
Poly_Strategy_Data * | strat = nullptr |
data for computational strategies | |
Friends | |
class | Constant_Polynomial_Iterator |
to iterate without changing this | |
class | Mutable_Constant_Polynomial_Iterator |
to iterate and possibly change this | |
Constant_Polynomial::Constant_Polynomial | ( | unsigned | length, |
Polynomial_Ring & | R, | ||
const Monomial * | mons, | ||
const Prime_Field_Element * | coeffs, | ||
const Monomial_Ordering * | order = nullptr |
||
) |
length | how long this should be |
R | parent ring |
mons | array of Monomial to populate the terms |
coeffs | array of coefficients to populate the terms, in same order as mons |
order | monomial ordering used to first sort the polynomial; nullptr gives generic_grevlex_ptr |
We assume that mons and coeffs both have length n. We do not check that the monomials have the same number of variables, nor that the coefficients come from the same field, nor do we sort the monomials. The client needs to do this!
Definition at line 54 of file polynomial_array.cpp.
Constant_Polynomial::Constant_Polynomial | ( | Polynomial_Ring & | R, |
const list< Monomial > & | mons, | ||
const list< Prime_Field_Element > & | coeffs, | ||
const Monomial_Ordering * | order = nullptr |
||
) |
R | parent ring |
mons | list of Monomial to populate the terms |
coeffs | list of coefficients to populate the terms, in same order as mons |
order | monomial ordering used to first sort the polynomial; nullptr gives generic_grevlex_ptr |
We assume that mons and coeffs have the same length. We do not check that the monomials have the same number of variables, nor that the coefficients come from the same field, nor do we sort the monomials. The client needs to do this!
Definition at line 82 of file polynomial_array.cpp.
Constant_Polynomial::Constant_Polynomial | ( | unsigned | length, |
Polynomial_Ring & | R, | ||
const Monomial_Ordering * | order = generic_grevlex_ptr |
||
) |
length | how long this should be |
R | parent ring |
order | monomial ordering |
This is a pretty useless constructor unless you know what you’re doing. Unless you’re a child of Constant_Polynomial, you don’t know what you’re doing. Even then, you probably don’t know what you’re doing.
Definition at line 113 of file polynomial_array.cpp.
|
overridevirtual |
Implements Abstract_Polynomial.
Definition at line 209 of file polynomial_array.cpp.
|
overridevirtual |
Implements Abstract_Polynomial.
Definition at line 203 of file polynomial_array.cpp.
|
overridevirtual |
Implements Abstract_Polynomial.
Definition at line 201 of file polynomial_array.cpp.
|
overridevirtual |
Implements Abstract_Polynomial.
Definition at line 207 of file polynomial_array.cpp.
|
overridevirtual |
this
and u
t | a Monomial in the same ring |
Implements Abstract_Polynomial.
Definition at line 221 of file polynomial_array.cpp.
|
overridevirtual |
this
and c
c | a scalar in the same prime field |
Implements Abstract_Polynomial.
Definition at line 229 of file polynomial_array.cpp.
uint64_t * Constant_Polynomial::serialized | ( | uint64_t & | size | ) |
uint64_t
containing the polynomial data and assigns the length of this array to size
size | modified to the number of elements in the array |
The data is stored in the form [ A1 M11 M12 ... M1n A2 M21 M22 ... M2n ... ] where Ai is the ith coefficient (lead is first) and Mij is the exponent of xj in the ith monomial
Definition at line 152 of file polynomial_array.cpp.
|
overridevirtual |
sets the ordering of monomials in this polynomial
order | the (new?) monomial ordering |
sort_anew | set this to true to re-sort the polynomial |
Implements Abstract_Polynomial.
Definition at line 174 of file polynomial_array.cpp.
|
overridevirtual |
sort by order
currently uses insertion sort
Implements Abstract_Polynomial.
Definition at line 183 of file polynomial_array.cpp.
|
overridevirtual |
Implements Abstract_Polynomial.
Definition at line 213 of file polynomial_array.cpp.
class Dense_Univariate_Integer_Polynomial |
quick-’n-dirty Dense_Univariate integer polynomial class
deg
smaller than size
, as deg
indexes the monomial of largest degree, which can be at most size - 1
. Definition at line 37 of file dense_univariate_integer_poly.hpp.
Public Member Functions | |
Construction | |
Dense_Univariate_Integer_Polynomial (DEG_TYPE) | |
construct with the number of expected terms | |
Dense_Univariate_Integer_Polynomial (const Dense_Univariate_Integer_Polynomial &) | |
copy constructor | |
Dense_Univariate_Integer_Polynomial (DEG_TYPE, int64_t *) | |
from serialized data | |
Destruction | |
~Dense_Univariate_Integer_Polynomial () | |
Modification | |
void | expand_poly (DEG_TYPE) |
expand to allow for higher-degree monomials More... | |
void | set_coefficient (DEG_TYPE k, COEF_TYPE a) |
set the coefficient of \(x^k\) to \(\frac{a}{b}\) | |
void | scale_by (COEF_TYPE a) |
multiplies every monomial by a constant | |
void | multiply_by_monomial_of_degree (DEG_TYPE) |
a hopefully efficient multiplication algorithm More... | |
void | multiply_by (const Dense_Univariate_Integer_Polynomial &) |
highly inefficient polynomial multiplication ( \(O(mn)\)) | |
void | negate () |
negates the coefficients | |
void | add (const Dense_Univariate_Integer_Polynomial &q) |
reasonably efficient, given our dense representation More... | |
Dense_Univariate_Integer_Polynomial & | operator+= (const Dense_Univariate_Integer_Polynomial &q) |
Computation | |
Dense_Univariate_Integer_Polynomial | operator- (const Dense_Univariate_Integer_Polynomial &) const |
returns the result of subtracting the other from this | |
Basic properties | |
COEF_TYPE | coeff (DEG_TYPE k) const |
the \(k\)th coefficient | |
COEF_TYPE | operator[] (DEG_TYPE k) const |
synonym for coeff(k) | |
DEG_TYPE | degree () const |
the polynomial’s degree (exponent of largest nonzero term) | |
bool | is_zero () const |
returns True if and only if every valid coefficient is zero | |
const COEF_TYPE * | coefficient_array () |
all the coefficients | |
Protected Attributes | |
COEF_TYPE * | coeffs |
list of numerators; index 0 is the constant’s | |
DEG_TYPE | deg |
degree of the polynomial (largest nonzero exponent) | |
DEG_TYPE | size |
number of slots for coefficients | |
Friends | |
I/O | |
ostream & | operator<< (ostream &os, const Dense_Univariate_Integer_Polynomial &p) |
void Dense_Univariate_Integer_Polynomial::add | ( | const Dense_Univariate_Integer_Polynomial & | q | ) |
reasonably efficient, given our dense representation
q | polynomial to add to this |
Definition at line 124 of file dense_univariate_integer_poly.cpp.
void Dense_Univariate_Integer_Polynomial::expand_poly | ( | DEG_TYPE | n | ) |
expand to allow for higher-degree monomials
Do this at the beginning of any computation that could expand the size of the polynomial.
Definition at line 55 of file dense_univariate_integer_poly.cpp.
void Dense_Univariate_Integer_Polynomial::multiply_by_monomial_of_degree | ( | DEG_TYPE | k | ) |
a hopefully efficient multiplication algorithm
Moves exponents from higher degrees to even higher degrees, freeing up space for smaller exponents.
Definition at line 84 of file dense_univariate_integer_poly.cpp.
|
inline |
q | polynomial to add to this |
this
, after adding q
Definition at line 90 of file dense_univariate_integer_poly.hpp.
class Dense_Univariate_Rational_Polynomial |
quick-’n-dirty Dense_Univariate rational polynomial class
deg
smaller than size
, as deg
indexes the monomial of largest degree, which can be at most size - 1
. Definition at line 37 of file dense_univariate_rational_poly.hpp.
Public Member Functions | |
Construction | |
Dense_Univariate_Rational_Polynomial (DEG_TYPE) | |
construct with the number of expected terms | |
Dense_Univariate_Rational_Polynomial (const Dense_Univariate_Rational_Polynomial &) | |
copy constructor | |
Dense_Univariate_Rational_Polynomial (DEG_TYPE, int64_t *, uint64_t *) | |
construct from given data, with the expected number of terms | |
Destruction | |
~Dense_Univariate_Rational_Polynomial () | |
Modification | |
void | expand_poly (DEG_TYPE) |
expand to allow for higher-degree monomials More... | |
void | set_coefficient (DEG_TYPE k, long a, unsigned long b) |
set the coefficient of \(x^k\) to \(\frac{a}{b}\) | |
void | scale_by (COEF_TYPE a) |
multiplies every monomial by a constant integer | |
void | scale_by (COEF_TYPE a, UCOEF_TYPE b) |
multiplies every monomial by a constant rational More... | |
void | scale_by (MPQCOEF_TYPE) |
multiplies every monomial by a constant rational | |
void | multiply_by_monomial_of_degree (DEG_TYPE) |
a hopefully efficient multiplication algorithm More... | |
void | multiply_by (const Dense_Univariate_Rational_Polynomial &) |
highly inefficient polynomial multiplication ( \(O(mn)\)) | |
void | negate () |
negates the numerators | |
void | add (const Dense_Univariate_Rational_Polynomial &) |
adds other to this | |
void | operator+= (const Dense_Univariate_Rational_Polynomial &other) |
alias for add() | |
void | subtract (const Dense_Univariate_Rational_Polynomial &) |
subtracts other from this | |
void | operator-= (const Dense_Univariate_Rational_Polynomial &other) |
alias for subtract() | |
Computation | |
Dense_Univariate_Rational_Polynomial | operator- (const Dense_Univariate_Rational_Polynomial &) const |
returns the difference between this and the other | |
Basic properties | |
bool | is_zero () const |
indicates whether the polynomial is zero | |
MPZCOEF_TYPE | numerator (DEG_TYPE k) const |
returns the \(k\)th numerator | |
MPZCOEF_TYPE | denominator (DEG_TYPE k) const |
returns the \(k\)th denominator | |
DEG_TYPE | degree () const |
returns the polynomial’s degree | |
Protected Attributes | |
MPQCOEF_TYPE * | coeffs |
list of coefficients; index 0 is the constant’s | |
DEG_TYPE | deg |
degree of the polynomial (largest nonzero exponent) | |
DEG_TYPE | size |
number of slots for coefficients | |
Friends | |
I/O | |
ostream & | operator<< (ostream &os, const Dense_Univariate_Rational_Polynomial &p) |
void Dense_Univariate_Rational_Polynomial::expand_poly | ( | DEG_TYPE | n | ) |
expand to allow for higher-degree monomials
You should do this at the beginning of any computation that could expand the size of the polynomial.
Definition at line 67 of file dense_univariate_rational_poly.cpp.
void Dense_Univariate_Rational_Polynomial::multiply_by_monomial_of_degree | ( | DEG_TYPE | k | ) |
a hopefully efficient multiplication algorithm
Moves exponents from higher degrees to even higher degrees, freeing up space for smaller exponents.
Definition at line 102 of file dense_univariate_rational_poly.cpp.
void Dense_Univariate_Rational_Polynomial::scale_by | ( | COEF_TYPE | a, |
UCOEF_TYPE | b | ||
) |
multiplies every monomial by a constant rational
a | rational’s numerator |
b | rational’s denominator |
Definition at line 92 of file dense_univariate_rational_poly.cpp.
class Double_Buffered_Polynomial |
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 110 of file 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 override |
leading monomial – call after sort_by_order()! | |
virtual Prime_Field_Element | leading_coefficient () const override |
leading coefficient – call after sort_by_order()! | |
virtual unsigned | length () const override |
number of monomials | |
virtual bool | is_zero () const override |
is this polynomial zero? | |
virtual bool | can_reduce (Abstract_Polynomial &other) const override |
can this reduce other ? | |
virtual Double_Buffered_Polynomial * | zero_polynomial () const override |
zero polynomial of this type | |
virtual void | set_monomial_ordering (const Monomial_Ordering *order, bool sort_anew=true) override |
set the monomial ordering and sort the polynomials (optionally, but by default) More... | |
Computation | |
virtual Double_Buffered_Polynomial * | monomial_multiple (const Monomial &t) const override |
multiple of this and u | |
virtual Double_Buffered_Polynomial * | scalar_multiple (const Prime_Field_Element &c) const override |
multiple of this and c | |
virtual Mutable_Polynomial & | operator+= (const Abstract_Polynomial &p) override |
add another polynomial | |
virtual Mutable_Polynomial & | operator-= (const Abstract_Polynomial &p) override |
subtract another polynomial | |
virtual void | add_polynomial_multiple (const Prime_Field_Element &a, const Monomial &u, const Abstract_Polynomial &p, bool subtract) override |
add monomial multiple of other | |
virtual void | sort_by_order () override |
sort according to the leading monomial’s ordering More... | |
Iteration | |
virtual DB_Polynomial_Iterator * | new_iterator () const override |
An iterator that poses no risk of modifying the polynomial. | |
virtual DB_Polynomial_Iterator * | new_mutable_iterator () override |
An iterator that may modify the current position. | |
virtual Polynomial_Iterator * | begin () const override |
virtual Polynomial_Iterator * | end () const override |
Modification | |
virtual void | add_last (const Prime_Field_Element &a, const Monomial &t) override |
Attach a new monomial to the tail – check that it belongs at tail! | |
virtual Polynomial_Linked_List * | detach_head () override |
Remove and return the head. | |
![]() | |
Mutable_Polynomial (Polynomial_Ring &R, const 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, const 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) | |
const 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 |
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 |
to iterate over this and possibly change it | |
Additional Inherited Members | |
![]() | |
Polynomial_Ring & | R |
data about polynomial ring | |
Poly_Strategy_Data * | strat = nullptr |
data for computational strategies | |
|
inlineprotected |
Expand buffer b
to hold \( 2n \) elements.
b | the buffer to expand |
n | number of monomials you’d like it to hold now |
This does not test to see if the space is already available.
Definition at line 214 of file polynomial_double_buffered.hpp.
|
overridevirtual |
set the monomial ordering and sort the polynomials (optionally, but by default)
order | new monomial ordering |
sort_anew | whether to sort the polynomial anew |
Implements Abstract_Polynomial.
Definition at line 145 of file polynomial_double_buffered.cpp.
|
overridevirtual |
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 346 of file polynomial_double_buffered.cpp.
class Indeterminate |
Implementation of indeterminates, for easier building of polynomials.
The main purpose of this class is to help make it easier to build polynomials. It is not especially useful otherwise, and is highly inefficient. However, it makes the following possible:
…and the result should be \(x^3y\). Alternately, you could do:
…with the same result. Just be careful in the second case to destroy the evidence.
Definition at line 63 of file indeterminate.hpp.
Public Member Functions | |
Construction | |
Indeterminate (Polynomial_Ring &P, NVAR_TYPE xi) | |
this will correspond to the xi th indeterminate of P . | |
Indeterminate (const Indeterminate &other) | |
copy constructor | |
Indeterminate & | operator= (const Indeterminate &other) |
Basic properties | |
Polynomial_Ring & | base_ring () |
the Polynomial_Ring this lives in | |
NVAR_TYPE | index_in_ring () |
which variable in base_ring() this is | |
Computation | |
Monomial | operator^ (EXP_TYPE a) |
returns this to the a th power | |
Monomial | operator* (Indeterminate y) |
returns the product of this and y | |
Monomial | operator* (Monomial t) |
returns the product of this and t | |
Protected Attributes | |
NVAR_TYPE | i |
which indeterminate in R this is | |
Polynomial_Ring * | R |
the ring this lives in | |
Friends | |
I/O | |
ostream & | operator<< (ostream &, Indeterminate &) |
prints this with the appropriate name | |
class Monomial |
Implementation of monomials.
A monomial is a product of powers, for instance \(x_1^2x_3\). (We do not include coefficients in our definition of monomials.) This class encapsulates basic monomial functionality necessary for computing Gröbner bases.
Monomial
, be sure to use the initialization functions to format and allocate space.Definition at line 69 of file monomial.hpp.
Public Member Functions | |
Construction | |
void | common_initialization (const Monomial_Ordering *ord=nullptr) |
things all Monomial initializers must do | |
void | initialize_exponents (NVAR_TYPE number_of_vars) |
allocates memory for exponents This is useful when you want to allocate an array of monomials. | |
void | deinitialize () |
deallocates memory for exponents This is useful when you want to deallocate an array of monomials. | |
void | set_exponent (NVAR_TYPE i, DEG_TYPE e) |
change \(i\)th exponent to \(e\) | |
Monomial (NVAR_TYPE number_of_vars, const Monomial_Ordering *order=generic_grevlex_ptr) | |
The first constructor is equivalent to instantiating 1. | |
Monomial (const Monomial &other) | |
Copy constructor, allocates new space for exponents. | |
Monomial (initializer_list< EXP_TYPE > powers, const Monomial_Ordering *order=generic_grevlex_ptr) | |
Constructor from initializer list. More... | |
Monomial (NVAR_TYPE size, const EXP_TYPE *powers, const Monomial_Ordering *order=generic_grevlex_ptr) | |
Constructor from array of exponents. More... | |
Destruction | |
~Monomial () | |
Destructor deallocates exponents. | |
Basic properties | |
The following functions give information about the monomial, but do not modify it. | |
NVAR_TYPE | num_vars () const |
number of variables | |
bool | is_one () const |
all exponents 0? | |
DEG_TYPE | degree (NVAR_TYPE i) const |
Degree of \(i\)th variable. | |
DEG_TYPE | operator[] (NVAR_TYPE i) const |
Degree of \(i\)th variable. Synonymous with degree(). | |
DEG_TYPE | total_degree (NVAR_TYPE m=0) const |
Sum of exponents of the first m variables. More... | |
DEG_TYPE | weighted_degree (const WT_TYPE *weights, NVAR_TYPE m=0) const |
const EXP_TYPE * | log () const |
Direct access to the exponents, for whatever reason. | |
Comparison | |
Compares this monomial to another. | |
const Monomial_Ordering * | monomial_ordering () const |
the Monomial_Ordering associated with this Monomial | |
Monomial_Order_Data * | monomial_ordering_data () const |
the Monomial_Order_Data associated with this Monomial | |
void | set_monomial_ordering (const Monomial_Ordering *mord) |
sets the Monomial_Ordering associated with this Monomial | |
void | set_ordering_data (Monomial_Order_Data *mordat) |
sets the Monomial_Order_Data associated with this Monomial | |
void | set_ordering_degree (DEG_TYPE d) |
sets the ordering degree for this Monomial | |
DEG_TYPE | ordering_degree () const |
returns the ordering degree for this Monomial | |
bool | operator== (const Monomial &other) const |
equal/alike? | |
bool | operator!= (const Monomial &other) const |
unequal/unlike? | |
bool | is_coprime (const Monomial &other) const |
true iff this has no common factor with other . | |
int | cmp (const Monomial &u) const |
Returns 0 if like, negative if smaller. | |
bool | is_like (const Monomial &other) const |
Have same variables, same powers? Synonymous with operator==(). | |
bool | like_multiple (const Monomial &u, const Monomial &v) const |
is this like \(uv\)? | |
bool | like_multiple (EXP_TYPE *e, const Monomial &v) const |
is this like \(uv\)? (where \(u\) is a monomial whose exponents are those of e | |
bool | larger_than (const Monomial &) const |
compares monomial with \(u\) according to monomial ordering | |
bool | operator> (const Monomial &u) const |
Compares monomial with \(u\) according to monomial ordering. | |
bool | operator>= (const Monomial &u) const |
Compares monomial with \(u\) according to monomial ordering. | |
bool | operator< (const Monomial &u) const |
Compares monomial with \(u\) according to monomial ordering. | |
bool | operator<= (const Monomial &u) const |
Compares monomial with \(u\) according to monomial ordering. | |
bool | larger_than_multiple (const Monomial &u, const Monomial &v) const |
Compares monomial with \(uv\) according to monomial ordering. | |
bool | divisible_by (const Monomial &other) const |
Divisible by other ? | |
bool | operator| (const Monomial &other) const |
operator for divisibility | |
Computation | |
Computes something, and may modify | |
Monomial & | operator= (const Monomial &other) |
assignment | |
Monomial & | operator*= (const Monomial &other) |
Multiply this by other . | |
Monomial | operator* (const Monomial &other) const |
Return result of this by other . | |
bool | operator/= (const Monomial &other) |
divide this by other More... | |
Monomial | lcm (const Monomial &u) const |
Least common multiple: largest exponents. | |
Monomial | gcd (const Monomial &u) const |
Greatest common divisor: smallest exponents. | |
Monomial | colon (const Monomial &u) const |
colon operator: exponents needed to make \(u\) divisible by this | |
Memory management | |
void * | operator new (size_t) |
requests memory form Monomial's Grading_Order_Data_Allocator | |
void | operator delete (void *) |
returns data to Monomial's Grading_Order_Data_Allocator | |
Protected Attributes | |
EXP_TYPE * | exponents |
has size n | |
uint64_t | mask |
divisibility mask (up to 64 variables) | |
NVAR_TYPE | n |
number of variables | |
DEG_TYPE | ord_degree |
degree associated with monomial ordering (used for faster comparisons) | |
const Monomial_Ordering * | ordering |
Monomial_Ordering associated with this polynomial. | |
Monomial_Order_Data * | ordering_data |
optional data for a monomial ordering | |
I/O | |
void | print (bool=true, ostream &=cout, const string *names=nullptr) const |
prints the monomial to the give stream with the given names; adds a newline if the boolean is true | |
void | printlncout () |
equivalent to print() with default values | |
ostream & | operator<< (ostream &, const Monomial &u) |
essentially u.print(false, ostream) | |
Monomial::Monomial | ( | initializer_list< EXP_TYPE > | powers, |
const Monomial_Ordering * | order = generic_grevlex_ptr |
||
) |
Constructor from initializer list.
powers | the Monomial’s exponents |
order | a Monomial_Ordering in the appropriate number of variables |
The list should contains the powers of the exponents, in order.
Definition at line 120 of file monomial.cpp.
Monomial::Monomial | ( | NVAR_TYPE | size, |
const EXP_TYPE * | powers, | ||
const Monomial_Ordering * | order = generic_grevlex_ptr |
||
) |
Constructor from array of exponents.
size | number of variables in the Monomial |
powers | array of exponents — use at least n unless you like to crash |
order | a Monomial_Ordering for n variables |
Copies exponents so you can reuse yours.
Definition at line 147 of file monomial.cpp.
bool Monomial::operator/= | ( | const Monomial & | other | ) |
divide this
by other
other | Monomial to divide this by |
this
is divisible by other. See divisible_by(), which is the tool to use. true
if and only if this
and other
have the same number of variables Definition at line 351 of file monomial.cpp.
DEG_TYPE Monomial::total_degree | ( | NVAR_TYPE | m = 0 | ) | const |
Sum of exponents of the first m
variables.
If m
is zero (default), computes for all variables.
m | compute up to m indeterminates; the default value of 0 computes all |
Definition at line 190 of file monomial.cpp.
DEG_TYPE Monomial::weighted_degree | ( | const WT_TYPE * | weights, |
NVAR_TYPE | m = 0 |
||
) | const |
m
exponents, using given weights
weights | the weights for each indeterminate: the first weight will be multiplied by the first exponent, the second weight by the second exponent, and so forth |
m | compute up to m indeterminates; the default value of 0 computes all |
If weights
is nullptr
then returns total_degree(m). If m
is zero (default), computes for all indeterminates.
Definition at line 199 of file monomial.cpp.
class Monomial_Ideal |
A class for monomial ideals.
Mostly a convenience class to encapsulate basic operations. I am in the process of moving some functions outside this class into it.
Definition at line 78 of file monomial_ideal.hpp.
Public Member Functions | |
Construction | |
Monomial_Ideal (NVAR_TYPE nvars) | |
Creates a zero ideal. | |
Monomial_Ideal (NVAR_TYPE nvars, const list< Monomial > &G, const Dense_Univariate_Integer_Polynomial *h_old=nullptr, const WT_TYPE *h_grading=nullptr) | |
Copies basis . If you supply a Hilbert function that is not computed according to the standard grading, please supply the grading as h_grading . | |
Monomial_Ideal (NVAR_TYPE nvars, const vector< Monomial > &G, const Dense_Univariate_Integer_Polynomial *h_old=nullptr, const WT_TYPE *h_grading=nullptr) | |
Copies basis . If you supply a Hilbert function that is not computed according to the standard grading, please supply the grading as h_grading . | |
Monomial_Ideal (const Monomial_Ideal &I) | |
copy constructor | |
Destruction | |
~Monomial_Ideal () | |
destroys the Hilbert data, but not the grading. | |
Basic properties | |
The following functions give information about the ideal, but do not modify it. | |
NVAR_TYPE | number_of_variables () const |
number of variables in each Monomial | |
unsigned | size () const |
number of generators | |
const list< Monomial > & | generators () const |
returns the list of generators | |
unsigned | dimension () |
returns the dimension of the ideal | |
const map< DEG_TYPE, unsigned long > & | inc_betti (const WT_TYPE *grading=nullptr) |
incremental Betti numbers when adding the last Monomial in this ideal | |
Dense_Univariate_Integer_Polynomial * | hilbert_numerator (const WT_TYPE *grading=nullptr) |
Dense_Univariate_Integer_Polynomial * | reduced_hilbert_numerator (const WT_TYPE *grading=nullptr) |
the reduced Hilbert Numerator More... | |
Dense_Univariate_Rational_Polynomial * | hilbert_poly () |
Computation | |
Monomial_Ideal * | colon (const Monomial &t) const |
returns the ideal \(J=\{u:t \forall u\in I\}\), where \(I\) is this More... | |
void | colon_with (const Monomial &t) |
replaces the generators of this with those of the ideal \(J=\{u:t \forall u\in I\}\), where \(I\) is this More... | |
Modification | |
void | add_generator (const Monomial &t) |
adds t to the basis | |
void | remove_newest () |
removes the newest monomial from the basis | |
void | forget_hilbert_numerator () |
sets numerator to nullptr | |
void | set_hilbert_numerator (Dense_Univariate_Integer_Polynomial *h) |
sets numerator to given value; only use when you know this is true! | |
Protected Attributes | |
const WT_TYPE * | current_grading |
the most recent grading for the Hilbert functions; nullptr implies standard grading | |
list< Monomial > | gens |
the ideal's generators | |
Dense_Univariate_Integer_Polynomial * | hGradNum |
the ideal's Hilbert numerator, according to current_grading | |
Dense_Univariate_Integer_Polynomial * | hGradRedNum |
the ideal's reduced Hilbert numerator, according to current_grading | |
Dense_Univariate_Integer_Polynomial * | hNum |
the ideal's Hilbert numerator, standard grading | |
Dense_Univariate_Rational_Polynomial * | hPol |
the ideal's Hilbert polynomial – standard grading only | |
Dense_Univariate_Integer_Polynomial * | hRedNum |
the ideal's reduced Hilbert numerator, standard grading | |
map< DEG_TYPE, unsigned long > | ibmap |
the ideal's incremental Betti numbers | |
NVAR_TYPE | n |
number of variables the monomials of this ideal have | |
Friends | |
I/O | |
ostream & | operator<< (ostream &, const Monomial_Ideal &) |
|
inline |
returns the ideal \(J=\{u:t \forall u\in I\}\), where \(I\) is this
t | Monomial used to form the colon ideal |
This does not recompute Hilbert data even if already known. It is probably better to do that explicitly, anyhow.
Definition at line 321 of file monomial_ideal.hpp.
|
inline |
replaces the generators of this
with those of the ideal \(J=\{u:t \forall u\in I\}\), where \(I\) is this
t | Monomial used to form the colon ideal |
Definition at line 331 of file monomial_ideal.hpp.
|
inline |
grading | grading to use for computing this; use nullptr for standard, which is the default |
Definition at line 227 of file monomial_ideal.hpp.
|
inline |
A “Hilbert Polynomial” does not exist in the non-standard graded case, so there is no option to supply a grading here, and if the Hilbert numerators have been computed for a different grading, this function re-computes them for the standard grading, without however losing the ones computed for the non-standard grading.
Definition at line 291 of file monomial_ideal.hpp.
|
inline |
the reduced Hilbert Numerator
grading | grading to use for computing this; use nullptr for standard, which is the default |
Definition at line 259 of file monomial_ideal.hpp.
class Monomial_Ideal_Variables_Exception |
class Monomial_Node |
Tool for Polynomial_Linked_List.
Each node in a linked list polynomial contains both the coefficient and the monomial.
Definition at line 42 of file polynomial_linked_list.hpp.
Public Member Functions | |
Construction | |
Monomial_Node (const Prime_Field_Element &a, const Monomial &u) | |
Monomial u with coefficient a. Both are copied, and can be deleted. | |
Monomial_Node (Prime_Field &F, const Monomial &u) | |
Monomial u (copied) with coefficient 1. | |
Basic properties | |
Monomial & | monomial () |
This term’s monomial, or power product. The coefficient is not included. | |
Prime_Field_Element & | coefficient () |
This term’s coefficient. | |
Memory management | |
void * | operator new (size_t) |
requests memory form Monomial_Node's Grading_Order_Data_Allocator | |
void | operator delete (void *) |
returns data to Monomial_Node's Grading_Order_Data_Allocator | |
Protected Attributes | |
Prime_Field_Element | c |
the monomial’s coefficient | |
Monomial_Node * | next |
for linking | |
Monomial_Node * | prev |
for linking | |
Monomial | t |
the monomial in this node | |
Friends | |
Iteration | |
class | LLPolynomial_Iterator |
class | Polynomial_Linked_List |
class Mutable_Polynomial |
Polynomials that need arithmetic typically descend from this class.
This class extends Abstract_Polynomial to allow for basic arithmetic of a polynomial.
Definition at line 305 of file polynomial.hpp.
Public Member Functions | |
Construction | |
Mutable_Polynomial (Polynomial_Ring &R, const Monomial_Ordering *ordering=generic_grevlex_ptr) | |
constructor | |
Destruction | |
virtual | ~Mutable_Polynomial ()=0 |
destructor | |
Computation | |
virtual Mutable_Polynomial * | zero_polynomial () const =0 |
zero polynomial of this type | |
virtual Mutable_Polynomial & | operator+= (const Abstract_Polynomial &)=0 |
add another polynomial | |
virtual Mutable_Polynomial & | operator-= (const Abstract_Polynomial &)=0 |
subtract another polynomial | |
virtual void | add_polynomial_multiple (const Prime_Field_Element &, const Monomial &, const Abstract_Polynomial &, bool subtract=false)=0 |
add monomial multiple of other | |
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 | |
virtual Mutable_Polynomial * | monomial_multiple (const Monomial &) const =0 |
multiple of this and u | |
virtual Mutable_Polynomial * | scalar_multiple (const Prime_Field_Element &) const =0 |
multiple of this and c | |
Iteration | |
virtual Mutable_Polynomial_Iterator * | new_mutable_iterator ()=0 |
An iterator that may modify the current position. | |
Modification | |
virtual Mutable_Polynomial * | detach_head ()=0 |
Remove and return the head. | |
virtual void | add_last (const Prime_Field_Element &, const Monomial &)=0 |
Attach a new monomial to the tail – check that it belongs at tail! | |
![]() | |
Abstract_Polynomial (Polynomial_Ring &ring, const 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) | |
const Monomial_Ordering * | monomial_ordering () const |
reports leading monomial’s monomial ordering | |
virtual Monomial & | leading_monomial () const =0 |
leading monomial – call after sort_by_order()! | |
virtual Prime_Field_Element | leading_coefficient () const =0 |
leading coefficient – call after sort_by_order()! | |
virtual unsigned | length () const =0 |
number of monomials | |
virtual bool | is_zero () const =0 |
is this polynomial zero? | |
virtual bool | can_reduce (Abstract_Polynomial &other) const |
can this reduce other ? | |
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 |
void | set_strategy (Poly_Strategy_Data *psd) |
sets the polynomial’s strategy to psd | |
virtual void | set_monomial_ordering (const Monomial_Ordering *order, bool sort_anew=true)=0 |
set the monomial ordering and sort the polynomials (optionally, but by default) More... | |
virtual void | sort_by_order ()=0 |
sort according to the leading monomial’s ordering More... | |
virtual Polynomial_Iterator * | new_iterator () const =0 |
An iterator that poses no risk of modifying the polynomial. | |
virtual Polynomial_Iterator * | begin () const =0 |
virtual Polynomial_Iterator * | end () const =0 |
virtual void | print (ostream &os=cout) const |
virtual void | println (ostream &os=cout) const |
virtual void | printlncout () const |
Additional Inherited Members | |
![]() | |
Polynomial_Ring & | R |
data about polynomial ring | |
Poly_Strategy_Data * | strat = nullptr |
data for computational strategies | |
class Polynomial_Geobucket |
Implementation of geobuckets.
NUM_BUCKETS
. Definition at line 114 of file polynomial_geobucket.hpp.
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 () override |
sorts each geobucket More... | |
virtual void | set_monomial_ordering (const Monomial_Ordering *order, bool sort_anew=true) override |
sets the monomial ordering for each bucket More... | |
virtual Monomial & | leading_monomial () const override |
returns the leading monomial More... | |
virtual Prime_Field_Element | leading_coefficient () const override |
returns the leading coefficient More... | |
virtual unsigned | length () const override |
how long is this polynomial? More... | |
virtual Polynomial_Linked_List * | zero_polynomial () const override |
creates and returns a geobucket initialized to zero More... | |
virtual bool | is_zero () const override |
is this polynomial zero? More... | |
virtual bool | can_reduce (Abstract_Polynomial &other) const override |
Whether this can reduce other . A geobucket should not generally be used to reduce other polynomials, so avoid this like the plague. | |
virtual Geobucket_Iterator * | new_iterator () const override |
An iterator that poses no risk of modifying the polynomial. | |
virtual Polynomial_Iterator * | begin () const override |
virtual Polynomial_Iterator * | end () const override |
virtual Geobucket_Iterator * | new_mutable_iterator () override |
An iterator that may modify the current position. | |
Computation | |
void | recompute_leading_monomial () |
You will need to call this after every operation that might modify the leading term. More... | |
virtual Polynomial_Geobucket * | monomial_multiple (const Monomial &t) const override |
Returns \(\texttt{this}\times t\). | |
virtual Polynomial_Geobucket * | scalar_multiple (const Prime_Field_Element &a) const override |
Returns \(\texttt{this}\times a\). | |
virtual Polynomial_Geobucket & | operator+= (const Abstract_Polynomial &g) override |
Adds \(g\) to this . Recomputes leading monomial. | |
virtual Polynomial_Geobucket & | operator-= (const Abstract_Polynomial &g) override |
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) override |
Adds \(bug\) to this . Recomputes leading monomial. | |
virtual Polynomial_Linked_List * | detach_head () override |
Detaches the head and recomputes leading monomial. | |
virtual void | add_last (const Prime_Field_Element &a, const Monomial &t) override |
Adds \(at\) as a monomial of this . (Not necessarily the last!) More... | |
Abstract_Polynomial * | canonicalize (bool constant_result=false) |
returns a copy of this in a simplified linear form More... | |
![]() | |
Mutable_Polynomial (Polynomial_Ring &R, const 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, const 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) | |
const 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 |
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\). More... | |
Protected Attributes | |
Polynomial_Linked_List ** | buckets |
Array of ptrs to linked list polys; most initialized to nullptr . | |
![]() | |
Polynomial_Ring & | R |
data about polynomial ring | |
Poly_Strategy_Data * | strat = nullptr |
data for computational strategies | |
Friends | |
class | Geobucket_Iterator |
to iterate over this and possibly change it | |
I/O | |
ostream & | operator<< (ostream &, const Polynomial_Geobucket &) |
prints the geobucket in an explicitly geobucket form More... | |
void | print (unsigned i, ostream &os=cout) const |
prints the \(i\)th bucket More... | |
virtual void | print (ostream &os=cout) const override |
prints the polynomial with an explicitly bucket form More... | |
|
overridevirtual |
Adds \(at\) as a monomial of this
. (Not necessarily the last!)
a | coefficient of the term to add |
t | Monomial of the term to add |
bucket[0]
). Implements Mutable_Polynomial.
Definition at line 363 of file polynomial_geobucket.cpp.
Abstract_Polynomial * Polynomial_Geobucket::canonicalize | ( | bool | constant_result = false | ) |
returns a copy of this
in a simplified linear form
constant_result | whether you want a Constant_Polynomial |
If constant_result
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.)
this
in a simplified linear form Definition at line 378 of file polynomial_geobucket.cpp.
|
overridevirtual |
is this polynomial zero?
true
iff all the buckets are nullptr
or themselves zero Implements Abstract_Polynomial.
Definition at line 201 of file polynomial_geobucket.cpp.
|
overridevirtual |
returns the leading coefficient
Implements Abstract_Polynomial.
Definition at line 185 of file polynomial_geobucket.cpp.
|
overridevirtual |
returns the leading monomial
Implements Abstract_Polynomial.
Definition at line 181 of file polynomial_geobucket.cpp.
|
overridevirtual |
how long is this polynomial?
Implements Abstract_Polynomial.
Definition at line 189 of file polynomial_geobucket.cpp.
|
inlineprotected |
Log-length of \(i\), used to select a bucket for a polynomial of length \(i\).
i | number of terms we need space for |
Definition at line 302 of file polynomial_geobucket.hpp.
void Polynomial_Geobucket::print | ( | unsigned | i, |
ostream & | os = cout |
||
) | const |
prints the \(i\)th bucket
i | which bucket to print |
os | where to print the 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 399 of file polynomial_geobucket.cpp.
|
overridevirtual |
prints the polynomial with an explicitly bucket form
os | where to print the polynomial |
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 403 of file polynomial_geobucket.cpp.
void Polynomial_Geobucket::recompute_leading_monomial | ( | ) |
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 214 of file polynomial_geobucket.cpp.
|
overridevirtual |
sets the monomial ordering for each bucket
order | the new monomial ordering |
sort_anew | whether to re-sort the polynomials |
Implements Abstract_Polynomial.
Definition at line 174 of file polynomial_geobucket.cpp.
|
overridevirtual |
sorts each geobucket
Implements Abstract_Polynomial.
Definition at line 168 of file polynomial_geobucket.cpp.
|
overridevirtual |
creates and returns a geobucket initialized to zero
Implements Mutable_Polynomial.
Definition at line 197 of file polynomial_geobucket.cpp.
|
friend |
prints the geobucket in an explicitly geobucket form
Definition at line 417 of file polynomial_geobucket.cpp.
class Polynomial_Linked_List |
Polynomials represented as a doubly linked list.
Definition at line 171 of file polynomial_linked_list.hpp.
Public Member Functions | |
Construction | |
Polynomial_Linked_List (Polynomial_Ring &R, const Monomial_Ordering *order=generic_grevlex_ptr) | |
initialize to zero | |
Polynomial_Linked_List (Polynomial_Ring &R, const Monomial &t, const Monomial_Ordering *order=nullptr) | |
initialize to monomial; monomial is copied | |
Polynomial_Linked_List (Polynomial_Ring &R, const Prime_Field_Element &c, const Monomial &t, const Monomial_Ordering *order=nullptr) | |
initialize to monomial and coefficient; monomial is copied | |
Polynomial_Linked_List (Polynomial_Ring &R, Monomial_Node *node, const Monomial_Ordering *order=nullptr) | |
initialize to given monomial node: nothing is copied | |
Polynomial_Linked_List (const Polynomial_Linked_List &other) | |
copy constructor: deep copy of monomials | |
Polynomial_Linked_List (const Abstract_Polynomial &p) | |
constructor from abstract polynomial: deep copy of monomials | |
Destruction | |
virtual | ~Polynomial_Linked_List () |
deletes all monomial nodes | |
Basic properties | |
virtual bool | is_zero () const override |
true iff the first node in the list is nullptr or has zero coeff | |
virtual Monomial & | leading_monomial () const override |
Returns the leading monomial — call sort_by_order() first! | |
virtual Prime_Field_Element | leading_coefficient () const override |
Returns the leading coefficient — call sort_by_order first! | |
virtual unsigned | length () const override |
Returns the number of polynomials in the list. | |
virtual void | set_monomial_ordering (const Monomial_Ordering *ord, bool sort_anew=true) override |
set the monomial ordering and sort the polynomials (optionally, but by default) More... | |
Computation | |
virtual Polynomial_Linked_List * | zero_polynomial () const override |
Returns as simple a zero polynomial as I can muster, short of this being nullptr . | |
virtual Polynomial_Linked_List * | monomial_multiple (const Monomial &u) const override |
Returns a new polynomial whose value is \(\textit{this}\times u\). | |
virtual Polynomial_Linked_List * | scalar_multiple (const Prime_Field_Element &c) const override |
Returns a new polynomial whose value is \(\textit{this}\times c\). | |
virtual Polynomial_Linked_List & | operator+= (const Abstract_Polynomial &other) override |
Adds other to this , and returns the result. | |
virtual Polynomial_Linked_List & | operator-= (const Abstract_Polynomial &other) override |
Subtracts other from this , and returns the result. | |
virtual void | add_polynomial_multiple (const Prime_Field_Element &a, const Monomial &t, const Abstract_Polynomial &q, bool subtract) override |
"Fast" addition of \(atq\) to this . More... | |
virtual void | sort_by_order () override |
Sort by specified weight order. | |
Iteration | |
virtual LLPolynomial_Iterator * | new_iterator () const override |
an iterator that poses no risk of modifying the polynomial | |
virtual Polynomial_Iterator * | begin () const override |
an iterator that poses no risk of modifying the polynomial | |
virtual Polynomial_Iterator * | end () const override |
an iterator that poses no risk of modifying the polynomial | |
virtual LLPolynomial_Iterator * | new_mutable_iterator () override |
An iterator that may modify the current position. | |
Modification | |
virtual Polynomial_Linked_List * | detach_head () override |
Detach and return leading term. | |
virtual void | add_last (const Prime_Field_Element &c, const Monomial &t) override |
Add this monomial as the last leading term. | |
![]() | |
Mutable_Polynomial (Polynomial_Ring &R, const 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, const 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) | |
const Monomial_Ordering * | monomial_ordering () const |
reports leading monomial’s monomial ordering | |
virtual bool | can_reduce (Abstract_Polynomial &other) const |
can this reduce other ? | |
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 |
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 Attributes | |
Monomial_Node * | head |
first monomial in the list, returned by leading_monomial() | |
![]() | |
Polynomial_Ring & | R |
data about polynomial ring | |
Poly_Strategy_Data * | strat = nullptr |
data for computational strategies | |
Friends | |
class | LLPolynomial_Iterator |
to iterate over this and possibly change it | |
|
overridevirtual |
"Fast" addition of \(atq\) to this
.
If subtract==true
, subtract instead.
a | coefficient of the term to multiply to q |
t | Monomial of the term to multiply to q |
q | polynomial to add to this , after multiplying q by \( at \) |
subtract | whether to add instead of subtract |
Implements Mutable_Polynomial.
Definition at line 389 of file polynomial_linked_list.cpp.
|
overridevirtual |
set the monomial ordering and sort the polynomials (optionally, but by default)
order | new monomial ordering |
sort_anew | whether to sort the polynomial anew |
Implements Abstract_Polynomial.
Definition at line 232 of file polynomial_linked_list.cpp.
class Polynomial_Ring |
Encapsulates information about a polynomial ring for easy access: ground field, number of indeterminates, ….
Definition at line 42 of file polynomial_ring.hpp.
Public Member Functions | |
Construction | |
Polynomial_Ring (NVAR_TYPE num_vars, Prime_Field &field, string *var_names=nullptr) | |
Initialize the ring for the given field and number of indeterminates. More... | |
Destruction | |
~Polynomial_Ring () | |
Deletes the names. | |
Modification | |
bool | set_names (string *new_names, NVAR_TYPE length) |
sets the names of the indeterminates, if you do not want the default More... | |
Basic properties | |
virtual NVAR_TYPE | number_of_variables () const |
number of indeterminates (variables) in the ring | |
virtual Indeterminate * | indeterminates () |
an array of the ring’s indeterminates; use only to biuld polynomials | |
virtual Prime_Field & | ground_field () const |
ground field | |
virtual const string | name (NVAR_TYPE i) const |
name of the \(i\)th indeterminate | |
virtual const string * | name_list () const |
names of all the variabiles | |
Protected Attributes | |
Prime_Field & | F |
the ring's ground field | |
NVAR_TYPE | n |
the number of indeterminates for every monomial in the ring More... | |
string * | names |
optional names for the variables | |
Polynomial_Ring::Polynomial_Ring | ( | NVAR_TYPE | num_vars, |
Prime_Field & | field, | ||
string * | var_names = nullptr |
||
) |
Initialize the ring for the given field and number of indeterminates.
The array of names is copied, so you can reuse or discard the memory as you prefer.
num_vars | number of indeterminates in this Polynomial_Ring |
field | ground field of this Polynomial_Ring |
var_names | an optional array of num_vars names to assign to the indeterminates |
Definition at line 25 of file polynomial_ring.cpp.
bool Polynomial_Ring::set_names | ( | string * | new_names, |
NVAR_TYPE | length | ||
) |
sets the names of the indeterminates, if you do not want the default
Returns True
if and only if successful. The names are not copied, so please do not discard them until you are done with this ring, or else have reassigned the names.
length
is not the same as the number of indeterminates, things can go very, very badly. new_names | names for the indeterminates |
length | number of names in new_names |
Definition at line 40 of file polynomial_ring.cpp.
|
protected |
the number of indeterminates for every monomial in the ring
Definition at line 102 of file polynomial_ring.hpp.
Computes the generators of an ideal and a new generator, given the ideal's generators. No monomial ideal machinery required.
U | generators of ideal we want to “colonize” |
t | Monomial that is “colonizing” the ideal generated by U |
U
by t
( \( U:(t) \)) Definition at line 42 of file monomial_ideal.cpp.
list<Abstract_Polynomial *> cyclic_n | ( | NVAR_TYPE | n, |
Prime_Field & | F, | ||
bool | homog, | ||
Monomial_Ordering * | mord = generic_grevlex_ptr |
||
) |
generates the Cyclic- \( n \) system
n | number of variables |
F | ground field |
homog | whether to homogenize the system (affects only the last polynomial) |
mord | a Monomial_Ordering |
Generates the Cyclic- \( n \) system,
\[ x_0 + x_1 + ... + x_n,\\ x_0 x_1 + x_1 x_2 + x_2 x_3 + ... + x_n x_1,\\ x_0 x_1 x_2 + x_1 x_2 x_3 + x_2 x_3 x_4 + x_n x_1 x_2,\\ \ldots\\ x_0 x_1 \ldots x_n - 1.\]
Use \(n > 2\). If homog
is true
, the last monomial is \(h^5\) instead of 1.
Definition at line 57 of file cyclic_n.hpp.