10 inline Factors<LPPolynomial>
factorization(
const LPPolynomial& p,
const CoCoAAdaptorLP& adaptor,
bool includeConstant) {
12 CARL_LOG_FATAL(
"carl.poly",
"factorization is not supported without libcocoa");
14 return adaptor.factorize(p, includeConstant);
22 Factors<LPPolynomial>
factorization(
const LPPolynomial& p,
bool includeConstant) {
23 CoCoAAdaptorLP adaptor = CoCoAAdaptorLP(p.context());
27 inline std::vector<LPPolynomial>
irreducible_factors(
const LPPolynomial& p,
const CoCoAAdaptorLP& adaptor,
bool includeConstants) {
29 CARL_LOG_FATAL(
"carl.poly",
"factorization is not supported without libcocoa");
33 if (includeConstants) {
38 }
else if (p.total_degree() == 1) {
42 return adaptor.irreducible_factors(p, includeConstants);
45 std::vector<LPPolynomial>
irreducible_factors(
const LPPolynomial& p,
bool includeConstants) {
46 CoCoAAdaptorLP adaptor = CoCoAAdaptorLP(p.context());
50 std::vector<LPPolynomial> square_free_factors(
const LPPolynomial& p) {
51 lp_polynomial_t** factors =
nullptr;
52 std::size_t* multiplicities =
nullptr;
54 lp_polynomial_factor_square_free(p.get_internal(), &factors, &multiplicities, &size);
55 std::vector<LPPolynomial> res;
56 for (std::size_t i = 0; i < size; ++i) {
57 res.emplace_back(factors[i], p.context());
64 std::vector<LPPolynomial> content_free_factors(
const LPPolynomial& p) {
65 lp_polynomial_t** factors =
nullptr;
66 std::size_t* multiplicities =
nullptr;
68 lp_polynomial_factor_content_free(p.get_internal(), &factors, &multiplicities, &size);
69 std::vector<LPPolynomial> res;
70 for (std::size_t i = 0; i < size; ++i) {
71 res.emplace_back(factors[i], p.context());
78 std::vector<LPPolynomial>
groebner_basis(
const std::vector<LPPolynomial>& polys) {
79 if (polys.size() <= 1)
return polys;
80 CoCoAAdaptorLP adaptor = CoCoAAdaptorLP(polys.at(0).context());
81 return adaptor.GBasis(polys);
#define CARL_LOG_FATAL(channel, msg)
carl is the main namespace for the library.
auto irreducible_factors(const ContextPolynomial< Coeff, Ordering, Policies > &p, bool constants=true)
bool is_constant(const ContextPolynomial< Coeff, Ordering, Policies > &p)
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)