carl  24.04
Computer ARithmetic Library
PrimitiveEuclidean.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Content.h"
4 #include "PrimitivePart.h"
5 
6 #include "../UnivariatePolynomial.h"
7 
8 namespace carl {
9 
10 /**
11  * Computes the GCD of two univariate polynomial with coefficients
12  * from a unique factorization domain using the primitive euclidean algorithm.
13  * @see @cite GCL92, page 57, Algorithm 2.3
14  */
15 template<typename Coeff>
19 
20  while (!is_zero(d)) {
22  c = d;
23  d = primitive_part(r.normalized());
24  }
25  return gcd(content(a), content(b)) * c;
26 }
27 
28 }
carl is the main namespace for the library.
Coeff content(const UnivariatePolynomial< Coeff > &p)
The content of a polynomial is the gcd of the coefficients of the normal part of a polynomial.
Definition: Content.h:22
cln::cl_I gcd(const cln::cl_I &a, const cln::cl_I &b)
Calculate the greatest common divisor of two integers.
Definition: operations.h:310
bool is_zero(const Interval< Number > &i)
Check if this interval is a point-interval containing 0.
Definition: Interval.h:1453
UnivariatePolynomial< Coeff > primitive_euclidean(const UnivariatePolynomial< Coeff > &a, const UnivariatePolynomial< Coeff > &b)
Computes the GCD of two univariate polynomial with coefficients from a unique factorization domain us...
UnivariatePolynomial< Coeff > primitive_part(const UnivariatePolynomial< Coeff > &p)
The primitive part of p is the normal part of p divided by the content of p.
Definition: PrimitivePart.h:19
UnivariatePolynomial< Coeff > pseudo_remainder(const UnivariatePolynomial< Coeff > &dividend, const UnivariatePolynomial< Coeff > &divisor)
Calculates the pseudo-remainder.
Definition: Remainder.h:105
This class represents a univariate polynomial with coefficients of an arbitrary type.
UnivariatePolynomial normalized() const
The normal part of a polynomial is the polynomial divided by the unit part.