1 #ifndef __DENSE_UNIVARIATE_INTEGER_POLY_HPP_ 2 #define __DENSE_UNIVARIATE_INTEGER_POLY_HPP_ 23 #include "system_constants.hpp" 115 for (DEG_TYPE i = 0; result and i <=
deg; ++i)
116 result = (
coeffs[i] == 0);
123 friend ostream & operator<<(
128 for (DEG_TYPE i = p.
deg; i > 0; --i) {
132 else { os << -p.
coeffs[i]; }
134 if (i != 1) { os <<
"t^" << i; }
137 if (p.
coeffs[i - 1] < 0) { os <<
" - "; }
138 else if (p.
coeffs[i - 1] > 0) { os <<
" + "; }
void set_coefficient(DEG_TYPE k, COEF_TYPE a)
set the coefficient of to
COEF_TYPE operator[](DEG_TYPE k) const
synonym for coeff(k)
void negate()
negates the coefficients
void scale_by(COEF_TYPE a)
multiplies every monomial by a constant
const COEF_TYPE * coefficient_array()
all the coefficients
void multiply_by_monomial_of_degree(DEG_TYPE)
a hopefully efficient multiplication algorithm
Dense_Univariate_Integer_Polynomial operator-(const Dense_Univariate_Integer_Polynomial &) const
returns the result of subtracting the other from this
Dense_Univariate_Integer_Polynomial(DEG_TYPE)
construct with the number of expected terms
Dense_Univariate_Integer_Polynomial & operator+=(const Dense_Univariate_Integer_Polynomial &q)
DEG_TYPE deg
degree of the polynomial (largest nonzero exponent)
COEF_TYPE coeff(DEG_TYPE k) const
the th coefficient
void expand_poly(DEG_TYPE)
expand to allow for higher-degree monomials
quick-’n-dirty Dense_Univariate integer polynomial class
void multiply_by(const Dense_Univariate_Integer_Polynomial &)
highly inefficient polynomial multiplication ( )
DEG_TYPE size
number of slots for coefficients
void add(const Dense_Univariate_Integer_Polynomial &q)
reasonably efficient, given our dense representation
DEG_TYPE degree() const
the polynomial’s degree (exponent of largest nonzero term)
COEF_TYPE * coeffs
list of numerators; index 0 is the constant’s
bool is_zero() const
returns True if and only if every valid coefficient is zero