1 #ifndef __POLYNOMIAL_CPP_ 2 #define __POLYNOMIAL_CPP_ 21 #include "polynomial.hpp" 30 return R.number_of_variables();
38 void Abstract_Polynomial::print(ostream & os)
const { os << *
this; }
40 void Abstract_Polynomial::println(ostream & os)
const {
56 if (!pi->
fellOff()) os <<
" + ";
92 add_polynomial_multiple(a, u, p,
true);
109 if (w ==
nullptr)
return standard_degree();
DEG_TYPE total_degree(NVAR_TYPE m=0) const
Sum of exponents of the first m variables.
The general class of a polynomial.
virtual bool is_zero() const =0
is this polynomial zero?
DEG_TYPE weighted_degree(const WT_TYPE *weights, NVAR_TYPE m=0) const
virtual bool can_reduce(Abstract_Polynomial &other) const
can this reduce other?
polynomial-related strategy data
virtual Polynomial_Iterator * new_iterator() const =0
An iterator that poses no risk of modifying the polynomial.
virtual void moveRight()=0
Moves right in the polynomial, to the next smaller monomial.
virtual const Prime_Field_Element & currCoeff() const =0
Reports the coefficient at the current position.
virtual DEG_TYPE standard_degree() const
maximum sum of exponents for any monomial
Information necessary for a field modulo a prime.
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()!
const Abstract_Polynomial * p
the polynomial this points to
Prime_Field & ground_field()
ground field – all coefficients should be in this field
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 ...
bool is_one() const
all exponents 0?
virtual DEG_TYPE weighted_degree(const WT_TYPE *w=nullptr) const
virtual void reduce_by(const Abstract_Polynomial &p)
reduce by until no further reduction possible
virtual void set_currCoeff(const Prime_Field_Element &)=0
change coefficient in current position
virtual void multiply_by_monomial(const Monomial &t)
multiply by monomial
virtual bool fellOff() const =0
virtual ~Mutable_Polynomial()=0
destructor
Implementation of monomials.
Element of a field of prime characteristic.
bool is_one() const
Is this the multiplicative identity?
virtual void set_currMonomial(const Monomial &)=0
change monomial in current position
unsigned number_of_variables() const
number of variables – all monomials should agree with this (though it is never tested by the class) ...
Encapsulates information about a polynomial ring for easy access: ground field, number of indetermina...
virtual void multiply_by_scalar(const Prime_Field_Element &a)
multiply by scalar
A Mutable_Polynomial_Iterator allows one to modify the terms of a polynomial.
virtual ~Polynomial_Iterator()=0
needed to avoid undefined behavior when disposing
void set_strategy(Poly_Strategy_Data *psd)
sets the polynomial’s strategy to psd
Used to iterate through a polynomial.
COEF_TYPE inverse() const
Returns the multiplicative inverse of this.
virtual const Monomial & currMonomial() const =0
Reports the monomial at the current position.
virtual const string * name_list() const
names of all the variabiles
Polynomial_Ring & base_ring() const
ring in which this polynomial resides