carl  24.04
Computer ARithmetic Library
PrimitivePart.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Content.h"
4 #include "Degree.h"
5 #include "Division.h"
6 
7 #include "../MultivariatePolynomial.h"
8 #include "../UnivariatePolynomial.h"
9 
10 namespace carl {
11 
12 /**
13  * The primitive part of p is the normal part of p divided by the content of p.
14  * The primitive part of zero is zero.
15  * @see @cite GCL92, page 53, definition 2.18
16  * @return The primitive part of the polynomial.
17  */
18 template<typename Coeff>
20  if (carl::is_zero(p)) {
21  // By definition
22  return p;
23  }
24  if (p.is_normal()) {
25  return p / carl::content(p);
26  } else {
27  return p / Coeff(-carl::content(p));
28  }
29 }
30 
31 /**
32  * Returns this/divisor where divisor is the numeric content of this polynomial.
33  * @return
34  */
35 template<typename Coeff>
37  auto c = p.numeric_content();
38  if (is_zero(c) || is_one(c)) return p;
39  return divide(p, c).quotient;
40 }
41 
42 }
Implements utility functions concerning the (total) degree of monomials, terms and polynomials.
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
UnivariatePolynomial< Coeff > pseudo_primitive_part(const UnivariatePolynomial< Coeff > &p)
Returns this/divisor where divisor is the numeric content of this polynomial.
Definition: PrimitivePart.h:36
bool is_zero(const Interval< Number > &i)
Check if this interval is a point-interval containing 0.
Definition: Interval.h:1453
void divide(const cln::cl_I &dividend, const cln::cl_I &divisor, cln::cl_I &quotient, cln::cl_I &remainder)
Definition: operations.h:326
typename UnderlyingNumberType< P >::type Coeff
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
bool is_one(const Interval< Number > &i)
Check if this interval is a point-interval containing 1.
Definition: Interval.h:1462
This class represents a univariate polynomial with coefficients of an arbitrary type.
bool is_normal() const
Checks whether the polynomial is unit normal.
NumberType numeric_content(std::size_t i) const
Returns the numeric content part of the i'th coefficient.