6 #include "../MultivariatePolynomial.h"
7 #include "../UnivariatePolynomial.h"
15 template<
typename Type>
21 template<
typename Coeff>
27 template<
typename Coeff>
35 template<
typename Coeff>
51 template<
typename Coeff,
typename Ordering,
typename Policies>
54 std::vector<Term<Coeff>> new_coeffs;
55 for (
const auto& t: p) {
56 new_coeffs.emplace_back(
divide(t, divisor));
73 template<
typename Coeff,
typename Ordering,
typename Policies>
85 auto id = tam.getId(0);
86 auto thisid = tam.getId(dividend.
nr_terms());
87 for (
const auto& t: dividend) {
88 tam.template addTerm<false,true>(thisid, t);
94 for (
const auto& t: divisor) {
95 tam.template addTerm<true,true>(thisid, -factor*t);
99 tam.template addTerm<true>(
id, factor);
104 tam.readTerms(
id,
quotient.terms());
105 tam.dropTerms(thisid);
107 quotient.template makeMinimallyOrdered<false, true>();
120 template<
typename Coeff,
typename Ordering,
typename Policies>
139 assert(dividend == q * divisor + r);
143 template<
typename Coeff>
148 assert(divisor.is_consistent());
152 assert(quo.is_consistent());
157 template<
typename Coeff>
160 assert(divisor.is_consistent());
168 CARL_LOG_ERROR(
"carl.core",
"Called divide() with non-field number divisor " << divisor);
173 template<
typename Coeff>
193 template<
typename Coeff>
199 assert(dividend == divisor * result.quotient + result.remainder);
204 for (std::size_t offset = 0; offset <= degdiff; offset++) {
207 coeffs[degdiff-offset] += factor;
210 assert(dividend == divisor * result.quotient + result.remainder);
217 assert(dividend == divisor * result.quotient + result.remainder);
226 Coeff factor = result.remainder.lcoeff()/divisor.
lcoeff();
227 uint degdiff = result.remainder.degree() - divisor.
degree();
229 coeffs[degdiff] += factor;
233 assert(dividend == divisor * result.quotient + result.remainder);
241 template<
typename C,
typename O,
typename P>
#define CARL_LOG_ERROR(channel, msg)
#define CARL_LOG_TRACE(channel, msg)
States if a type is a field.
States if a type is an integer type.
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 try_divide(const Term< Coeff > &t, const Coeff &c, Term< Coeff > &res)
Interval< Number > operator/(const Interval< Number > &lhs, const Number &rhs)
Operator for the division of an interval and a number.
Interval< Number > quotient(const Interval< Number > &_lhs, const Interval< Number > &_rhs)
Implements the division with remainder.
bool is_zero(const Interval< Number > &i)
Check if this interval is a point-interval containing 0.
void divide(const cln::cl_I ÷nd, const cln::cl_I &divisor, cln::cl_I "ient, cln::cl_I &remainder)
typename UnderlyingNumberType< P >::type Coeff
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.
T type
A type associated with the type.
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.
bool is_consistent() const
Asserts that this polynomial over numeric coefficients complies with the requirements and assumptions...
uint degree() const
Get the maximal exponent of the main variable.
The general-purpose multivariate polynomial class.
bool is_consistent() const
Asserts that this polynomial complies with the requirements and assumptions for MultivariatePolynomia...
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.
std::size_t nr_terms() const
Calculate the number of terms.
bool isOrdered() const
Check if the terms are ordered.
States if a type is a number type.
A strongly typed pair encoding the result of a division, being a quotient and a remainder.
Term divide(const Coefficient &c) const
Coefficient & coeff()
Get the coefficient.
Monomial::Arg & monomial()
Get the monomial.