7 #include "../MultivariatePolynomial.h"
8 #include "../UnivariatePolynomial.h"
19 template<
typename Coeff>
25 if(dividend.
degree() < divisor.
degree())
return dividend;
33 if(prefactor !=
nullptr)
37 assert(factor * divisor.
lcoeff() == *prefactor * dividend.
lcoeff());
46 std::vector<Coeff> coeffs;
52 if(prefactor !=
nullptr)
54 for(
Coeff& c : coeffs)
61 if(prefactor !=
nullptr)
63 for(std::size_t i = 0; i < dividend.
coefficients().size() - degdiff -1; ++i)
70 for(std::size_t i = 0; i < dividend.
coefficients().size() - degdiff -1; ++i)
77 result.strip_leading_zeroes();
89 template<
typename Coeff>
94 template<
typename Coeff>
104 template<
typename Coeff>
110 if (divisor.
degree() > dividend.
degree())
return dividend;
116 std::size_t reductions = 0;
122 std::size_t degdiff = dividend.
degree() - divisor.
degree() + 1;
123 if (reductions < degdiff) {
128 std::vector<Coeff> newR(res.
degree());
130 for (std::size_t i = 0; i < res.
degree(); i++) {
132 assert(!newR[i].has(v));
136 for (std::size_t i = 0; i <= reduct.
degree(); i++) {
138 assert(!newR[i].has(v));
144 for (std::size_t i = 0; i <= reduct.
degree(); i++) {
146 assert(!newR[res.
degree() - divisor.
degree() + i].has(v));
158 template<
typename Coeff>
169 return remainder(dividend, divisor, &prefactor);
172 template<
typename C,
typename O,
typename P>
176 if(÷nd == &divisor ||
carl::is_one(divisor) || dividend == divisor)
216 template<
typename C,
typename O,
typename P>
Implements utility functions concerning the (total) degree of monomials, terms and polynomials.
States if a type is a field.
carl is the main namespace for the library.
UnivariatePolynomial< C > to_univariate_polynomial(const MultivariatePolynomial< C, O, P > &p)
Convert a univariate polynomial that is currently (mis)represented by a 'MultivariatePolynomial' into...
bool is_constant(const ContextPolynomial< Coeff, Ordering, Policies > &p)
Interval< Number > quotient(const Interval< Number > &_lhs, const Interval< Number > &_rhs)
Implements the division with remainder.
UnivariatePolynomial< Coeff > remainder_helper(const UnivariatePolynomial< Coeff > ÷nd, const UnivariatePolynomial< Coeff > &divisor, const Coeff *prefactor=nullptr)
Does the heavy lifting for the remainder computation of polynomial division.
bool is_zero(const Interval< Number > &i)
Check if this interval is a point-interval containing 0.
UnivariatePolynomial< Coeff > signed_pseudo_remainder(const UnivariatePolynomial< Coeff > ÷nd, const UnivariatePolynomial< Coeff > &divisor)
Compute the signed pseudo-remainder.
typename UnderlyingNumberType< P >::type Coeff
cln::cl_I remainder(const cln::cl_I &a, const cln::cl_I &b)
Calculate the remainder of the integer division.
UnivariatePolynomial< Coeff > pseudo_remainder(const UnivariatePolynomial< Coeff > ÷nd, const UnivariatePolynomial< Coeff > &divisor)
Calculates the pseudo-remainder.
Interval< Number > pow(const Interval< Number > &i, Integer exp)
bool is_one(const Interval< Number > &i)
Check if this interval is a point-interval containing 1.
A Variable represents an algebraic variable that can be used throughout carl.
This class represents a univariate polynomial with coefficients of an arbitrary type.
const std::vector< Coefficient > & coefficients() const &
Retrieves the coefficients defining this polynomial.
Variable main_var() const
Retrieves the main variable of this polynomial.
const Coefficient & lcoeff() const
Returns the leading coefficient.
void truncate()
Removes the leading term from the polynomial.
uint degree() const
Get the maximal exponent of the main variable.
The general-purpose multivariate polynomial class.
MultivariatePolynomial & strip_lterm()
Drops the leading term.
const Term< Coeff > & lterm() const
The leading term.
void subtractProduct(const Term< Coeff > &factor, const MultivariatePolynomial &p)
Subtract a term times a polynomial from this polynomial.
Represents a single term, that is a numeric coefficient and a monomial.
Term divide(const Coefficient &c) const
bool divisible(const Term &t) const
uint tdeg() const
Gives the total degree, i.e.