carl  24.04
Computer ARithmetic Library
SPolynomial.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../MultivariatePolynomial.h"
4 
5 namespace carl {
6 
7 /**
8  * Calculates the S-Polynomial of two polynomials.
9  */
10 template<typename C, typename O, typename P>
12  assert(p.is_consistent());
13  assert(q.is_consistent());
14  assert(p.nr_terms() != 0);
15  assert(q.nr_terms() != 0);
16 
17  if ((p.nr_terms() == 1) && (q.nr_terms() == 1)) {
19  } else if (p.nr_terms() == 1) {
20  return -(p.lterm().calcLcmAndDivideBy(q.lmon()) * q.tail());
21  } else if (q.nr_terms() == 1) {
22  return (q.lterm().calcLcmAndDivideBy(p.lmon()) * p.tail());
23  } else {
24  return (p.tail() * q.lterm().calcLcmAndDivideBy(p.lmon())) - (q.tail() * p.lterm().calcLcmAndDivideBy(q.lmon()));
25  }
26 }
27 
28 }
carl is the main namespace for the library.
MultivariatePolynomial< C, O, P > SPolynomial(const MultivariatePolynomial< C, O, P > &p, const MultivariatePolynomial< C, O, P > &q)
Calculates the S-Polynomial of two polynomials.
Definition: SPolynomial.h:11
The general-purpose multivariate polynomial class.
bool is_consistent() const
Asserts that this polynomial complies with the requirements and assumptions for MultivariatePolynomia...
MultivariatePolynomial tail(bool makeFullyOrdered=false) const
For the polynomial p, the function calculates a polynomial p - lt(p).
const Term< Coeff > & lterm() const
The leading term.
const Monomial::Arg & lmon() const
The leading monomial.
std::size_t nr_terms() const
Calculate the number of terms.
Term calcLcmAndDivideBy(const Monomial::Arg &m) const