Gröbner basis project
Codebase for research into Gröbner basis computation
Polynomials

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< Monomialcolon_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...
 

Detailed Description

classes related to the structure of polynomials


Class Documentation

◆ Abstract_Polynomial

class Abstract_Polynomial

The general class of a polynomial.

Author
John Perry
Date
2015

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).

Warning
Monomials should have the same number of variables, and coefficients should all come from the same field. Behavior is undefined if these assumptions are violated. From an algebraic point of view, it doesn’t make much sense to violate them, anyway; (in/pro)ject into a different ring if you want to screw around like this.
Examples:
test_cyclicn.cpp, test_dynamic.cpp, and user_interface.cpp.

Definition at line 101 of file polynomial.hpp.

Inheritance diagram for Abstract_Polynomial:
Constant_Polynomial Mutable_Polynomial Double_Buffered_Polynomial Polynomial_Geobucket Polynomial_Linked_List

Public Member Functions

Construction
 Abstract_Polynomial (Polynomial_Ring &ring, const Monomial_Ordering *ordering)
 
Destruction
virtual ~Abstract_Polynomial ()
 
Basic properties
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)
 
const Monomial_Orderingmonomial_ordering () const
 reports leading monomial’s monomial ordering
 
virtual Monomialleading_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_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
 
Computation
virtual Abstract_Polynomialzero_polynomial () const =0
 new zero polynomial of this same type
 
virtual Abstract_Polynomialmonomial_multiple (const Monomial &) const =0
 multiple of this and \(u\)
 
virtual Abstract_Polynomialscalar_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_Iteratornew_iterator () const =0
 An iterator that poses no risk of modifying the polynomial.
 
virtual Polynomial_Iteratorbegin () const =0
 
virtual Polynomial_Iteratorend () const =0
 

Protected Attributes

Polynomial_RingR
 data about polynomial ring
 
Poly_Strategy_Datastrat = 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
 

Constructor & Destructor Documentation

◆ Abstract_Polynomial()

Abstract_Polynomial::Abstract_Polynomial ( Polynomial_Ring ring,
const Monomial_Ordering ordering 
)
inline
Parameters
ringthe polynomial ring in which this polynomial will reside
orderingthe monomial ordering that first sorts the monomials

Definition at line 110 of file polynomial.hpp.

Member Function Documentation

◆ set_monomial_ordering()

virtual void Abstract_Polynomial::set_monomial_ordering ( const Monomial_Ordering order,
bool  sort_anew = true 
)
pure virtual

set the monomial ordering and sort the polynomials (optionally, but by default)

Parameters
ordernew monomial ordering
sort_anewwhether to sort the polynomial anew
Warning
In most cases you will want to sort anew immediately after setting the ordering. Otherwise, the monomials may be in the wrong order! That is therefore the default behavior of this function, but in case you don’t want to sort, that option is provided.

Implemented in Polynomial_Linked_List, Constant_Polynomial, Polynomial_Geobucket, and Double_Buffered_Polynomial.

◆ sort_by_order()

virtual void Abstract_Polynomial::sort_by_order ( )
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.

Examples:
user_interface.cpp.

◆ weighted_degree()

DEG_TYPE Abstract_Polynomial::weighted_degree ( const WT_TYPE *  w = nullptr) const
virtual
Returns
largest weighted sum of exponents for any monomial
Parameters
wweights to use for weighted degree

Equivalent to standard_degree() if w == nullptr.

Definition at line 108 of file polynomial.cpp.

◆ Constant_Polynomial

class Constant_Polynomial

A Constant_Polynomial is a polynomial that should not change.

Author
John Perry
Date
2015

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).

Examples:
test_4by4.cpp, test_cab_es1.cpp, test_cab_es2.cpp, test_cab_es4.cpp, test_cab_es5.cpp, test_cab_es6.cpp, test_cab_es9.cpp, test_cyclic4.cpp, test_cyclicn.cpp, test_dynamic.cpp, and user_interface.cpp.

Definition at line 87 of file polynomial_array.hpp.

Inheritance diagram for Constant_Polynomial:
Abstract_Polynomial

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 Monomialleading_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_Polynomialzero_polynomial () const override
 
virtual Constant_Polynomialmonomial_multiple (const Monomial &t) const override
 
virtual Constant_Polynomialscalar_multiple (const Prime_Field_Element &c) const override
 
Iteration
virtual Constant_Polynomial_Iteratornew_iterator () const override
 an iterator that poses no risk of modifying the polynomial
 
virtual Polynomial_Iteratorbegin () const override
 iterator to the first element
 
virtual Polynomial_Iteratorend () const override
 iterator to the last element
 
Serialization
uint64_t * serialized (uint64_t &size)
 
- Public Member Functions inherited from Abstract_Polynomial
 Abstract_Polynomial (Polynomial_Ring &ring, const 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)
 
const Monomial_Orderingmonomial_ordering () const
 reports leading monomial’s monomial ordering
 
virtual bool can_reduce (Abstract_Polynomial &other) const
 can this reduce other?
 
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
 
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_ElementA
 array of coefficients, in one-to-one correspondence with M
 
unsigned head
 location of leading term in array (always farther left)
 
MonomialM
 array of monomials, in one-to-one correspondence with A
 
unsigned m
 position after last monomial
 
- Protected Attributes inherited from Abstract_Polynomial
Polynomial_RingR
 data about polynomial ring
 
Poly_Strategy_Datastrat = 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
 

Constructor & Destructor Documentation

◆ Constant_Polynomial() [1/3]

Constant_Polynomial::Constant_Polynomial ( unsigned  length,
Polynomial_Ring R,
const Monomial mons,
const Prime_Field_Element coeffs,
const Monomial_Ordering order = nullptr 
)
Parameters
lengthhow long this should be
Rparent ring
monsarray of Monomial to populate the terms
coeffsarray of coefficients to populate the terms, in same order as mons
ordermonomial 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() [2/3]

Constant_Polynomial::Constant_Polynomial ( Polynomial_Ring R,
const list< Monomial > &  mons,
const list< Prime_Field_Element > &  coeffs,
const Monomial_Ordering order = nullptr 
)
Parameters
Rparent ring
monslist of Monomial to populate the terms
coeffslist of coefficients to populate the terms, in same order as mons
ordermonomial 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() [3/3]

Constant_Polynomial::Constant_Polynomial ( unsigned  length,
Polynomial_Ring R,
const Monomial_Ordering order = generic_grevlex_ptr 
)
Parameters
lengthhow long this should be
Rparent ring
ordermonomial 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.

Member Function Documentation

◆ is_zero()

bool Constant_Polynomial::is_zero ( ) const
overridevirtual
Returns
is this polynomial zero?

Implements Abstract_Polynomial.

Definition at line 209 of file polynomial_array.cpp.

◆ leading_coefficient()

Prime_Field_Element Constant_Polynomial::leading_coefficient ( ) const
overridevirtual
Returns
leading coefficient – call after sort_by_order()!

Implements Abstract_Polynomial.

Definition at line 203 of file polynomial_array.cpp.

◆ leading_monomial()

Monomial & Constant_Polynomial::leading_monomial ( ) const
overridevirtual
Returns
leading monomial – call after sort_by_order()!

Implements Abstract_Polynomial.

Definition at line 201 of file polynomial_array.cpp.

◆ length()

unsigned Constant_Polynomial::length ( ) const
overridevirtual
Returns
number of monomials

Implements Abstract_Polynomial.

Definition at line 207 of file polynomial_array.cpp.

◆ monomial_multiple()

Constant_Polynomial * Constant_Polynomial::monomial_multiple ( const Monomial t) const
overridevirtual
Returns
multiple of this and u
Parameters
ta Monomial in the same ring

Implements Abstract_Polynomial.

Definition at line 221 of file polynomial_array.cpp.

◆ scalar_multiple()

Constant_Polynomial * Constant_Polynomial::scalar_multiple ( const Prime_Field_Element c) const
overridevirtual
Returns
multiple of this and c
Parameters
ca scalar in the same prime field

Implements Abstract_Polynomial.

Definition at line 229 of file polynomial_array.cpp.

◆ serialized()

uint64_t * Constant_Polynomial::serialized ( uint64_t &  size)
Returns
an array of uint64_t containing the polynomial data and assigns the length of this array to size
Parameters
sizemodified 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.

◆ set_monomial_ordering()

void Constant_Polynomial::set_monomial_ordering ( const Monomial_Ordering order,
bool  sort_anew = true 
)
overridevirtual

sets the ordering of monomials in this polynomial

Parameters
orderthe (new?) monomial ordering
sort_anewset this to true to re-sort the polynomial

Implements Abstract_Polynomial.

Definition at line 174 of file polynomial_array.cpp.

◆ sort_by_order()

void Constant_Polynomial::sort_by_order ( )
overridevirtual

sort by order

currently uses insertion sort

Implements Abstract_Polynomial.

Examples:
test_4by4.cpp, test_cab_es1.cpp, test_cab_es2.cpp, test_cab_es4.cpp, test_cab_es5.cpp, test_cab_es6.cpp, test_cab_es9.cpp, and test_cyclic4.cpp.

Definition at line 183 of file polynomial_array.cpp.

◆ zero_polynomial()

Constant_Polynomial * Constant_Polynomial::zero_polynomial ( ) const
overridevirtual
Returns
zero constant polynomial: one entry, and it’s zero!

Implements Abstract_Polynomial.

Definition at line 213 of file polynomial_array.cpp.

◆ Dense_Univariate_Integer_Polynomial

class Dense_Univariate_Integer_Polynomial

quick-’n-dirty Dense_Univariate integer polynomial class

Author
John Perry
Date
2016
Warning
You must have 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_Polynomialoperator+= (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)
 

Member Function Documentation

◆ add()

void Dense_Univariate_Integer_Polynomial::add ( const Dense_Univariate_Integer_Polynomial q)

reasonably efficient, given our dense representation

Parameters
qpolynomial to add to this

Definition at line 124 of file dense_univariate_integer_poly.cpp.

◆ expand_poly()

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.

◆ multiply_by_monomial_of_degree()

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.

◆ operator+=()

Dense_Univariate_Integer_Polynomial& Dense_Univariate_Integer_Polynomial::operator+= ( const Dense_Univariate_Integer_Polynomial q)
inline
See also
add()
Parameters
qpolynomial to add to this
Returns
this, after adding q

Definition at line 90 of file dense_univariate_integer_poly.hpp.

◆ Dense_Univariate_Rational_Polynomial

class Dense_Univariate_Rational_Polynomial

quick-’n-dirty Dense_Univariate rational polynomial class

Author
John Perry
Date
2016
Warning
You must have 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)
 

Member Function Documentation

◆ expand_poly()

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.

◆ multiply_by_monomial_of_degree()

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.

◆ scale_by()

void Dense_Univariate_Rational_Polynomial::scale_by ( COEF_TYPE  a,
UCOEF_TYPE  b 
)

multiplies every monomial by a constant rational

Parameters
arational’s numerator
brational’s denominator

Definition at line 92 of file dense_univariate_rational_poly.cpp.

◆ Double_Buffered_Polynomial

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.

Author
John Perry
Date
2015

Definition at line 110 of file polynomial_double_buffered.hpp.

Inheritance diagram for Double_Buffered_Polynomial:
Mutable_Polynomial Abstract_Polynomial

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 Monomialleading_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_Polynomialzero_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_Polynomialmonomial_multiple (const Monomial &t) const override
 multiple of this and u
 
virtual Double_Buffered_Polynomialscalar_multiple (const Prime_Field_Element &c) const override
 multiple of this and c
 
virtual Mutable_Polynomialoperator+= (const Abstract_Polynomial &p) override
 add another polynomial
 
virtual Mutable_Polynomialoperator-= (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_Iteratornew_iterator () const override
 An iterator that poses no risk of modifying the polynomial.
 
virtual DB_Polynomial_Iteratornew_mutable_iterator () override
 An iterator that may modify the current position.
 
virtual Polynomial_Iteratorbegin () const override
 
virtual Polynomial_Iteratorend () 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_Listdetach_head () override
 Remove and return the head.
 
- Public Member Functions inherited from Mutable_Polynomial
 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
 
- Public Member Functions inherited from Abstract_Polynomial
 Abstract_Polynomial (Polynomial_Ring &ring, const 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)
 
const 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
 
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

- Protected Attributes inherited from Abstract_Polynomial
Polynomial_RingR
 data about polynomial ring
 
Poly_Strategy_Datastrat = nullptr
 data for computational strategies
 

Member Function Documentation

◆ expand_buffer()

void Double_Buffered_Polynomial::expand_buffer ( unsigned  b,
unsigned  n 
)
inlineprotected

Expand buffer b to hold \( 2n \) elements.

Parameters
bthe buffer to expand
nnumber 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.

◆ set_monomial_ordering()

void Double_Buffered_Polynomial::set_monomial_ordering ( const Monomial_Ordering order,
bool  sort_anew = true 
)
overridevirtual

set the monomial ordering and sort the polynomials (optionally, but by default)

Parameters
ordernew monomial ordering
sort_anewwhether to sort the polynomial anew
Warning
In most cases you will want to sort anew immediately after setting the ordering. Otherwise, the monomials may be in the wrong order! That is therefore the default behavior of this function, but in case you don’t want to sort, that option is provided.

Implements Abstract_Polynomial.

Definition at line 145 of file polynomial_double_buffered.cpp.

◆ sort_by_order()

void Double_Buffered_Polynomial::sort_by_order ( )
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.

◆ Indeterminate

class Indeterminate

Implementation of indeterminates, for easier building of polynomials.

Author
John Perry
Date
2016

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:

string var_names [] = { "x", "y" };
P = Polynomial_Ring(2, F, var_names);
Monomial x3y = (x^3) * (x*y);

…and the result should be \(x^3y\). Alternately, you could do:

Indeterminate * X = P.indeterminates();
Monomial x3y = (X[0]^3) * (X[0]*X[1]);
free(X);

…with the same result. Just be careful in the second case to destroy the evidence.

Examples:
test_monomials.cpp.

Definition at line 63 of file indeterminate.hpp.

Public Member Functions

Construction
 Indeterminate (Polynomial_Ring &P, NVAR_TYPE xi)
 this will correspond to the xith indeterminate of P.
 
 Indeterminate (const Indeterminate &other)
 copy constructor
 
Indeterminateoperator= (const Indeterminate &other)
 
Basic properties
Polynomial_Ringbase_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 ath 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_RingR
 the ring this lives in
 

Friends

I/O
ostream & operator<< (ostream &, Indeterminate &)
 prints this with the appropriate name
 

◆ Monomial

class Monomial

Implementation of monomials.

Author
John Perry
Date
2015

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.

Warning
When initializing an array of Monomial , be sure to use the initialization functions to format and allocate space.
Any monomial requires that you specify a number of variables. At the present time, the limit on this is 64 (for the sake of masking; though an earlier verison of the code did not have this limit). Most operations require that the number of variables be the same, but the code does not check for this. For what I am designing this for, this is acceptable, but if you intend to work with monomials that contain a different number of variables, check to make sure that any monomial arithmetic involves monomials with the same number of variables.
Examples:
test_4by4.cpp, test_cab_es1.cpp, test_cab_es2.cpp, test_cab_es4.cpp, test_cab_es5.cpp, test_cab_es6.cpp, test_cab_es9.cpp, test_cyclic4.cpp, test_monomials.cpp, and user_interface.cpp.

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_Orderingmonomial_ordering () const
 the Monomial_Ordering associated with this Monomial
 
Monomial_Order_Datamonomial_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 this.

Monomialoperator= (const Monomial &other)
 assignment
 
Monomialoperator*= (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_Orderingordering
 Monomial_Ordering associated with this polynomial.
 
Monomial_Order_Dataordering_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)
 

Constructor & Destructor Documentation

◆ Monomial() [1/2]

Monomial::Monomial ( initializer_list< EXP_TYPE >  powers,
const Monomial_Ordering order = generic_grevlex_ptr 
)

Constructor from initializer list.

Parameters
powersthe Monomial’s exponents
ordera 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() [2/2]

Monomial::Monomial ( NVAR_TYPE  size,
const EXP_TYPE *  powers,
const Monomial_Ordering order = generic_grevlex_ptr 
)

Constructor from array of exponents.

Parameters
sizenumber of variables in the Monomial
powersarray of exponents — use at least n unless you like to crash
ordera Monomial_Ordering for n variables

Copies exponents so you can reuse yours.

Definition at line 147 of file monomial.cpp.

Member Function Documentation

◆ operator/=()

bool Monomial::operator/= ( const Monomial other)

divide this by other

Parameters
otherMonomial to divide this by
Warning
Does not check if this is divisible by other. See divisible_by(), which is the tool to use.
Returns
true if and only if this and other have the same number of variables

Definition at line 351 of file monomial.cpp.

◆ total_degree()

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.

Parameters
mcompute up to m indeterminates; the default value of 0 computes all
Returns
total standard degree of this Monomial

Definition at line 190 of file monomial.cpp.

◆ weighted_degree()

DEG_TYPE Monomial::weighted_degree ( const WT_TYPE *  weights,
NVAR_TYPE  m = 0 
) const
Returns
weighted sum of first m exponents, using given weights
Parameters
weightsthe weights for each indeterminate: the first weight will be multiplied by the first exponent, the second weight by the second exponent, and so forth
mcompute 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.

◆ Monomial_Ideal

class Monomial_Ideal

A class for monomial ideals.

Author
John Perry
Date
2016

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_Polynomialhilbert_numerator (const WT_TYPE *grading=nullptr)
 
Dense_Univariate_Integer_Polynomialreduced_hilbert_numerator (const WT_TYPE *grading=nullptr)
 the reduced Hilbert Numerator More...
 
Dense_Univariate_Rational_Polynomialhilbert_poly ()
 
Computation
Monomial_Idealcolon (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< Monomialgens
 the ideal's generators
 
Dense_Univariate_Integer_PolynomialhGradNum
 the ideal's Hilbert numerator, according to current_grading
 
Dense_Univariate_Integer_PolynomialhGradRedNum
 the ideal's reduced Hilbert numerator, according to current_grading
 
Dense_Univariate_Integer_PolynomialhNum
 the ideal's Hilbert numerator, standard grading
 
Dense_Univariate_Rational_PolynomialhPol
 the ideal's Hilbert polynomial – standard grading only
 
Dense_Univariate_Integer_PolynomialhRedNum
 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 &)
 

Member Function Documentation

◆ colon()

Monomial_Ideal* Monomial_Ideal::colon ( const Monomial t) const
inline

returns the ideal \(J=\{u:t \forall u\in I\}\), where \(I\) is this

Parameters
tMonomial used to form the colon ideal
Returns
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.

◆ colon_with()

void Monomial_Ideal::colon_with ( const Monomial t)
inline

replaces the generators of this with those of the ideal \(J=\{u:t \forall u\in I\}\), where \(I\) is this

Parameters
tMonomial used to form the colon ideal
Warning
does not delete the old Hilbert numerator (as this could be a copy) so delete manually if you need that done

Definition at line 331 of file monomial_ideal.hpp.

◆ hilbert_numerator()

Dense_Univariate_Integer_Polynomial* Monomial_Ideal::hilbert_numerator ( const WT_TYPE *  grading = nullptr)
inline
Returns
the (un-reduced) Hilbert numerator
Parameters
gradinggrading to use for computing this; use nullptr for standard, which is the default
Warning
Destroys the old Hilbert numerator if it was assigned a different grading. The comparison is by pointer only, not by values.

Definition at line 227 of file monomial_ideal.hpp.

◆ hilbert_poly()

Dense_Univariate_Rational_Polynomial* Monomial_Ideal::hilbert_poly ( )
inline
Returns
the Hilbert Polynomial for this ideal

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.

◆ reduced_hilbert_numerator()

Dense_Univariate_Integer_Polynomial* Monomial_Ideal::reduced_hilbert_numerator ( const WT_TYPE *  grading = nullptr)
inline

the reduced Hilbert Numerator

Parameters
gradinggrading to use for computing this; use nullptr for standard, which is the default
Returns
the reduced Hilbert numberator of this ideal, which is computed by canceling common factors with the denominator
See also
hilbert_second_numerator()

Definition at line 259 of file monomial_ideal.hpp.

◆ Monomial_Ideal_Variables_Exception

class Monomial_Ideal_Variables_Exception

exceptions for Monomial Ideals

Author
John Perry
Date
2016

Definition at line 46 of file monomial_ideal.hpp.

Inheritance diagram for Monomial_Ideal_Variables_Exception:

◆ Monomial_Node

class Monomial_Node

Tool for Polynomial_Linked_List.

Author
John Perry
Date
2015

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
Monomialmonomial ()
 This term’s monomial, or power product. The coefficient is not included.
 
Prime_Field_Elementcoefficient ()
 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_Nodenext
 for linking
 
Monomial_Nodeprev
 for linking
 
Monomial t
 the monomial in this node
 

Friends

Iteration
class LLPolynomial_Iterator
 
class Polynomial_Linked_List
 

◆ Mutable_Polynomial

class Mutable_Polynomial

Polynomials that need arithmetic typically descend from this class.

Author
John Perry
Date
2015

This class extends Abstract_Polynomial to allow for basic arithmetic of a polynomial.

Definition at line 305 of file polynomial.hpp.

Inheritance diagram for Mutable_Polynomial:
Abstract_Polynomial Double_Buffered_Polynomial Polynomial_Geobucket Polynomial_Linked_List

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_Polynomialzero_polynomial () const =0
 zero polynomial of this type
 
virtual Mutable_Polynomialoperator+= (const Abstract_Polynomial &)=0
 add another polynomial
 
virtual Mutable_Polynomialoperator-= (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_Polynomialmonomial_multiple (const Monomial &) const =0
 multiple of this and u
 
virtual Mutable_Polynomialscalar_multiple (const Prime_Field_Element &) const =0
 multiple of this and c
 
Iteration
virtual Mutable_Polynomial_Iteratornew_mutable_iterator ()=0
 An iterator that may modify the current position.
 
Modification
virtual Mutable_Polynomialdetach_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!
 
- Public Member Functions inherited from Abstract_Polynomial
 Abstract_Polynomial (Polynomial_Ring &ring, const 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)
 
const Monomial_Orderingmonomial_ordering () const
 reports leading monomial’s monomial ordering
 
virtual Monomialleading_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_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
 
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_Iteratornew_iterator () const =0
 An iterator that poses no risk of modifying the polynomial.
 
virtual Polynomial_Iteratorbegin () const =0
 
virtual Polynomial_Iteratorend () const =0
 
virtual void print (ostream &os=cout) const
 
virtual void println (ostream &os=cout) const
 
virtual void printlncout () const
 

Additional Inherited Members

- Protected Attributes inherited from Abstract_Polynomial
Polynomial_RingR
 data about polynomial ring
 
Poly_Strategy_Datastrat = nullptr
 data for computational strategies
 

◆ Polynomial_Geobucket

class Polynomial_Geobucket

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 114 of file 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 () 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 Monomialleading_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_Listzero_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_Iteratornew_iterator () const override
 An iterator that poses no risk of modifying the polynomial.
 
virtual Polynomial_Iteratorbegin () const override
 
virtual Polynomial_Iteratorend () const override
 
virtual Geobucket_Iteratornew_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_Geobucketmonomial_multiple (const Monomial &t) const override
 Returns \(\texttt{this}\times t\).
 
virtual Polynomial_Geobucketscalar_multiple (const Prime_Field_Element &a) const override
 Returns \(\texttt{this}\times a\).
 
virtual Polynomial_Geobucketoperator+= (const Abstract_Polynomial &g) override
 Adds \(g\) to this. Recomputes leading monomial.
 
virtual Polynomial_Geobucketoperator-= (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_Listdetach_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_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, 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
 
- Public Member Functions inherited from Abstract_Polynomial
 Abstract_Polynomial (Polynomial_Ring &ring, const 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)
 
const 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
 
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.
 
- Protected Attributes inherited from Abstract_Polynomial
Polynomial_RingR
 data about polynomial ring
 
Poly_Strategy_Datastrat = 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...
 

Member Function Documentation

◆ add_last()

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

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

Parameters
acoefficient of the term to add
tMonomial of the term to add
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 363 of file polynomial_geobucket.cpp.

◆ canonicalize()

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

returns a copy of this in a simplified linear form

Parameters
constant_resultwhether 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.)

Returns
a copy of this in a simplified linear form

Definition at line 378 of file polynomial_geobucket.cpp.

◆ is_zero()

bool Polynomial_Geobucket::is_zero ( ) const
overridevirtual

is this polynomial zero?

Returns
true iff all the buckets are nullptr or themselves zero
See also
Fixed_Length_Polynomial

Implements Abstract_Polynomial.

Definition at line 201 of file polynomial_geobucket.cpp.

◆ leading_coefficient()

Prime_Field_Element Polynomial_Geobucket::leading_coefficient ( ) const
overridevirtual

returns the leading coefficient

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 185 of file polynomial_geobucket.cpp.

◆ leading_monomial()

Monomial & Polynomial_Geobucket::leading_monomial ( ) const
overridevirtual

returns the leading monomial

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 181 of file polynomial_geobucket.cpp.

◆ length()

unsigned Polynomial_Geobucket::length ( ) const
overridevirtual

how long is this polynomial?

Returns
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 189 of file polynomial_geobucket.cpp.

◆ lglen()

unsigned Polynomial_Geobucket::lglen ( unsigned  i)
inlineprotected

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

Parameters
inumber of terms we need space for
Returns
the smallest power of 2 larger than i

Definition at line 302 of file polynomial_geobucket.hpp.

◆ print() [1/2]

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

prints the \(i\)th bucket

Parameters
iwhich bucket to print
oswhere 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.

◆ print() [2/2]

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

prints the polynomial with an explicitly bucket form

Parameters
oswhere 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.

◆ recompute_leading_monomial()

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.

◆ set_monomial_ordering()

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

sets the monomial ordering for each bucket

Warning
This performs no simplification bewteen buckets.
Parameters
orderthe new monomial ordering
sort_anewwhether to re-sort the polynomials

Implements Abstract_Polynomial.

Definition at line 174 of file polynomial_geobucket.cpp.

◆ sort_by_order()

void Polynomial_Geobucket::sort_by_order ( )
overridevirtual

sorts each geobucket

Warning
This performs no simplification between buckets.

Implements Abstract_Polynomial.

Definition at line 168 of file polynomial_geobucket.cpp.

◆ zero_polynomial()

Polynomial_Linked_List * Polynomial_Geobucket::zero_polynomial ( ) const
overridevirtual

creates and returns a geobucket initialized to zero

Returns
a geobucket initialized to zero

Implements Mutable_Polynomial.

Definition at line 197 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 417 of file polynomial_geobucket.cpp.

◆ Polynomial_Linked_List

class Polynomial_Linked_List

Polynomials represented as a doubly linked list.

Author
John Perry
Date
2015

Definition at line 171 of file polynomial_linked_list.hpp.

Inheritance diagram for Polynomial_Linked_List:
Mutable_Polynomial Abstract_Polynomial

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 Monomialleading_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_Listzero_polynomial () const override
 Returns as simple a zero polynomial as I can muster, short of this being nullptr.
 
virtual Polynomial_Linked_Listmonomial_multiple (const Monomial &u) const override
 Returns a new polynomial whose value is \(\textit{this}\times u\).
 
virtual Polynomial_Linked_Listscalar_multiple (const Prime_Field_Element &c) const override
 Returns a new polynomial whose value is \(\textit{this}\times c\).
 
virtual Polynomial_Linked_Listoperator+= (const Abstract_Polynomial &other) override
 Adds other to this, and returns the result.
 
virtual Polynomial_Linked_Listoperator-= (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_Iteratornew_iterator () const override
 an iterator that poses no risk of modifying the polynomial
 
virtual Polynomial_Iteratorbegin () const override
 an iterator that poses no risk of modifying the polynomial
 
virtual Polynomial_Iteratorend () const override
 an iterator that poses no risk of modifying the polynomial
 
virtual LLPolynomial_Iteratornew_mutable_iterator () override
 An iterator that may modify the current position.
 
Modification
virtual Polynomial_Linked_Listdetach_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.
 
- Public Member Functions inherited from Mutable_Polynomial
 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
 
- Public Member Functions inherited from Abstract_Polynomial
 Abstract_Polynomial (Polynomial_Ring &ring, const 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)
 
const Monomial_Orderingmonomial_ordering () const
 reports leading monomial’s monomial ordering
 
virtual bool can_reduce (Abstract_Polynomial &other) const
 can this reduce other?
 
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
 
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_Nodehead
 first monomial in the list, returned by leading_monomial()
 
- Protected Attributes inherited from Abstract_Polynomial
Polynomial_RingR
 data about polynomial ring
 
Poly_Strategy_Datastrat = nullptr
 data for computational strategies
 

Friends

class LLPolynomial_Iterator
 to iterate over this and possibly change it
 

Member Function Documentation

◆ add_polynomial_multiple()

void Polynomial_Linked_List::add_polynomial_multiple ( const Prime_Field_Element a,
const Monomial t,
const Abstract_Polynomial q,
bool  subtract 
)
overridevirtual

"Fast" addition of \(atq\) to this.

If subtract==true, subtract instead.

Parameters
acoefficient of the term to multiply to q
tMonomial of the term to multiply to q
qpolynomial to add to this, after multiplying q by \( at \)
subtractwhether to add instead of subtract

Implements Mutable_Polynomial.

Definition at line 389 of file polynomial_linked_list.cpp.

◆ set_monomial_ordering()

void Polynomial_Linked_List::set_monomial_ordering ( const Monomial_Ordering order,
bool  sort_anew = true 
)
overridevirtual

set the monomial ordering and sort the polynomials (optionally, but by default)

Parameters
ordernew monomial ordering
sort_anewwhether to sort the polynomial anew
Warning
In most cases you will want to sort anew immediately after setting the ordering. Otherwise, the monomials may be in the wrong order! That is therefore the default behavior of this function, but in case you don’t want to sort, that option is provided.

Implements Abstract_Polynomial.

Definition at line 232 of file polynomial_linked_list.cpp.

◆ Polynomial_Ring

class Polynomial_Ring

Encapsulates information about a polynomial ring for easy access: ground field, number of indeterminates, ….

Author
John Perry
Date
2015
Examples:
test_4by4.cpp, test_cab_es1.cpp, test_cab_es2.cpp, test_cab_es4.cpp, test_cab_es5.cpp, test_cab_es6.cpp, test_cab_es9.cpp, test_cyclic4.cpp, test_cyclicn.cpp, test_dynamic.cpp, test_monomials.cpp, and user_interface.cpp.

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 Indeterminateindeterminates ()
 an array of the ring’s indeterminates; use only to biuld polynomials
 
virtual Prime_Fieldground_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_FieldF
 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
 

Constructor & Destructor Documentation

◆ Polynomial_Ring()

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.

Parameters
num_varsnumber of indeterminates in this Polynomial_Ring
fieldground field of this Polynomial_Ring
var_namesan optional array of num_vars names to assign to the indeterminates

Definition at line 25 of file polynomial_ring.cpp.

Member Function Documentation

◆ set_names()

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.

Warning
If length is not the same as the number of indeterminates, things can go very, very badly.
Parameters
new_namesnames for the indeterminates
lengthnumber of names in new_names
Returns
whether all supplied names were set

Definition at line 40 of file polynomial_ring.cpp.

Member Data Documentation

◆ n

NVAR_TYPE Polynomial_Ring::n
protected

the number of indeterminates for every monomial in the ring

Warning
The system does not verify that the number of indeterminates in a monomial agrees with the number specified in this ring. This information is easily available through the number_of_variables() command.

Definition at line 102 of file polynomial_ring.hpp.

Function Documentation

◆ colon_ideal_without_ideals()

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.

Author
John Perry
Date
2016
Parameters
Ugenerators of ideal we want to “colonize”
tMonomial that is “colonizing” the ideal generated by U
Returns
a list of generators of the colon ideal of U by t ( \( U:(t) \))

Definition at line 42 of file monomial_ideal.cpp.

◆ cyclic_n()

list<Abstract_Polynomial *> cyclic_n ( NVAR_TYPE  n,
Prime_Field F,
bool  homog,
Monomial_Ordering mord = generic_grevlex_ptr 
)

generates the Cyclic- \( n \) system

Returns
a set of generators of the Cyclic- \( n \) system, as pointers to Constant_Polynomial
Parameters
nnumber of variables
Fground field
homogwhether to homogenize the system (affects only the last polynomial)
morda 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.

Examples:
test_cyclicn.cpp, and test_dynamic.cpp.

Definition at line 57 of file cyclic_n.hpp.