carl  24.04
Computer ARithmetic Library
IntervalEvaluation.h
Go to the documentation of this file.
1 #pragma once
4 
5 #include "../IntervalEvaluation.h"
6 
7 // #include "MultivariateHorner.h"
8 
9 namespace carl {
10 
11 template<typename PolynomialType, class strategy >
12 class MultivariateHorner;
13 
14 template<typename PolynomialType, typename Number, class strategy>
16 {
17  Interval<Number> result(1);
18  CARL_LOG_FUNC("carl.core.intervalevaluation", mvH << ", " << map);
19 
20  if (mvH.getVariable() != Variable::NO_VARIABLE){
21  assert(map.count(mvH.getVariable()) > 0);
23  const Interval<Number> varValue = map.find(mvH.getVariable())->second;
24 
25  //Case 1: no further Horner schemes in mvH
26  if (!mvH.getDependent() && !mvH.getIndependent())
27  {
28  result = ( pow(varValue, mvH.getExponent()) * Interval<Number> (mvH.getDepConstant()) ) + Interval<Number> (mvH.getIndepConstant());
29  return result;
30  }
31  //Case 2: dependent part contains a Horner Scheme
32  else if (mvH.getDependent() && !mvH.getIndependent())
33  {
34  result = pow(varValue, mvH.getExponent()) * evaluate(*mvH.getDependent(), map) + Interval<Number> (mvH.getIndepConstant());
35  return result;
36  }
37  //Case 3: independent part contains a Horner Scheme
38  else if (!mvH.getDependent() && mvH.getIndependent())
39  {
40  result = pow(varValue, mvH.getExponent()) * Interval<Number> (mvH.getDepConstant()) + evaluate(*mvH.getIndependent(), map);
41  return result;
42  }
43  //Case 4: both independent part and dependent part
44  else if (mvH.getDependent() && mvH.getIndependent())
45  {
46  result = pow(varValue, mvH.getExponent()) * evaluate(*mvH.getDependent(), map) + evaluate(*mvH.getIndependent(), map);
47  return result;
48  }
49  }
50  else
51  {
52  result = Interval<Number> (mvH.getIndepConstant());
53  }
54  return result;
55 }
56 
57 
58 
59 } //Namespace carl
#define CARL_LOG_FUNC(channel, args)
Definition: carl-logging.h:46
carl is the main namespace for the library.
bool evaluate(const BasicConstraint< Poly > &c, const Assignment< Number > &m)
Definition: Evaluation.h:10
Interval< Number > pow(const Interval< Number > &i, Integer exp)
Definition: Power.h:11
A Variable represents an algebraic variable that can be used throughout carl.
Definition: Variable.h:85
static const Variable NO_VARIABLE
Instance of an invalid variable.
Definition: Variable.h:203
The class which contains the interval arithmetic including trigonometric functions.
Definition: Interval.h:134
static Interval< Number > empty_interval()
Method which returns the empty interval rooted at 0.
Definition: Interval.h:813
const CoeffType & getIndepConstant() const
const CoeffType & getDepConstant() const
std::shared_ptr< MultivariateHorner > getIndependent() const
std::shared_ptr< MultivariateHorner > getDependent() const
Variable getVariable() const