carl  24.04
Computer ARithmetic Library
LazardEvaluation.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "FieldExtensions.h"
6 
7 namespace carl::ran::interval {
8 
9 template<typename Rational, typename Poly>
11 private:
14 
15 public:
16  LazardEvaluation(const Poly& p): mLiftingPoly(p) {}
17 
18  auto substitute(Variable v, const IntRepRealAlgebraicNumber<Rational>& r, bool divideZeroFactors = true) {
19  auto red = mFieldExtensions.extend(v, r);
20  Poly newPoly;
21  if (red.first) {
22  CARL_LOG_DEBUG("carl.lazard", "Substituting " << v << " by " << red.second);
23  newPoly = carl::substitute(mLiftingPoly, v, red.second);
24  } else {
25  CARL_LOG_DEBUG("carl.lazard", "Obtained reductor " << red.second);
26  newPoly = carl::remainder(mLiftingPoly, red.second);
27  }
28  // TODO newPoly = mFieldExtensions.embed(newPoly);
29  while (carl::is_zero(newPoly) && divideZeroFactors) {
30  if (red.first) {
31  mLiftingPoly = carl::quotient(mLiftingPoly, v - red.second);
32  newPoly = carl::substitute(mLiftingPoly, v, red.second);
33  } else {
35  newPoly = carl::remainder(mLiftingPoly, red.second);
36  }
37  // TODO newPoly = mFieldExtensions.embed(newPoly);
38  CARL_LOG_DEBUG("carl.lazard", "Reducing to " << mLiftingPoly);
39  }
40  mLiftingPoly = newPoly;
41  CARL_LOG_DEBUG("carl.lazard", "Remaining poly: " << mLiftingPoly);
42  return red;
43  }
44 
45  const auto& getLiftingPoly() const {
46  return mLiftingPoly;
47  }
48 };
49 
50 }
#define CARL_LOG_DEBUG(channel, msg)
Definition: carl-logging.h:43
Interval< Number > quotient(const Interval< Number > &_lhs, const Interval< Number > &_rhs)
Implements the division with remainder.
Definition: Interval.h:1488
bool is_zero(const Interval< Number > &i)
Check if this interval is a point-interval containing 0.
Definition: Interval.h:1453
Coeff substitute(const Monomial &m, const std::map< Variable, Coeff > &substitutions)
Applies the given substitutions to a monomial.
Definition: Substitution.h:19
cln::cl_I remainder(const cln::cl_I &a, const cln::cl_I &b)
Calculate the remainder of the integer division.
Definition: operations.h:526
A Variable represents an algebraic variable that can be used throughout carl.
Definition: Variable.h:85
This class can be used to construct iterated field extensions from a sequence of real algebraic numbe...
FieldExtensions< Rational, Poly > mFieldExtensions
auto substitute(Variable v, const IntRepRealAlgebraicNumber< Rational > &r, bool divideZeroFactors=true)