15 inline LPPolynomial
gcd(
const LPPolynomial& p,
const LPPolynomial& q) {
16 lp_polynomial_t* res = lp_polynomial_new(p.context().lp_context());
17 lp_polynomial_gcd(res, p.get_internal(), q.get_internal());
18 return LPPolynomial(res, p.context());
26 inline LPPolynomial
lcm(
const LPPolynomial& p,
const LPPolynomial& q) {
27 lp_polynomial_t* res = lp_polynomial_new(p.context().lp_context());
28 lp_polynomial_lcm(res, p.get_internal(), q.get_internal());
29 return LPPolynomial(res, p.context());
37 inline LPPolynomial
content(
const LPPolynomial& p) {
38 lp_polynomial_t* res = lp_polynomial_new(p.context().lp_context());
39 lp_polynomial_cont(res, p.get_internal());
40 return LPPolynomial(res, p.context());
43 inline LPPolynomial
derivative(
const LPPolynomial& p) {
44 lp_polynomial_t* res = lp_polynomial_new(p.context().lp_context());
45 lp_polynomial_derivative(res, p.get_internal());
46 return LPPolynomial(res, p.context());
55 lp_polynomial_t* res = lp_polynomial_new(p.context().lp_context());
56 lp_polynomial_pp(res, p.get_internal());
57 return LPPolynomial(res, p.context());
65 inline LPPolynomial
resultant(
const LPPolynomial& p,
const LPPolynomial& q) {
66 lp_polynomial_t* res = lp_polynomial_new(p.context().lp_context());
67 lp_polynomial_resultant(res, p.get_internal(), q.get_internal());
68 return LPPolynomial(res, p.context());
76 inline LPPolynomial
discriminant(
const LPPolynomial& p) {
77 assert(p.context().lp_context() == lp_polynomial_get_context(p.get_internal()));
78 if (lp_polynomial_degree(p.get_internal()) == 1) {
79 return LPPolynomial(p.context(), 1);
82 lp_polynomial_t* ldcf = lp_polynomial_new(p.context().lp_context());
83 lp_polynomial_get_coefficient(ldcf, p.get_internal(), lp_polynomial_degree(p.get_internal()));
84 lp_polynomial_t* res = lp_polynomial_new(p.context().lp_context());
85 lp_polynomial_derivative(res, p.get_internal());
86 lp_polynomial_resultant(res, p.get_internal(), res);
87 lp_polynomial_div(res, res, ldcf);
88 lp_polynomial_delete(ldcf);
89 return LPPolynomial(res, p.context());
97 Factors<LPPolynomial>
factorization(
const LPPolynomial& p,
bool includeConstant =
true);
99 std::vector<LPPolynomial>
irreducible_factors(
const LPPolynomial& p,
bool includeConstants =
true);
106 std::vector<LPPolynomial> square_free_factors(
const LPPolynomial& p);
113 std::vector<LPPolynomial> content_free_factors(
const LPPolynomial& p);
115 std::vector<LPPolynomial>
groebner_basis(
const std::vector<LPPolynomial>& polys);
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.
const T & derivative(const T &t, Variable, std::size_t n=1)
Computes the n'th derivative of a number, which is either the number itself (for n = 0) or zero.
auto irreducible_factors(const ContextPolynomial< Coeff, Ordering, Policies > &p, bool constants=true)
auto discriminant(const ContextPolynomial< Coeff, Ordering, Policies > &p)
cln::cl_I gcd(const cln::cl_I &a, const cln::cl_I &b)
Calculate the greatest common divisor of two integers.
cln::cl_I lcm(const cln::cl_I &a, const cln::cl_I &b)
Calculate the least common multiple of two integers.
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.
auto resultant(const ContextPolynomial< Coeff, Ordering, Policies > &p, const ContextPolynomial< Coeff, Ordering, Policies > &q)
Factors< MultivariatePolynomial< C, O, P > > factorization(const MultivariatePolynomial< C, O, P > &p, bool includeConstants=true)
Try to factorize a multivariate polynomial.
std::vector< MultivariatePolynomial< C, O, P > > groebner_basis(const std::vector< MultivariatePolynomial< C, O, P >> &polys)