1 #ifndef __DENSE_UNIVARIATE_RATIONAL_POLY_HPP_ 2 #define __DENSE_UNIVARIATE_RATIONAL_POLY_HPP_ 6 #include "system_constants.hpp" 8 using std::ostream;
using std::cout;
using std::endl;
53 if (k >
deg and a != 0) {
deg = k; }
54 else if (k ==
deg and a == 0) {
67 void scale_by(COEF_TYPE a, UCOEF_TYPE b);
102 for (DEG_TYPE i = 0; nonzero and i <=
deg; ++i)
118 friend ostream & operator<<(
123 for (DEG_TYPE i = p.
deg; i > 0; --i) {
138 if (i != 1) { os <<
"t^" << i; }
142 else if (p.
numerators[i - 1] > 0) { os <<
" + "; }
UCOEF_TYPE denominator(DEG_TYPE k) const
returns the th denominator
COEF_TYPE * numerators
list of numerators; index 0 is the constant’s
DEG_TYPE size
number of slots for coefficients
bool is_zero() const
indicates whether the polynomial is zero
void multiply_by(const Dense_Univariate_Rational_Polynomial &)
highly inefficient polynomial multiplication ( )
void operator-=(const Dense_Univariate_Rational_Polynomial &other)
alias for subtract()
void negate()
negates the numerators
void add(const Dense_Univariate_Rational_Polynomial &)
adds other to this
void set_coefficient(DEG_TYPE k, COEF_TYPE a, UCOEF_TYPE b)
set the coefficient of to
COEF_TYPE numerator(DEG_TYPE k) const
returns the th numerator
const COEF_TYPE * numerator_array()
all the numerators
void expand_poly(DEG_TYPE)
expand to allow for higher-degree monomials
void subtract(const Dense_Univariate_Rational_Polynomial &)
subtracts other from this
void multiply_by_monomial_of_degree(DEG_TYPE)
a hopefully efficient multiplication algorithm
void operator+=(const Dense_Univariate_Rational_Polynomial &other)
alias for add()
DEG_TYPE deg
degree of the polynomial (largest nonzero exponent)
void scale_by(COEF_TYPE a)
multiplies every monomial by a constant integer
quick-’n-dirty Dense_Univariate rational polynomial class
DEG_TYPE degree() const
returns the polynomial’s degree
const UCOEF_TYPE * denominator_array()
all the denominators
Dense_Univariate_Rational_Polynomial(DEG_TYPE)
construct with the number of expected terms
Dense_Univariate_Rational_Polynomial operator-(const Dense_Univariate_Rational_Polynomial &) const
returns the difference between this and the other
UCOEF_TYPE * denominators
list of denominators; index 0 is the constant’s