carl  24.04
Computer ARithmetic Library
internal.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "LazardEvaluation.h"
5 
6 namespace carl::ran::interval {
7  template<typename Number, typename Coeff>
8  std::optional<UnivariatePolynomial<Number>> substitute_rans_into_polynomial(
11  bool use_lazard = false // TODO revert
12  ) {
13  std::vector<MultivariatePolynomial<Number>> polys;
14  std::vector<Variable> varOrder;
15 
16  if (use_lazard) {
17  CARL_LOG_TRACE("carl.ran.interval", "Substituting using Lazard evaluation");
19  for (const auto& vic: m) {
20  varOrder.emplace_back(vic.first);
21  auto res = le.substitute(vic.first, vic.second, true);
22  if (res.first) {
23  polys.emplace_back(vic.first - res.second);
24  } else {
25  polys.emplace_back(res.second);
26  }
27  CARL_LOG_TRACE("carl.ran.interval", vic.first << " -> " << vic.second << " is now " << polys.back());
28  }
29  polys.emplace_back(le.getLiftingPoly());
30  varOrder.emplace_back(p.main_var());
31  CARL_LOG_TRACE("carl.ran.interval", "main poly " << p << " in " << p.main_var() << " is now " << polys.back());
32  } else {
33  CARL_LOG_TRACE("carl.ran.interval", "Substituting using field extensions only");
35  for (const auto& vic: m) {
36  varOrder.emplace_back(vic.first);
37  auto res = fe.extend(vic.first, vic.second);
38  if (res.first) {
39  polys.emplace_back(vic.first - res.second);
40  } else {
41  polys.emplace_back(res.second);
42  }
43  CARL_LOG_TRACE("carl.ran.interval", vic.first << " -> " << vic.second << " is now " << polys.back());
44  }
45  polys.emplace_back(p);
46  varOrder.emplace_back(p.main_var());
47  CARL_LOG_TRACE("carl.ran.interval", "main poly " << p << " in " << p.main_var() << " is now " << polys.back());
48  }
49 
50  CARL_LOG_TRACE("carl.ran.interval", "Perform algebraic substitution on " << polys << " wrt " << varOrder);
51  return algebraic_substitution(polys, varOrder);
52  }
53 }
This file contains carl::algebraic_substitution which performs what we call an algebraic substitution...
#define CARL_LOG_TRACE(channel, msg)
Definition: carl-logging.h:44
std::vector< std::pair< Variable, T > > OrderedAssignment
Definition: Common.h:16
std::optional< UnivariatePolynomial< Number > > substitute_rans_into_polynomial(const UnivariatePolynomial< Coeff > &p, const OrderedAssignment< IntRepRealAlgebraicNumber< Number >> &m, bool use_lazard=false)
Definition: internal.h:8
std::optional< UnivariatePolynomial< Number > > algebraic_substitution(const UnivariatePolynomial< MultivariatePolynomial< Number >> &p, const std::vector< UnivariatePolynomial< MultivariatePolynomial< Number >>> &polynomials, AlgebraicSubstitutionStrategy strategy=AlgebraicSubstitutionStrategy::RESULTANT)
Computes the algebraic substitution of the given defining polynomials into a multivariate polynomial ...
This class represents a univariate polynomial with coefficients of an arbitrary type.
Variable main_var() const
Retrieves the main variable of this polynomial.
This class can be used to construct iterated field extensions from a sequence of real algebraic numbe...
std::pair< bool, Poly > extend(Variable v, const IntRepRealAlgebraicNumber< Rational > &r)
Extend the current number field with the field extension defined by r.
auto substitute(Variable v, const IntRepRealAlgebraicNumber< Rational > &r, bool divideZeroFactors=true)