carl  24.04
Computer ARithmetic Library
LPPolynomial.cpp
Go to the documentation of this file.
1 #include "LPPolynomial.h"
2 #include "helper.h"
3 #include <poly/variable_list.h>
4 
5 #include <carl-common/config.h>
6 #ifdef USE_LIBPOLY
7 
8 namespace carl {
9 
10 LPPolynomial::LPPolynomial(const LPPolynomial& rhs)
11  : m_internal(lp_polynomial_new_copy(rhs.m_internal)), m_context(rhs.m_context) {
12  assert(lp_polynomial_check_order(get_internal()));
13 }
14 
15 LPPolynomial::LPPolynomial(LPPolynomial&& rhs)
16  : m_internal(rhs.m_internal), m_context(std::move(rhs.m_context)) {
17  assert(lp_polynomial_check_order(get_internal()));
18 }
19 
20 LPPolynomial& LPPolynomial::operator=(const LPPolynomial& rhs) {
21  m_internal = lp_polynomial_new_copy(rhs.m_internal);
22  m_context = rhs.m_context;
23  assert(lp_polynomial_check_order(get_internal()));
24  return *this;
25 }
26 
27 LPPolynomial& LPPolynomial::operator=(LPPolynomial&& rhs) {
28  m_internal = rhs.m_internal;
29  m_context = std::move(rhs.m_context);
30  assert(lp_polynomial_check_order(get_internal()));
31  return *this;
32 }
33 
34 LPPolynomial::LPPolynomial(const LPContext& context)
35  : m_internal(lp_polynomial_new(context.lp_context())), m_context(context) {
36  //lp_polynomial_set_external(get_internal());
37  assert(lp_polynomial_check_order(get_internal()));
38 }
39 
40 LPPolynomial::LPPolynomial(lp_polynomial_t* p, const LPContext& context)
41  : m_internal(p), m_context(context) {
42  //lp_polynomial_set_external(get_internal());
43  assert(lp_polynomial_check_order(get_internal()));
44  assert(context.lp_context() == lp_polynomial_get_context(get_internal()));
45 }
46 
47 LPPolynomial::LPPolynomial(const LPContext& context, long val)
48  : m_internal(lp_polynomial_alloc()), m_context(context) {
49  lp_polynomial_construct_simple(get_internal(), context.lp_context(), mpz_class(val).get_mpz_t(), 0, 0);
50  //lp_polynomial_set_external(get_internal());
51  assert(lp_polynomial_check_order(get_internal()));
52 }
53 
54 LPPolynomial::LPPolynomial(const LPContext& context, const mpz_class& val)
55  : m_internal(lp_polynomial_alloc()), m_context(context) {
56  lp_polynomial_construct_simple(get_internal(), context.lp_context(), val.get_mpz_t(), lp_variable_null, 0) ;
57  //lp_polynomial_set_external(get_internal());
58  assert(lp_polynomial_check_order(get_internal()));
59 }
60 
61 LPPolynomial::LPPolynomial(const LPContext& context, const mpq_class& val) : LPPolynomial(context, carl::get_num(val)) {}
62 
63 LPPolynomial::LPPolynomial(const LPContext& context, const Variable& var, const mpz_class& coeff, unsigned int degree)
64  : m_internal(lp_polynomial_alloc()), m_context(context) {
65  lp_polynomial_construct_simple(get_internal(), context.lp_context(), mpz_class(coeff).get_mpz_t(), context.lp_variable(var), degree);
66  //lp_polynomial_set_external(get_internal());
67  assert(lp_polynomial_check_order(get_internal()));
68 }
69 
70 LPPolynomial::LPPolynomial(const LPContext& context, const Variable& var)
71  : m_internal(lp_polynomial_alloc()), m_context(context) {
72  lp_polynomial_construct_simple(get_internal(), context.lp_context(), mpz_class(1).get_mpz_t(), context.lp_variable(var), 1);
73  //lp_polynomial_set_external(get_internal());
74  assert(lp_polynomial_check_order(get_internal()));
75 }
76 
77 LPPolynomial::LPPolynomial(const LPContext& context, const Variable& mainVar, const std::initializer_list<mpz_class>& coefficients)
78  : LPPolynomial(context) {
79 
80  auto var = context.lp_variable(mainVar);
81  auto pow = coefficients.size();
82 
83  for (const mpz_class& coeff : coefficients) {
84  pow--;
85  if (is_zero(coeff)) continue;
86  lp_monomial_t t;
87  lp_monomial_construct(context.lp_context(), &t);
88  lp_monomial_set_coefficient(context.lp_context(), &t, mpz_class(coeff).get_mpz_t());
89  if (pow>0)
90  lp_monomial_push(&t, var, (unsigned int)pow);
91  lp_polynomial_add_monomial(get_internal(), &t);
92  lp_monomial_destruct(&t);
93  }
94  //lp_polynomial_set_external(get_internal());
95 }
96 
97 LPPolynomial::LPPolynomial(const LPContext& context, const Variable& mainVar, const std::vector<mpz_class>& coefficients)
98  : LPPolynomial(context) {
99 
100  auto var = context.lp_variable(mainVar);
101  auto pow = coefficients.size();
102 
103  for (const mpz_class& coeff : coefficients) {
104  pow--;
105  if (is_zero(coeff)) continue;
106  lp_monomial_t t;
107  lp_monomial_construct(context.lp_context(), &t);
108  lp_monomial_set_coefficient(context.lp_context(), &t, mpz_class(coeff).get_mpz_t());
109  if (pow>0)
110  lp_monomial_push(&t, var, (unsigned int)pow);
111  lp_polynomial_add_monomial(get_internal(), &t);
112  lp_monomial_destruct(&t);
113  }
114  //lp_polynomial_set_external(get_internal());
115 }
116 
117 LPPolynomial::LPPolynomial(const LPContext& context, const Variable& mainVar, std::vector<mpz_class>&& coefficients)
118  : LPPolynomial(context) {
119 
120  auto var = context.lp_variable(mainVar);
121  auto pow = coefficients.size();
122 
123  for (const mpz_class& coeff : coefficients) {
124  pow--;
125  if (is_zero(coeff)) continue;
126  lp_monomial_t t;
127  lp_monomial_construct(context.lp_context(), &t);
128  lp_monomial_set_coefficient(context.lp_context(), &t, mpz_class(coeff).get_mpz_t());
129  if (pow>0)
130  lp_monomial_push(&t, var, (unsigned int)pow);
131  lp_polynomial_add_monomial(get_internal(), &t);
132  lp_monomial_destruct(&t);
133  }
134  //lp_polynomial_set_external(get_internal());
135 }
136 
137 LPPolynomial::LPPolynomial(const LPContext& context, const Variable& mainVar, const std::map<unsigned int, mpz_class>& coefficients)
138  : LPPolynomial(context) {
139 
140  auto var = context.lp_variable(mainVar);
141 
142  for (const auto& coeff : coefficients) {
143  if (is_zero(coeff.second)) continue;
144  lp_monomial_t t;
145  lp_monomial_construct(context.lp_context(), &t);
146  lp_monomial_set_coefficient(context.lp_context(), &t, mpz_class(coeff.second).get_mpz_t());
147  if (coeff.first>0)
148  lp_monomial_push(&t, var, (unsigned int)coeff.first);
149  lp_polynomial_add_monomial(get_internal(), &t);
150  lp_monomial_destruct(&t);
151  }
152  //lp_polynomial_set_external(get_internal());
153 }
154 
155 bool LPPolynomial::has(const Variable& var) const {
156  lp_variable_list_t varList;
157  lp_variable_list_construct(&varList);
158  lp_polynomial_get_variables(get_internal(), &varList);
159  auto lp_variable = context().lp_variable_opt(var);
160  if (!lp_variable) return false;
161  bool contains = lp_variable_list_contains(&varList, *lp_variable);
162  lp_variable_list_destruct(&varList);
163  return contains;
164 }
165 
166 bool operator==(const LPPolynomial& lhs, const LPPolynomial& rhs) {
167  return lp_polynomial_eq(lhs.get_internal(), rhs.get_internal());
168 }
169 bool operator==(const LPPolynomial& lhs, const mpz_class& rhs) {
170  if (!is_number(lhs)) {
171  return false;
172  }
173  return lhs.constant_part() == rhs;
174 }
175 bool operator==(const mpz_class& lhs, const LPPolynomial& rhs) {
176  return rhs == lhs;
177 }
178 
179 bool operator!=(const LPPolynomial& lhs, const LPPolynomial& rhs) {
180  return !(lhs == rhs);
181 }
182 bool operator!=(const LPPolynomial& lhs, const mpz_class& rhs) {
183  return !(lhs == rhs);
184 }
185 bool operator!=(const mpz_class& lhs, const LPPolynomial& rhs) {
186  return !(lhs == rhs);
187 }
188 
189 inline auto cmp_util(const LPPolynomial& lhs, const mpz_class& rhs) {
190  lp_polynomial_t* tmp = poly_helper::construct_lp_poly(lp_polynomial_get_context(lhs.get_internal()), rhs);
191  auto res = lp_polynomial_cmp(lhs.get_internal(), tmp);
192  lp_polynomial_delete(tmp);
193  return res;
194 }
195 
196 bool operator<(const LPPolynomial& lhs, const LPPolynomial& rhs) {
197  return lp_polynomial_cmp(lhs.get_internal(), rhs.get_internal()) < 0;
198 }
199 bool operator<(const LPPolynomial& lhs, const mpz_class& rhs) {
200  return cmp_util(lhs,rhs) < 0;
201 }
202 bool operator<(const mpz_class& lhs, const LPPolynomial& rhs) {
203  return cmp_util(rhs,lhs) > 0;
204 }
205 
206 bool operator<=(const LPPolynomial& lhs, const LPPolynomial& rhs) {
207  return lp_polynomial_cmp(lhs.get_internal(), rhs.get_internal()) <= 0;
208 }
209 bool operator<=(const LPPolynomial& lhs, const mpz_class& rhs) {
210  return cmp_util(lhs,rhs) <= 0;
211 }
212 bool operator<=(const mpz_class& lhs, const LPPolynomial& rhs) {
213  return cmp_util(rhs,lhs) >= 0;
214 }
215 
216 bool operator>(const LPPolynomial& lhs, const LPPolynomial& rhs) {
217  return lp_polynomial_cmp(lhs.get_internal(), rhs.get_internal()) > 0;
218 }
219 bool operator>(const LPPolynomial& lhs, const mpz_class& rhs) {
220  return cmp_util(lhs,rhs) > 0;
221 }
222 bool operator>(const mpz_class& lhs, const LPPolynomial& rhs) {
223  return cmp_util(rhs,lhs) < 0;
224 }
225 
226 bool operator>=(const LPPolynomial& lhs, const LPPolynomial& rhs) {
227  return lp_polynomial_cmp(lhs.get_internal(), rhs.get_internal()) >= 0;
228 }
229 bool operator>=(const LPPolynomial& lhs, const mpz_class& rhs) {
230  return cmp_util(lhs,rhs) >= 0;
231 }
232 bool operator>=(const mpz_class& lhs, const LPPolynomial& rhs) {
233  return cmp_util(rhs,lhs) <= 0;
234 }
235 
236 LPPolynomial operator+(const LPPolynomial& lhs, const LPPolynomial& rhs) {
237  assert(rhs.context() == lhs.context());
238  assert(lp_polynomial_context_equal(lp_polynomial_get_context(lhs.get_internal()), lp_polynomial_get_context(rhs.get_internal())));
239  LPPolynomial result(lhs.context());
240  lp_polynomial_add(result.get_internal(), lhs.get_internal(), rhs.get_internal());
241  return result;
242 }
243 LPPolynomial operator+(const LPPolynomial& lhs, const mpz_class& rhs) {
244  return lhs + LPPolynomial(lhs.context(), rhs);
245 }
246 LPPolynomial operator+(const mpz_class& lhs, const LPPolynomial& rhs) {
247  return rhs + lhs;
248 }
249 
250 LPPolynomial operator-(const LPPolynomial& lhs, const LPPolynomial& rhs) {
251  assert(rhs.context() == lhs.context());
252  assert(lp_polynomial_context_equal(lp_polynomial_get_context(lhs.get_internal()), lp_polynomial_get_context(rhs.get_internal())));
253  LPPolynomial result(lhs.context());
254  lp_polynomial_sub(result.get_internal(), lhs.get_internal(), rhs.get_internal());
255  return result;
256 }
257 LPPolynomial operator-(const LPPolynomial& lhs, const mpz_class& rhs) {
258  return lhs - LPPolynomial(lhs.context(), rhs);
259 }
260 LPPolynomial operator-(const mpz_class& lhs, const LPPolynomial& rhs) {
261  return LPPolynomial(rhs.context(), lhs) - rhs;
262 }
263 
264 LPPolynomial operator*(const LPPolynomial& lhs, const LPPolynomial& rhs) {
265  assert(lhs.context() == rhs.context());
266  assert(lp_polynomial_context_equal(lp_polynomial_get_context(lhs.get_internal()), lp_polynomial_get_context(rhs.get_internal())));
267  LPPolynomial result(lhs.context());
268  lp_polynomial_mul(result.get_internal(), lhs.get_internal(), rhs.get_internal());
269  return result;
270 }
271 LPPolynomial operator*(const LPPolynomial& lhs, const mpz_class& rhs) {
272  return lhs * LPPolynomial(lhs.context(), rhs);
273 }
274 LPPolynomial operator*(const mpz_class& lhs, const LPPolynomial& rhs) {
275  return rhs * lhs;
276 }
277 
278 LPPolynomial& operator+=(LPPolynomial& lhs, const LPPolynomial& rhs) {
279  assert(rhs.context() == lhs.context());
280  assert(lp_polynomial_context_equal(lp_polynomial_get_context(lhs.get_internal()), lp_polynomial_get_context(rhs.get_internal())));
281  lp_polynomial_add(lhs.get_internal(), lhs.get_internal(), rhs.get_internal());
282  return lhs;
283 }
284 LPPolynomial& operator+=(LPPolynomial& lhs, const mpz_class& rhs) {
285  lp_polynomial_t* tmp = poly_helper::construct_lp_poly(lp_polynomial_get_context(lhs.get_internal()), rhs);
286  lp_polynomial_add(lhs.get_internal(), lhs.get_internal(), tmp);
287  lp_polynomial_delete(tmp);
288  return lhs;
289 }
290 
291 LPPolynomial& operator-=(LPPolynomial& lhs, const LPPolynomial& rhs) {
292  assert(rhs.context() == lhs.context());
293  assert(lp_polynomial_context_equal(lp_polynomial_get_context(lhs.get_internal()), lp_polynomial_get_context(rhs.get_internal())));
294  lp_polynomial_sub(lhs.get_internal(), lhs.get_internal(), rhs.get_internal());
295  return lhs;
296 }
297 LPPolynomial& operator-=(LPPolynomial& lhs, const mpz_class& rhs) {
298  lp_polynomial_t* tmp = poly_helper::construct_lp_poly(lp_polynomial_get_context(lhs.get_internal()), rhs);
299  lp_polynomial_sub(lhs.get_internal(), lhs.get_internal(), tmp);
300  lp_polynomial_delete(tmp);
301  return lhs;
302 }
303 
304 LPPolynomial& operator*=(LPPolynomial& lhs, const LPPolynomial& rhs) {
305  assert(rhs.context() == lhs.context());
306  assert(lp_polynomial_context_equal(lp_polynomial_get_context(lhs.get_internal()), lp_polynomial_get_context(rhs.get_internal())));
307  lp_polynomial_mul(lhs.get_internal(), lhs.get_internal(), rhs.get_internal());
308  return lhs;
309 }
310 LPPolynomial& operator*=(LPPolynomial& lhs, const mpz_class& rhs) {
311  lp_polynomial_t* tmp = poly_helper::construct_lp_poly(lp_polynomial_get_context(lhs.get_internal()), rhs);
312  lp_polynomial_mul(lhs.get_internal(), lhs.get_internal(), tmp);
313  lp_polynomial_delete(tmp);
314  return lhs;
315 }
316 
317 mpz_class LPPolynomial::coprime_factor() const {
318  // TODO: can this be done with content/primitive part?
319  struct coprime_factor_travers {
320  std::vector<mpz_class> coefficients; // coefficients of the polynomial
321  };
322 
323  auto getCoeffs = [](const lp_polynomial_context_t* /*ctx*/,
324  lp_monomial_t* m,
325  void* d) {
326  coprime_factor_travers& v = *static_cast<coprime_factor_travers*>(d);
327  v.coefficients.push_back(*reinterpret_cast<mpz_class*>(&m->a));
328  };
329 
330  // first get the coefficients of every monomial
331  coprime_factor_travers travers;
332  lp_polynomial_traverse(get_internal(), getCoeffs, &travers);
333 
334  if (travers.coefficients.size() == 0) {
335  return 0;
336  }
337  mpz_class res = travers.coefficients[0];
338  for (size_t i = 1; i < travers.coefficients.size(); i++) {
339  res = gcd(res, travers.coefficients[i]);
340  }
341 
342  return res;
343 }
344 
345 LPPolynomial LPPolynomial::coprime_coefficients() const {
346  mpz_class g = coprime_factor();
347  if (g == 1) return *this;
348  lp_polynomial_t* temp = poly_helper::construct_lp_poly(lp_polynomial_get_context(get_internal()), g);
349  lp_polynomial_t* res = lp_polynomial_new(context().lp_context());
350  lp_polynomial_div(res, get_internal(), temp);
351  lp_polynomial_delete(temp);
352  return LPPolynomial(res, context());
353 }
354 
355 std::size_t LPPolynomial::total_degree() const {
356 
357  struct degree_travers {
358  std::size_t degree = 0;
359  };
360 
361  auto getDegree = [](const lp_polynomial_context_t* /*ctx*/,
362  lp_monomial_t* m,
363  void* d) {
364  degree_travers& v = *static_cast<degree_travers*>(d);
365 
366  size_t current_degree = 0;
367  // iterate over the number of variables and add up their degrees
368  for (size_t i = 0; i < m->n; i++) {
369  current_degree += m->p[i].d;
370  }
371  v.degree = std::max(v.degree, current_degree);
372  };
373 
374  degree_travers travers;
375  lp_polynomial_traverse(get_internal(), getDegree, &travers);
376 
377  return travers.degree;
378 }
379 
380 std::size_t LPPolynomial::degree(Variable::Arg var) const {
381  struct degree_travers {
382  std::size_t degree = 0;
383  lp_variable_t var; // the variable we are looking for
384  };
385 
386  auto getDegree = [](const lp_polynomial_context_t* /*ctx*/,
387  lp_monomial_t* m,
388  void* d) {
389  degree_travers& v = *static_cast<degree_travers*>(d);
390 
391  size_t current_degree = 0;
392  // iterate over the number of variables and add up their degrees
393  for (size_t i = 0; i < m->n; i++) {
394  if (m->p[i].x == v.var) {
395  current_degree = m->p[i].d;
396  break;
397  }
398  }
399  v.degree = std::max(v.degree, current_degree);
400  };
401 
402  degree_travers travers;
403  travers.var = context().lp_variable(var);
404  lp_polynomial_traverse(get_internal(), getDegree, &travers);
405 
406  return travers.degree;
407 }
408 
409 std::vector<std::size_t> LPPolynomial::monomial_total_degrees() const {
410  struct degree_travers {
411  std::vector<std::size_t> degree;
412  };
413 
414  auto getDegree = [](const lp_polynomial_context_t* /*ctx*/,
415  lp_monomial_t* m,
416  void* d) {
417  degree_travers& v = *static_cast<degree_travers*>(d);
418 
419  size_t current_degree = 0;
420  // iterate over the number of variables and add up their degrees
421  for (size_t i = 0; i < m->n; i++) {
422  current_degree += m->p[i].d;
423  }
424  v.degree.push_back(current_degree);
425  };
426 
427  degree_travers travers;
428  lp_polynomial_traverse(get_internal(), getDegree, &travers);
429 
430  return travers.degree;
431 }
432 
433 std::vector<std::size_t> LPPolynomial::monomial_degrees(Variable::Arg var) const {
434  struct degree_travers {
435  std::vector<std::size_t> degree;
436  lp_variable_t var; // the variable we are looking for
437  };
438 
439  auto getDegree = [](const lp_polynomial_context_t* /*ctx*/,
440  lp_monomial_t* m,
441  void* d) {
442  degree_travers& v = *static_cast<degree_travers*>(d);
443 
444  size_t current_degree = 0;
445  // iterate over the number of variables and add up their degrees
446  for (size_t i = 0; i < m->n; i++) {
447  if (m->p[i].x == v.var) {
448  current_degree = m->p[i].d;
449  break;
450  }
451  }
452  v.degree.push_back(current_degree);
453  };
454 
455  degree_travers travers;
456  travers.var = context().lp_variable(var);
457  lp_polynomial_traverse(get_internal(), getDegree, &travers);
458 
459  return travers.degree;
460 }
461 
462 mpz_class LPPolynomial::unit_part() const {
463  //As we can only have integer coefficients, they do not form a field
464  //Thus the unit part is the sign of the leading coefficient, if it is not zero
465  //Is the Poly is zero unit part is one
466  if(is_zero(*this)) {
467  return 1 ;
468  }
469  return lp_polynomial_lc_sgn(get_internal()) ;
470 }
471 
472 LPPolynomial LPPolynomial::normalized() const {
473  auto res = coprime_coefficients();
474  auto unit = res.unit_part() ;
475  assert(!is_zero(unit)) ;
476  return res * unit ;
477 
478  /*
479  auto unit = unit_part() ;
480  assert(!is_zero(unit)) ;
481  return (*this) * unit ;
482  */
483 }
484 
485 LPPolynomial LPPolynomial::coeff(Variable::Arg var, std::size_t exp) const {
486  struct coeff_travers {
487  std::vector<lp_monomial_t> coeff;
488  const lp_polynomial_context_t* ctx; // context for the newly created monomials
489  lp_variable_t var; // the variable we are looking for
490  std::size_t exp; // the exponent we are looking for
491  };
492 
493 
494  auto getCoeff = [](const lp_polynomial_context_t* /*ctx*/,
495  lp_monomial_t* m,
496  void* d) {
497  coeff_travers& v = *static_cast<coeff_travers*>(d);
498 
499  bool found = false;
500  // iterate each monomials, and add the ones to add
501  for (size_t i = 0; i < m->n; i++) {
502  if (m->p[i].x == v.var && m->p[i].d == v.exp) {
503  found = true;
504  break;
505  }
506  }
507 
508  if (!found) {
509  return;
510  }
511 
512  // Make a copy (without var^exp) of each monomial and add it to the vector
513  lp_monomial_t new_monomial;
514  lp_monomial_construct(v.ctx, &new_monomial);
515  new_monomial.n = m->n -1 ; // copy the number of variables (-1 because we remove var^exp)
516  new_monomial.capacity = m->capacity ; // copy the capacity
517  lp_integer_assign(v.ctx->K, &new_monomial.a ,&m->a); // copy the coefficient
518  new_monomial.p = (power_t*)realloc(new_monomial.p, sizeof(power_t) * new_monomial.capacity); //allocate the memory for the power array
519 
520  size_t current_counter = 0 ;
521  for(size_t i = 0; i < m->n; i++){
522  if(m->p[i].x == v.var && m->p[i].d == v.exp){
523  continue;
524  }
525  new_monomial.p[current_counter].x = m->p[i].x;
526  new_monomial.p[current_counter].d = m->p[i].d;
527  current_counter++;
528  }
529  assert(current_counter == new_monomial.n);
530  v.coeff.push_back(std::move(new_monomial));
531  };
532 
533  coeff_travers travers;
534  travers.var = context().lp_variable(var);
535  travers.exp = exp;
536  travers.ctx = lp_polynomial_get_context(get_internal());
537  lp_polynomial_traverse(get_internal(), getCoeff, &travers);
538 
539  LPPolynomial res(context());
540  for (auto m : travers.coeff) {
541  lp_polynomial_add_monomial(res.get_internal(), &m);
542  }
543 
544  //free the memory allocated for the monomials
545  for(auto& m : travers.coeff){
546  lp_monomial_destruct(&m);
547  }
548 
549  return res;
550 }
551 
552 bool LPPolynomial::is_normal() const {
553  return carl::is_one(this->unit_part()) ;
554  //return carl::is_one(carl::abs(this->unit_part())) ;
555 }
556 
557 std::ostream& operator<<(std::ostream& os, const LPPolynomial& p) {
558  os << lp_polynomial_to_string(p.get_internal());
559  return os;
560 }
561 
562 void LPPolynomial::set_context(const LPContext& c) {
563  for (auto& v : variables(*this)) assert(c.has(v));
564  if (context() == c) return;
565 
566  bool reorder = !(c.is_extension_of(context()) || context().is_extension_of(c));
567  m_context = c;
568  lp_polynomial_set_context(get_internal(), m_context.lp_context());
569  if (reorder) {
570  lp_polynomial_ensure_order(get_internal());
571  }
572  assert(lp_polynomial_check_order(get_internal()));
573 }
574 
575 } // namespace carl
576 
577 #endif
std::ostream & operator<<(std::ostream &os, const GbBenchmark< C, O, P > &b)
carl is the main namespace for the library.
bool operator>(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
Interval< Number > operator+(const Interval< Number > &lhs, const Interval< Number > &rhs)
Operator for the addition of two intervals.
Definition: operators.h:261
bool operator<(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
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
Interval< Number > exp(const Interval< Number > &i)
Definition: Exponential.h:10
bool is_zero(const Interval< Number > &i)
Check if this interval is a point-interval containing 0.
Definition: Interval.h:1453
Interval< Number > operator*(const Interval< Number > &lhs, const Interval< Number > &rhs)
Operator for the multiplication of two intervals.
Definition: operators.h:386
cln::cl_I get_num(const cln::cl_RA &n)
Extract the numerator from a fraction.
Definition: operations.h:60
Interval< Number > & operator*=(Interval< Number > &lhs, const Interval< Number > &rhs)
Operator for the multiplication of an interval and a number with assignment.
Definition: operators.h:425
Interval< Number > & operator+=(Interval< Number > &lhs, const Interval< Number > &rhs)
Operator for the addition of an interval and a number with assignment.
Definition: operators.h:295
Interval< Number > operator-(const Interval< Number > &rhs)
Unary minus.
Definition: operators.h:318
bool operator!=(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
bool operator<=(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
bool operator==(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
bool operator>=(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
Interval< Number > & operator-=(Interval< Number > &lhs, const Interval< Number > &rhs)
Operator for the subtraction of two intervals with assignment.
Definition: operators.h:362
bool is_number(double d)
Definition: operations.h:54
void variables(const BasicConstraint< Pol > &c, carlVariables &vars)
Interval< Number > pow(const Interval< Number > &i, Integer exp)
Definition: Power.h:11
auto total_degree(const Monomial &m)
Gives the total degree, i.e.
Definition: Degree.h:24
bool is_one(const Interval< Number > &i)
Check if this interval is a point-interval containing 1.
Definition: Interval.h:1462
lp_polynomial_t * construct_lp_poly(const lp_polynomial_context_t *c, lp_variable_t v)
Definition: helper.h:11