9 #include "../MultivariatePolynomial.h"
10 #include "../../numbers/PrimeFactory.h"
20 template<
typename Coeff,
typename Ordering= GrLexOrdering,
typename Policies = StdMultivariatePolynomialPolicies<>>
25 typedef GCDResult<Coeff,Ordering,Policies>
Result;
76 a = a.divideBy(g).quotient;
77 b = b.divideBy(g).quotient;
80 std::map<Variable, Integer> eval_b =
findEval(
A,B,p);
81 UnivPol A_I =
A.evaluateCoefficient(eval_b).mod(p);
93 std::map<Variable, Integer> eval_c =
findEval(
A,B,p_prime);
94 UnivPol A_I_prime =
A.evaluateCoefficient(eval_c).mod(p_prime);
97 unsigned d_I_prime = C_I_prime.
degree();
108 else if (d < d_I_prime)
113 assert(d == d_I_prime);
140 H_I = B_I.divideBy(C_I).quotient;
146 H_I = A_I.divideBy(C_I).quotient;
158 Coeff c_I =
mod(c.evaluate(eval_b),p);
162 std::vector<Polynomial> CE;
163 assert(CE.size() == 2);
164 if(U_I == CE.front()*CE.back())
171 return {a*
mp1/C, b*
mp2/C, g*C};
190 std::vector<Variable> common;
195 std::inserter(common,common.begin()));
202 return *common.begin();
228 std::map<Variable, Integer> result;
#define CARL_LOG_NOTIMPLEMENTED()
carl is the main namespace for the library.
cln::cl_I mod(const cln::cl_I &a, const cln::cl_I &b)
Calculate the remainder of the integer division.
cln::cl_I gcd(const cln::cl_I &a, const cln::cl_I &b)
Calculate the greatest common divisor of two integers.
bool is_zero(const Interval< Number > &i)
Check if this interval is a point-interval containing 0.
typename UnderlyingNumberType< P >::type Coeff
Interval< Number > set_intersection(const Interval< Number > &lhs, const Interval< Number > &rhs)
Intersects two intervals in a set-theoretic manner.
void variables(const BasicConstraint< Pol > &c, carlVariables &vars)
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.
static const Variable NO_VARIABLE
Instance of an invalid variable.
const T & next_prime()
Computed the next prime and returns it.
This class represents a univariate polynomial with coefficients of an arbitrary type.
UnivariatePolynomial< Coefficient > evaluateCoefficient(const std::map< Variable, SubstitutionType > &) const
uint degree() const
Get the maximal exponent of the main variable.
The general-purpose multivariate polynomial class.
bool divides(const MultivariatePolynomial &b) const
std::size_t nr_terms() const
Calculate the number of terms.
Extended Zassenhaus algorithm for multivariate GCD calculation.
IntegralType< Coeff >::type Integer
UnivariatePolynomial< Coeff > UnivPol
Polynomial::TermType Term
Result calculate(bool approx=true)
UnivariatePolynomial< MultivariatePolynomial< Coeff, Ordering, Policies > > UnivReprPol
std::map< Variable, Integer > findEval(const UnivReprPol &A, const UnivReprPol &B, Integer p) const
Find a valid evaluation point b = (b_1, ...
MultivariatePolynomial< Coeff, Ordering, Policies > Polynomial
GCDResult< Coeff, Ordering, Policies > Result
EZGCD(const MultivariatePolynomial< Coeff, Ordering, Policies > &p1, const MultivariatePolynomial< Coeff, Ordering, Policies > &p2)
PrimeFactory< Integer > mPrimeFactory
Variable getMainVar(const Polynomial p1, const Polynomial p2) const
Given the two polynomials, find a suitable main variable for gcd.
Integer getPrime(const UnivReprPol &A, const UnivReprPol &B)