10 LPVariables::LPVariables() {
11 lp_var_db = lp_variable_db_new();
12 for (
size_t i = 0; i < TEMP_VARIABLE_SIZE; ++ i) {
14 sprintf(name,
"#%zu", i);
15 lp_var_tmp[i] = lp_variable_db_new_variable(lp_var_db, name);
19 LPVariables::~LPVariables() {
20 lp_variable_db_detach(lp_var_db);
24 std::optional<carl::Variable> LPVariables::carl_variable(lp_variable_t var)
const {
25 auto it = vars_libpoly_carl.find(var);
26 if(it == vars_libpoly_carl.end())
return std::nullopt;
27 CARL_LOG_TRACE(
"carl.poly",
"Mapping libpoly variable " << lp_variable_db_get_name(lp_var_db, var) <<
" (" << var <<
") -> " << it->second <<
" (" << it->second.id() <<
")");
31 std::optional<lp_variable_t> LPVariables::lp_variable_opt(
carl::Variable var)
const {
32 auto it = vars_carl_libpoly.find(var);
33 if(it == vars_carl_libpoly.end())
return std::nullopt;
34 CARL_LOG_TRACE(
"carl.poly",
"Mapping carl variable " << var <<
" (" << var.
id() <<
") -> " << lp_variable_db_get_name(lp_var_db, it->second) <<
" (" << it->second <<
")");
39 auto it = vars_carl_libpoly.find(var);
40 if(it != vars_carl_libpoly.end()) {
41 CARL_LOG_TRACE(
"carl.poly",
"Mapping carl variable " << var <<
" (" << var.
id() <<
") -> " << lp_variable_db_get_name(lp_var_db, it->second) <<
" (" << it->second <<
")");
44 std::string var_name = var.
name();
45 lp_variable_t poly_var = lp_variable_db_new_variable(lp_var_db, &var_name[0]);
46 vars_carl_libpoly.emplace(var, poly_var);
47 vars_libpoly_carl.emplace(poly_var, var);
48 CARL_LOG_TRACE(
"carl.poly",
"Mapping carl variable " << var <<
" (" << var.
id() <<
") -> " << lp_variable_db_get_name(lp_var_db, poly_var) <<
" (" << poly_var <<
")");
#define CARL_LOG_TRACE(channel, msg)
carl is the main namespace for the library.
A Variable represents an algebraic variable that can be used throughout carl.
std::string name() const
Retrieves the name of the variable.
constexpr std::size_t id() const noexcept
Retrieves the id of the variable.