carl  24.04
Computer ARithmetic Library
ModelPolynomialSubstitution.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../ModelSubstitution.h"
4 #include "../evaluation/ModelEvaluation.h"
5 
6 namespace carl {
7  template<typename Rational, typename Poly>
8  class ModelPolynomialSubstitution: public ModelSubstitution<Rational,Poly> {
9  private:
11  Poly mPoly;
12  public:
14  {}
15  const auto& getPoly() const {
16  return mPoly;
17  }
18  virtual void multiplyBy(const Rational& n) {
19  mPoly *= n;
20  }
21  virtual void add(const Rational& n) {
22  mPoly += n;
23  }
24 
26  return createSubstitutionPtr<Rational,Poly,ModelPolynomialSubstitution>(mPoly);
27  }
28 
30  assert(mv.is_variable());
32  }
34  return evaluate(mPoly, m);
35  }
36  virtual bool dependsOn(const ModelVariable& var) const {
37  if (!var.is_variable()) return false;
38  return mPoly.degree(var.asVariable()) > 0;
39  }
40  virtual void print(std::ostream& os) const {
41  os << mPoly;
42  }
43  };
44 }
mpq_class Rational
Definition: HornerTest.cpp:12
carl is the main namespace for the library.
std::unique_ptr< ModelSubstitution< Rational, Poly > > ModelSubstitutionPtr
Definition: ModelValue.h:24
Represent a collection of assignments/mappings from variables to values.
Definition: Model.h:19
virtual Formula< Poly > representingFormula(const ModelVariable &mv)
virtual void multiplyBy(const Rational &n)
Multiply this model substitution by a rational.
virtual void add(const Rational &n)
Add a rational to this model substitution.
virtual bool dependsOn(const ModelVariable &var) const
Check if this substitution needs the given model variable.
virtual void print(std::ostream &os) const
Print this substitution to the given output stream.
virtual ModelValue< Rational, Poly > evaluateSubstitution(const Model< Rational, Poly > &m) const
Evaluate this substitution with respect to the given model.
virtual ModelSubstitutionPtr< Rational, Poly > clone() const
Create a copy of this model substitution.
Represent a expression for a ModelValue with variables as placeholders, where the final expression's ...
const ModelValue< Rational, Poly > & evaluate(const Model< Rational, Poly > &model) const
Represent a sum type/variant over the different kinds of values that can be assigned to the different...
Definition: ModelValue.h:56
Represent a sum type/variant over the different kinds of variables that exist in CARL to use them in ...
Definition: ModelVariable.h:20
bool is_variable() const
Definition: ModelVariable.h:44
carl::Variable asVariable() const
Definition: ModelVariable.h:72