14 class GiNaCConverter {
16 std::map<carl::Variable, GiNaC::symbol> vars;
18 GiNaC::numeric operator()(
const cln::cl_RA& n) {
19 return GiNaC::numeric(n);
21 GiNaC::numeric operator()(
const mpq_class& n) {
24 return GiNaC::numeric(ss.str().c_str());
27 auto it = vars.find(v);
28 if (it == vars.end()) {
33 GiNaC::ex operator()(
const std::pair<carl::Variable, carl::exponent>& p) {
34 assert(carl::fits_within<unsigned long>(p.second));
35 return GiNaC::pow((*
this)(p.first),
static_cast<unsigned long>(p.second));
39 for (
auto it: m) res *= (*this)(it);
42 template<
typename Coeff>
44 GiNaC::ex res = (*this)(t.
coeff());
48 template<
typename Coeff>
51 for (
auto t: p) res += (*this)(t);
52 return GiNaC::expand(res);
54 template<
typename Coeff>
58 GiNaC::symbol mainvar = (*this)(p.
main_var());
63 return GiNaC::expand(res);
71 std::vector<carl::Variable>
variables(
const std::vector<GiNaC::symbol>& cadVariables) {
72 std::vector<carl::Variable> v = std::vector<carl::Variable>();
73 for(std::vector<GiNaC::symbol>::const_iterator g_it = cadVariables.begin(); g_it != cadVariables.end(); ++g_it)
75 for(std::map<carl::Variable, GiNaC::symbol>::const_iterator it = vars.begin(); it != vars.end(); ++it)
77 if(*g_it == it->second)
78 v.push_back(it->first);
81 assert(cadVariables.size() == v.size());
carl is the main namespace for the library.
Interval< Number > exp(const Interval< Number > &i)
void variables(const BasicConstraint< Pol > &c, carlVariables &vars)
Interval< Number > pow(const Interval< Number > &i, Integer exp)
A Variable represents an algebraic variable that can be used throughout carl.
This class represents a univariate polynomial with coefficients of an arbitrary type.
const std::vector< Coefficient > & coefficients() const &
Retrieves the coefficients defining this polynomial.
Variable main_var() const
Retrieves the main variable of this polynomial.
The general-purpose multivariate polynomial class.
The general-purpose monomials.
Coefficient & coeff()
Get the coefficient.
Monomial::Arg & monomial()
Get the monomial.
static VariablePool & getInstance()
Returns the single instance of this class by reference.