carl  24.04
Computer ARithmetic Library
Term.h
Go to the documentation of this file.
1 /*
2  * @file Term.h
3  * @ingroup multirp
4  * @author Sebastian Junges
5  * @author Florian Corzilius
6  */
7 
8 #pragma once
9 
10 #include "Monomial.h"
11 #include "MonomialPool.h"
13 
14 #include <memory>
15 
16 namespace carl {
17 
18 /**
19  * Represents a single term, that is a numeric coefficient and a monomial.
20  * @ingroup multirp
21  */
22 template<typename Coefficient>
23 class Term {
24 private:
25  using CoefficientType = Coefficient;
28 
29 public:
30  /**
31  * Default constructor. Constructs a term of value zero.
32  */
33  Term() = default;
34  /**
35  * Constructs a term of value \f$ c \f$.
36  * @param c Coefficient.
37  */
38  explicit Term(const Coefficient& c);
39  /**
40  * Constructs a term of value \f$ v \f$.
41  * @param v Variable.
42  */
43  explicit Term(Variable v);
44  /**
45  * Constructs a term of value \f$ m \f$.
46  * @param m Monomial pointer.
47  */
48  explicit Term(Monomial::Arg m);
49  /**
50  * Constructs a term of value \f$ m \f$.
51  * @param m Monomial pointer.
52  */
53  explicit Term(Monomial::Arg&& m);
54 
55  /**
56  * Constructs a term of value \f$ c \cdot m \f$.
57  * @param c Coefficient.
58  * @param m Monomial pointer.
59  */
60  Term(const Coefficient& c, Monomial::Arg m);
61 
62  /**
63  * Constructs a term of value \f$ c \cdot m \f$.
64  * @param c Coefficient.
65  * @param m Monomial pointer.
66  */
67  Term(Coefficient&& c, Monomial::Arg&& m);
68  /**
69  * Constructs a term of value \f$ c \cdot v^e \f$.
70  * @param c Coefficient.
71  * @param v Variable.
72  * @param e Exponent.
73  */
74  Term(const Coefficient& c, Variable v, uint e);
75 
76  /**
77  * Get the coefficient.
78  * @return Coefficient.
79  */
80  Coefficient& coeff() {
81  return mCoeff;
82  }
83  const Coefficient& coeff() const {
84  return mCoeff;
85  }
86 
87  /**
88  * Get the monomial.
89  * @return Monomial.
90  */
92  return mMonomial;
93  }
94  const Monomial::Arg& monomial() const {
95  return mMonomial;
96  }
97  /**
98  * Gives the total degree, i.e. the sum of all exponents.
99  * @return Total degree.
100  */
101  uint tdeg() const {
102  if (!mMonomial) return 0;
103  return mMonomial->tdeg();
104  }
105 
106  /**
107  * Checks whether the term is zero.
108  * @return
109  */
110  [[deprecated("use carl::is_zero(t) instead.")]]
111  bool is_zero() const {
112  return carl::is_zero(mCoeff); //change this to mCoeff.is_zero() at some point
113  }
114 
115  /**
116  * Checks whether the term equals one.
117  * @return
118  */
119  [[deprecated("use carl::is_one(t) instead.")]]
120  bool is_one() const {
121  return is_constant() && carl::is_one(mCoeff); //change this to mCoeff.is_one() at some point
122  }
123  /**
124  * Checks whether the monomial is a constant.
125  * @return
126  */
127  bool is_constant() const {
128  return !mMonomial;
129  }
130 
131  /**
132  * @return true, if the image of this term is integer-valued.
133  */
134  bool integer_valued() const {
135  if (!carl::is_integer(mCoeff)) return false;
136  return !mMonomial || mMonomial->integer_valued();
137  }
138 
139  /**
140  * Checks whether the monomial has exactly the degree one.
141  * @return
142  */
143  bool is_linear() const {
144  if (!mMonomial) return true;
145  return mMonomial->is_linear();
146  }
147  /**
148  *
149  * @return
150  */
151  std::size_t num_variables() const {
152  if (!mMonomial) return 0;
153  return mMonomial->num_variables();
154  }
155 
156  /**
157  * @param v The variable to check for its occurrence.
158  * @return true, if the variable occurs in this term.
159  */
160  bool has(Variable v) const {
161  if (!mMonomial) return false;
162  return mMonomial->has(v);
163  }
164 
165  /**
166  * Removes the given variable from the term.
167  */
169  return Term(coeff(), monomial()->drop_variable(v));
170  }
171 
172  /**
173  * Checks if the monomial is either a constant or the only variable occuring is the variable v.
174  * @param v The variable which may occur.
175  * @return true if no variable occurs, or just v occurs.
176  */
178  if (!mMonomial) return true;
179  return mMonomial->has_no_other_variable(v);
180  }
181 
182  bool is_single_variable() const {
183  if (!mMonomial) return false;
184  return mMonomial->is_linear();
185  }
186  /**
187  * For terms with exactly one variable, get this variable.
188  * @return The only variable occuring in the term.
189  */
191  assert(num_variables() == 1);
192  return mMonomial->single_variable();
193  }
194 
195  /**
196  * Checks if the term is a square.
197  * @return If this is square.
198  */
199  bool is_square() const {
200  return (mCoeff >= CoefficientType(0)) && ((!mMonomial) || mMonomial->is_square());
201  }
202 
203  /**
204  * Set the term to zero with the canonical representation.
205  */
206  void clear() {
208  mMonomial = nullptr;
209  }
210 
211  /**
212  * Negates the term by negating the coefficient.
213  */
214  void negate() {
215  mCoeff = -mCoeff;
216  }
217 
218  /**
219  *
220  * @param c a non-zero coefficient.
221  * @return
222  */
223  [[deprecated("Use carl::divide() instead.")]]
224  Term divide(const Coefficient& c) const;
225  [[deprecated("Use carl::divide() instead.")]]
226  bool divide(const Coefficient& c, Term& res) const;
227  [[deprecated("Use carl::divide() instead.")]]
228  bool divide(Variable v, Term& res) const;
229 
230  bool divide(const Monomial::Arg& m, Term& res) const;
231 
232  bool divide(const Term& t, Term& res) const;
233 
235 
236  /**
237  * Calculates the square root of this term.
238  * Returns true, iff the term is a square as checked by is_square().
239  * In that case, res will changed to be the square root.
240  * Otherwise, res is undefined.
241  * @param res Square root of this term.
242  * @return If square root could be calculated.
243  */
244  bool sqrt(Term& res) const;
245 
246  template<typename C = Coefficient, EnableIf<is_field_type<C>> = dummy>
247  bool divisible(const Term& t) const;
248  template<typename C = Coefficient, DisableIf<is_field_type<C>> = dummy>
249  bool divisible(const Term& t) const;
250 
251  bool is_consistent() const;
252 
253  /// @name Division operators
254  /// @{
255  /**
256  * Perform a division involving a term.
257  * @param lhs Left hand side.
258  * @param rhs Right hand side.
259  * @return `lhs / rhs`
260  */
261  template<typename Coeff>
262  friend const Term<Coeff> operator/(const Term<Coeff>& lhs, uint rhs);
263  /// @}
264 
265  /**
266  * Streaming operator for Term.
267  * @param os Output stream.
268  * @param rhs Term.
269  * @return `os`
270  */
271  template<typename Coeff>
272  friend std::ostream& operator<<(std::ostream& os, const Term<Coeff>& rhs);
273 
274  /**
275  * Checks if two terms have the same monomial.
276  * @param lhs First term.
277  * @param rhs Second term.
278  * @return If both terms have the same monomial.
279  */
280  static bool monomialEqual(const Term& lhs, const Term& rhs) {
281  return lhs.mMonomial == rhs.mMonomial;
282  }
283  static bool monomialEqual(const std::shared_ptr<const Term>& lhs, const std::shared_ptr<const Term>& rhs) {
284  if (lhs == rhs) return true;
285  if (lhs && rhs) return monomialEqual(*lhs, *rhs);
286  return false;
287  }
288  static bool monomialLess(const Term& lhs, const Term& rhs) {
289  return lhs.mMonomial < rhs.mMonomial;
290  }
291  static bool monomialLess(const std::shared_ptr<const Term>& lhs, const std::shared_ptr<const Term>& rhs) {
292  if (lhs && rhs) return monomialLess(*lhs, *rhs);
293  return !lhs;
294  }
295 };
296 
297 /**
298  * Checks whether a term is zero.
299  */
300 template<typename Coeff>
301 inline bool is_zero(const Term<Coeff>& term) {
302  return carl::is_zero(term.coeff());
303 }
304 
305 /// Add the variables of the given term to the variables.
306 template<typename Coeff>
307 void variables(const Term<Coeff>& t, carlVariables& vars) {
308  if (t.monomial()) variables(*t.monomial(), vars);
309 }
310 
311 /**
312  * Checks whether a term is one.
313  */
314 template<typename Coeff>
315 inline bool is_one(const Term<Coeff>& term) {
316  return term.is_constant() && carl::is_one(term.coeff());
317 }
318 
319 template<typename Coeff>
321  return Term<Coeff>(-rhs.coeff(), rhs.monomial());
322 }
323 
324 /// @name In-place multiplication operators
325 /// @{
326 /**
327  * Multiply a term with something and return the changed term.
328  * @param lhs Left hand side.
329  * @param rhs Right hand side.
330  * @return Changed `lhs`.
331  */
332 template<typename Coeff>
334  if (carl::is_zero(rhs)) {
335  lhs.clear();
336  } else {
337  lhs.coeff() *= rhs;
338  }
339  return lhs;
340 }
341 template<typename Coeff>
343  if (carl::is_zero(lhs.coeff())) {
344  return lhs;
345  }
346  if (lhs.monomial()) {
347  lhs.monomial() = lhs.monomial() * rhs;
348  } else {
349  lhs.monomial() = createMonomial(rhs, 1);
350  }
351  return lhs;
352 }
353 template<typename Coeff>
355  if (carl::is_zero(lhs.coeff())) {
356  return lhs;
357  }
358  if (lhs.monomial()) {
359  lhs.monomial() = lhs.monomial() * rhs;
360  } else {
361  lhs.monomial() = rhs;
362  }
363  return lhs;
364 }
365 template<typename Coeff>
367  if (carl::is_zero(lhs.coeff())) {
368  return lhs;
369  }
370  if (carl::is_zero(rhs.coeff())) {
371  lhs.clear();
372  return lhs;
373  }
374  lhs.monomial() = lhs.monomial() * rhs.monomial();
375  lhs.coeff() *= rhs.coeff();
376  return lhs;
377 }
378 /// @}
379 
380 /// @name Comparison operators
381 /// @{
382 /**
383  * Compares two arguments where one is a term and the other is either a term, a monomial or a variable.
384  * @param lhs First argument.
385  * @param rhs Second argument.
386  * @return `lhs ~ rhs`, `~` being the relation that is checked.
387  */
388 template<typename Coeff>
389 inline bool operator==(const Term<Coeff>& lhs, const Term<Coeff>& rhs);
390 template<typename Coeff>
391 inline bool operator==(const Term<Coeff>& lhs, const Monomial& rhs);
392 template<typename Coeff>
393 inline bool operator==(const Term<Coeff>& lhs, Variable rhs);
394 template<typename Coeff>
395 inline bool operator==(const Term<Coeff>& lhs, const Coeff& rhs);
396 template<typename Coeff>
397 inline bool operator==(const Monomial::Arg& lhs, const Term<Coeff>& rhs) {
398  return rhs == lhs;
399 }
400 template<typename Coeff>
401 inline bool operator==(Variable lhs, const Term<Coeff>& rhs) {
402  return rhs == lhs;
403 }
404 template<typename Coeff>
405 inline bool operator==(const Coeff& lhs, const Term<Coeff>& rhs) {
406  return rhs == lhs;
407 }
408 
409 template<typename Coeff>
410 inline bool operator!=(const Term<Coeff>& lhs, const Term<Coeff>& rhs) {
411  return !(lhs == rhs);
412 }
413 template<typename Coeff>
414 inline bool operator!=(const Term<Coeff>& lhs, const Monomial::Arg& rhs) {
415  return !(lhs == rhs);
416 }
417 template<typename Coeff>
418 inline bool operator!=(const Term<Coeff>& lhs, Variable rhs) {
419  return !(lhs == rhs);
420 }
421 template<typename Coeff>
422 inline bool operator!=(const Term<Coeff>& lhs, const Coeff& rhs) {
423  return !(lhs == rhs);
424 }
425 template<typename Coeff>
426 inline bool operator!=(const Monomial::Arg& lhs, const Term<Coeff>& rhs) {
427  return !(lhs == rhs);
428 }
429 template<typename Coeff>
430 inline bool operator!=(Variable lhs, const Term<Coeff>& rhs) {
431  return !(lhs == rhs);
432 }
433 template<typename Coeff>
434 inline bool operator!=(const Coeff& lhs, const Term<Coeff>& rhs) {
435  return !(lhs == rhs);
436 }
437 
438 template<typename Coeff>
439 bool operator<(const Term<Coeff>& lhs, const Term<Coeff>& rhs);
440 template<typename Coeff>
441 bool operator<(const Term<Coeff>& lhs, const Monomial::Arg& rhs);
442 template<typename Coeff>
443 bool operator<(const Term<Coeff>& lhs, Variable rhs);
444 template<typename Coeff>
445 bool operator<(const Term<Coeff>& lhs, const Coeff& rhs);
446 template<typename Coeff>
447 bool operator<(const Monomial::Arg& lhs, const Term<Coeff>& rhs);
448 template<typename Coeff>
449 bool operator<(Variable lhs, const Term<Coeff>& rhs);
450 template<typename Coeff>
451 bool operator<(const Coeff& lhs, const Term<Coeff>& rhs);
452 
453 template<typename Coeff>
454 inline bool operator<=(const Term<Coeff>& lhs, const Term<Coeff>& rhs) {
455  return !(rhs < lhs);
456 }
457 template<typename Coeff>
458 inline bool operator<=(const Term<Coeff>& lhs, const Monomial::Arg& rhs) {
459  return !(rhs < lhs);
460 }
461 template<typename Coeff>
462 inline bool operator<=(const Term<Coeff>& lhs, Variable rhs) {
463  return !(rhs < lhs);
464 }
465 template<typename Coeff>
466 inline bool operator<=(const Term<Coeff>& lhs, const Coeff& rhs) {
467  return !(rhs < lhs);
468 }
469 template<typename Coeff>
470 inline bool operator<=(const Monomial::Arg& lhs, const Term<Coeff>& rhs) {
471  return !(rhs < lhs);
472 }
473 template<typename Coeff>
474 inline bool operator<=(Variable lhs, const Term<Coeff>& rhs) {
475  return !(rhs < lhs);
476 }
477 template<typename Coeff>
478 inline bool operator<=(const Coeff& lhs, const Term<Coeff>& rhs) {
479  return !(rhs < lhs);
480 }
481 
482 template<typename Coeff>
483 inline bool operator>(const Term<Coeff>& lhs, const Term<Coeff>& rhs) {
484  return rhs < lhs;
485 }
486 template<typename Coeff>
487 inline bool operator>(const Term<Coeff>& lhs, const Monomial::Arg& rhs) {
488  return rhs < lhs;
489 }
490 template<typename Coeff>
491 inline bool operator>(const Term<Coeff>& lhs, Variable rhs) {
492  return rhs < lhs;
493 }
494 template<typename Coeff>
495 inline bool operator>(const Term<Coeff>& lhs, const Coeff& rhs) {
496  return rhs < lhs;
497 }
498 template<typename Coeff>
499 inline bool operator>(const Monomial::Arg& lhs, const Term<Coeff>& rhs) {
500  return rhs < lhs;
501 }
502 template<typename Coeff>
503 inline bool operator>(Variable lhs, const Term<Coeff>& rhs) {
504  return rhs < lhs;
505 }
506 template<typename Coeff>
507 inline bool operator>(const Coeff& lhs, const Term<Coeff>& rhs) {
508  return rhs < lhs;
509 }
510 
511 template<typename Coeff>
512 inline bool operator>=(const Term<Coeff>& lhs, const Term<Coeff>& rhs) {
513  return rhs <= lhs;
514 }
515 template<typename Coeff>
516 inline bool operator>=(const Term<Coeff>& lhs, const Monomial::Arg& rhs) {
517  return rhs <= lhs;
518 }
519 template<typename Coeff>
520 inline bool operator>=(const Term<Coeff>& lhs, Variable rhs) {
521  return rhs <= lhs;
522 }
523 template<typename Coeff>
524 inline bool operator>=(const Term<Coeff>& lhs, const Coeff& rhs) {
525  return rhs <= lhs;
526 }
527 template<typename Coeff>
528 inline bool operator>=(const Monomial::Arg& lhs, const Term<Coeff>& rhs) {
529  return rhs <= lhs;
530 }
531 template<typename Coeff>
532 inline bool operator>=(Variable lhs, const Term<Coeff>& rhs) {
533  return rhs <= lhs;
534 }
535 template<typename Coeff>
536 inline bool operator>=(const Coeff& lhs, const Term<Coeff>& rhs) {
537  return rhs <= lhs;
538 }
539 /// @}
540 
541 /// @name Multiplication operators
542 /// @{
543 /**
544  * Perform a multiplication involving a term.
545  * @param lhs Left hand side.
546  * @param rhs Right hand side.
547  * @return `lhs * rhs`
548  */
549 template<typename Coeff>
550 inline Term<Coeff> operator*(Term<Coeff> lhs, const Term<Coeff>& rhs) {
551  return lhs *= rhs;
552 }
553 template<typename Coeff>
555  return lhs *= rhs;
556 }
557 template<typename Coeff>
559  return lhs *= rhs;
560 }
561 template<typename Coeff>
562 inline Term<Coeff> operator*(Term<Coeff> lhs, const Coeff& rhs) {
563  return lhs *= rhs;
564 }
565 template<typename Coeff>
566 inline Term<Coeff> operator*(const Monomial::Arg& lhs, const Term<Coeff>& rhs) {
567  return rhs * lhs;
568 }
569 template<typename Coeff, EnableIf<carl::is_number_type<Coeff>> = dummy>
570 inline Term<Coeff> operator*(const Monomial::Arg& lhs, const Coeff& rhs) {
571  return Term<Coeff>(rhs, lhs);
572 }
573 template<typename Coeff>
574 inline Term<Coeff> operator*(Variable lhs, const Term<Coeff>& rhs) {
575  return rhs * lhs;
576 }
577 template<typename Coeff>
578 inline Term<Coeff> operator*(Variable lhs, const Coeff& rhs) {
579  return Term<Coeff>(rhs, lhs, 1);
580 }
581 template<typename Coeff>
582 inline Term<Coeff> operator*(const Coeff& lhs, const Term<Coeff>& rhs) {
583  return rhs * lhs;
584 }
585 template<typename Coeff, EnableIf<carl::is_number_type<Coeff>> = dummy>
586 inline Term<Coeff> operator*(const Coeff& lhs, const Monomial::Arg& rhs) {
587  return rhs * lhs;
588 }
589 template<typename Coeff>
590 inline Term<Coeff> operator*(const Coeff& lhs, Variable rhs) {
591  return rhs * lhs;
592 }
593 template<typename Coeff, EnableIf<carl::is_subset_of_rationals_type<Coeff>> = dummy>
594 inline Term<Coeff> operator/(const Term<Coeff>& lhs, const Coeff& rhs) {
595  return lhs * reciprocal(rhs);
596 }
597 template<typename Coeff, EnableIf<carl::is_subset_of_rationals_type<Coeff>> = dummy>
598 inline Term<Coeff> operator/(const Monomial::Arg& lhs, const Coeff& rhs) {
599  return lhs * reciprocal(rhs);
600 }
601 template<typename Coeff, EnableIf<carl::is_subset_of_rationals_type<Coeff>> = dummy>
602 inline Term<Coeff> operator/(Variable& lhs, const Coeff& rhs) {
603  return lhs * reciprocal(rhs);
604 }
605 /// @}
606 
607 } // namespace carl
608 
609 namespace std {
610 
611 /**
612  * Specialization of `std::hash` for a Term.
613  */
614 template<typename Coefficient>
615 struct hash<carl::Term<Coefficient>> {
616  /**
617  * Calculates the hash of a Term.
618  * @param term Term.
619  * @return Hash of term.
620  */
621  std::size_t operator()(const carl::Term<Coefficient>& term) const {
622  if (term.is_constant()) {
623  return carl::hash_all(term.coeff());
624  } else {
625  return carl::hash_all(term.coeff(), *term.monomial());
626  }
627  }
628 };
629 } // namespace std
630 
631 #include "Term.tpp"
carl is the main namespace for the library.
Monomial::Arg createMonomial(T &&... t)
Definition: MonomialPool.h:168
bool operator>(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
std::uint64_t uint
Definition: numbers.h:16
Interval< Number > operator/(const Interval< Number > &lhs, const Number &rhs)
Operator for the division of an interval and a number.
Definition: operators.h:453
bool operator<(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
cln::cl_RA reciprocal(const cln::cl_RA &a)
Definition: operations.h:546
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
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
typename UnderlyingNumberType< P >::type Coeff
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 is_integer(const Interval< Number > &n)
Definition: Interval.h:1445
bool operator>=(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
std::size_t hash_all(Args &&... args)
Hashes an arbitrary number of values.
Definition: hash.h:71
void variables(const BasicConstraint< Pol > &c, carlVariables &vars)
bool is_one(const Interval< Number > &i)
Check if this interval is a point-interval containing 1.
Definition: Interval.h:1462
A Variable represents an algebraic variable that can be used throughout carl.
Definition: Variable.h:85
static const T & get()
Definition: constants.h:42
The general-purpose monomials.
Definition: Monomial.h:59
std::shared_ptr< const Monomial > Arg
Definition: Monomial.h:62
Represents a single term, that is a numeric coefficient and a monomial.
Definition: Term.h:23
Term divide(const Coefficient &c) const
Monomial::Arg mMonomial
Definition: Term.h:27
bool divide(const Term &t, Term &res) const
Term drop_variable(Variable v) const
Removes the given variable from the term.
Definition: Term.h:168
std::size_t num_variables() const
Definition: Term.h:151
Term()=default
Default constructor.
void negate()
Negates the term by negating the coefficient.
Definition: Term.h:214
bool is_linear() const
Checks whether the monomial has exactly the degree one.
Definition: Term.h:143
Coefficient & coeff()
Get the coefficient.
Definition: Term.h:80
static bool monomialLess(const std::shared_ptr< const Term > &lhs, const std::shared_ptr< const Term > &rhs)
Definition: Term.h:291
bool is_one() const
Checks whether the term equals one.
Definition: Term.h:120
bool sqrt(Term &res) const
Calculates the square root of this term.
Term(Variable v)
Constructs a term of value .
Term(Monomial::Arg &&m)
Constructs a term of value .
bool divide(const Coefficient &c, Term &res) const
bool has_no_other_variable(Variable v) const
Checks if the monomial is either a constant or the only variable occuring is the variable v.
Definition: Term.h:177
static bool monomialEqual(const std::shared_ptr< const Term > &lhs, const std::shared_ptr< const Term > &rhs)
Definition: Term.h:283
bool divisible(const Term &t) const
Coefficient CoefficientType
Definition: Term.h:25
bool is_single_variable() const
Definition: Term.h:182
static bool monomialEqual(const Term &lhs, const Term &rhs)
Checks if two terms have the same monomial.
Definition: Term.h:280
bool is_consistent() const
void clear()
Set the term to zero with the canonical representation.
Definition: Term.h:206
Term(const Coefficient &c, Monomial::Arg m)
Constructs a term of value .
Term calcLcmAndDivideBy(const Monomial::Arg &m) const
friend std::ostream & operator<<(std::ostream &os, const Term< Coeff > &rhs)
Streaming operator for Term.
bool integer_valued() const
Definition: Term.h:134
static bool monomialLess(const Term &lhs, const Term &rhs)
Definition: Term.h:288
Variable single_variable() const
For terms with exactly one variable, get this variable.
Definition: Term.h:190
bool divide(const Monomial::Arg &m, Term &res) const
Term(Coefficient &&c, Monomial::Arg &&m)
Constructs a term of value .
friend const Term< Coeff > operator/(const Term< Coeff > &lhs, uint rhs)
Perform a division involving a term.
bool is_square() const
Checks if the term is a square.
Definition: Term.h:199
const Monomial::Arg & monomial() const
Definition: Term.h:94
bool has(Variable v) const
Definition: Term.h:160
CoefficientType mCoeff
Definition: Term.h:26
bool is_zero() const
Checks whether the term is zero.
Definition: Term.h:111
uint tdeg() const
Gives the total degree, i.e.
Definition: Term.h:101
bool is_constant() const
Checks whether the monomial is a constant.
Definition: Term.h:127
Term(const Coefficient &c, Variable v, uint e)
Constructs a term of value .
Term(const Coefficient &c)
Constructs a term of value .
const Coefficient & coeff() const
Definition: Term.h:83
bool divide(Variable v, Term &res) const
Monomial::Arg & monomial()
Get the monomial.
Definition: Term.h:91
Term(Monomial::Arg m)
Constructs a term of value .
std::size_t operator()(const carl::Term< Coefficient > &term) const
Calculates the hash of a Term.
Definition: Term.h:621