9 template<
typename Poly>
13 if (!roots.is_univariate() || roots.roots().size() < f.
k())
return;
15 for (
int i = 1; i <= f.
k(); i++) {
17 if (i == f.
k()) tmp_var = var;
27 template<
typename Poly>
31 if (!roots.is_univariate() || roots.roots().size() < f.
k())
return;
33 ass.emplace(var, roots.roots()[f.
k()-1]);
34 while (!poly.is_constant()) {
39 out.emplace_back(poly, rel);
44 template<
typename Poly>
45 using EncodingCache = std::map<MultivariateRoot<Poly>, std::pair<std::vector<BasicConstraint<Poly>>,
Variable>>;
47 template<
typename Poly>
49 if (cache.find(f) == cache.end()) {
51 std::vector<BasicConstraint<Poly>> result;
54 if (!result.empty()) {
55 cache.emplace(f, std::make_pair(result, var));
57 cache.emplace(f, std::make_pair(result,
Variable()));
63 template<
typename Poly>
68 auto mv = std::get<typename VariableComparison<Poly>::MR>(f.
value());
72 return std::make_pair(result, res_constr);
carl is the main namespace for the library.
UnivariatePolynomial< C > to_univariate_polynomial(const MultivariatePolynomial< C, O, P > &p)
Convert a univariate polynomial that is currently (mis)represented by a 'MultivariatePolynomial' into...
const T & derivative(const T &t, Variable, std::size_t n=1)
Computes the n'th derivative of a number, which is either the number itself (for n = 0) or zero.
std::map< MultivariateRoot< Poly >, std::pair< std::vector< BasicConstraint< Poly > >, Variable > > EncodingCache
RealRootsResult< IntRepRealAlgebraicNumber< Number > > real_roots(const UnivariatePolynomial< Coeff > &polynomial, const Interval< Number > &interval=Interval< Number >::unbounded_interval())
Find all real roots of a univariate 'polynomial' with numeric coefficients within a given 'interval'.
@ NEGATIVE
Indicates that .
@ POSITIVE
Indicates that .
std::optional< BasicConstraint< Poly > > as_constraint(const VariableComparison< Poly > &f)
Convert this variable comparison "v < root(..)" into a simpler polynomial (in)equality against zero "...
void encode_as_constraints_thom(const MultivariateRoot< Poly > &f, Assignment< typename VariableComparison< Poly >::RAN > ass, Variable var, std::vector< BasicConstraint< Poly >> &out)
bool evaluate(const BasicConstraint< Poly > &c, const Assignment< Number > &m)
void encode_as_constraints_simple(const MultivariateRoot< Poly > &f, Assignment< typename VariableComparison< Poly >::RAN > ass, Variable var, std::vector< BasicConstraint< Poly >> &out)
Sign sgn(const Number &n)
Obtain the sign of the given number.
Coeff substitute(const Monomial &m, const std::map< Variable, Coeff > &substitutions)
Applies the given substitutions to a monomial.
Variable fresh_real_variable() noexcept
Relation inverse(Relation r)
Inverts the given relation symbol.
std::map< Variable, T > Assignment
std::pair< std::vector< BasicConstraint< Poly > >, Variable > encode_as_constraints(const MultivariateRoot< Poly > &f, Assignment< typename VariableComparison< Poly >::RAN > ass, EncodingCache< Poly > cache)
Represent a polynomial (in)equality against zero.
A Variable represents an algebraic variable that can be used throughout carl.
static const Variable NO_VARIABLE
Instance of an invalid variable.
std::size_t k() const noexcept
Return k, the index of the root.
const Poly & poly() const noexcept
Variable var() const noexcept
Represent a sum type/variant of an (in)equality between a variable on the left-hand side and multivar...
const std::variant< MR, RAN > & value() const
typename MultivariateRoot< Poly >::RAN RAN
Relation relation() const