22 ap_var_t* r = (ap_var_t*)malloc(
sizeof(ap_var_t)*n.size());
24 for (
size_t i=0; i<n.size(); i++) r[i] = n[i].get_ap_var_t();
31 *x = (ap_var_t*)malloc(
sizeof(ap_var_t)*n.size());
32 *y = (ap_var_t*)malloc(
sizeof(ap_var_t)*n.size());
34 for (
size_t i=0; i<n.size(); i++) {
35 (*x)[i] = n[i].first.get_ap_var_t();
36 (*y)[i] = n[i].second.get_ap_var_t();
44inline environment::environment()
45 : e(ap_environment_alloc_empty())
55 if (!
e)
throw std::invalid_argument(
"apron::environment::environment(const vector<var>&, const vector<var>&) incompatible variable types");
60 e = ap_environment_alloc(
const_cast<ap_var_t*
>(
reinterpret_cast<const ap_var_t*
>(
intdim)), intdim_size,
61 const_cast<ap_var_t*
>(
reinterpret_cast<const ap_var_t*
>(
realdim)), realdim_size);
62 if (!
e)
throw std::invalid_argument(
"apron::environment::environment(const var*, size_t, const var*, size_t) incompatible variable types");
66 : e(ap_environment_copy(x.e))
72 ap_environment_free(
e);
81 ap_environment_t* ee = ap_environment_copy(x.
e);
82 ap_environment_free(
e);
96 ap_environment_t* ee = ap_environment_add(
e, i,
intdim.size(), r,
realdim.size());
98 if (!ee)
throw std::invalid_argument(
"apron::environment::add(const vector<var>&, const vector<var>&) incompatible variable types");
104 ap_environment_t* ee =
105 ap_environment_add(
e,
106 const_cast<ap_var_t*
>(
reinterpret_cast<const ap_var_t*
>(
intdim)), intdim_size,
107 const_cast<ap_var_t*
>(
reinterpret_cast<const ap_var_t*
>(
realdim)), realdim_size);
108 if (!ee)
throw std::invalid_argument(
"apron::environment::add(const var*, size_t, const var*, size_t) incompatible variable types");
117 ap_environment_t* ee = ap_environment_add_perm(
e, i,
intdim.size(), r,
realdim.size(), &p);
119 if (!ee)
throw std::invalid_argument(
"apron::environment::add(const vector<var>&, const vector<var>&, dimperm& perm) incompatible variable types");
128 ap_environment_t* ee =
129 ap_environment_add_perm(
e,
130 const_cast<ap_var_t*
>(
reinterpret_cast<const ap_var_t*
>(
intdim)), intdim_size,
131 const_cast<ap_var_t*
>(
reinterpret_cast<const ap_var_t*
>(
realdim)), realdim_size,
133 if (!ee)
throw std::invalid_argument(
"apron::environment::add(const var*, size_t, const var*, size_t, dimperm&) incompatible variable types");
142 ap_environment_t* ee = ap_environment_remove(
e, d, dims.size());
144 if (!ee)
throw std::invalid_argument(
"apron::environment::remove(const vector<var>&) variable not in environment");
150 ap_environment_t* ee =
151 ap_environment_remove(
e,
152 const_cast<ap_var_t*
>(
reinterpret_cast<const ap_var_t*
>(dims)),
154 if (!ee)
throw std::invalid_argument(
"apron::environment::remove(const var*, size_t) variable not in environment");
163 ap_environment_t* ee = ap_environment_rename(
e, a, b, dims.size(), &p);
165 if (!ee)
throw std::invalid_argument(
"apron::environment::rename(const vector<std::pair<var,var>>&) variable mismatch");
166 ap_dimperm_clear(&p);
173 ap_environment_t* ee =
174 ap_environment_rename(
e,
175 const_cast<ap_var_t*
>(
reinterpret_cast<const ap_var_t*
>(before)),
176 const_cast<ap_var_t*
>(
reinterpret_cast<const ap_var_t*
>(after)),
178 if (!ee)
throw std::invalid_argument(
"apron::environment::rename(const var*, const var*, size_t) variable mismatch");
179 ap_dimperm_clear(&p);
189 ap_environment_t* ee = ap_environment_rename(
e, a, b, dims.size(), &p);
191 if (!ee)
throw std::invalid_argument(
"apron::environment::rename(const vector<std::pair<var,var>>&, dimperm&) variable mismatch");
200 ap_environment_t* ee =
201 ap_environment_rename(
e,
202 const_cast<ap_var_t*
>(
reinterpret_cast<const ap_var_t*
>(before)),
203 const_cast<ap_var_t*
>(
reinterpret_cast<const ap_var_t*
>(after)),
205 if (!ee)
throw std::invalid_argument(
"apron::environment::rename(const var*, const var*, size_t, dimperm&) variable mismatch");
212inline environment
lce(
const environment& x,
const environment& y)
214 ap_dimchange_t *a = NULL, *b = NULL;
215 ap_environment_t* ee = ap_environment_lce(x.e, y.e, &a, &b);
216 if (a) ap_dimchange_free(a);
217 if (b) ap_dimchange_free(b);
218 if (!ee)
throw std::invalid_argument(
"apron::environment::lce(const environment&, const environment&) incompatible variable types");
222inline environment
lce(
const environment& x,
const environment& y, dimchange& chgx, dimchange& chgy)
224 ap_dimchange_t *a = NULL, *b = NULL;
225 ap_environment_t* ee = ap_environment_lce(x.e, y.e, &a, &b);
226 ap_dimchange_clear(chgx.get_ap_dimchange_t());
227 ap_dimchange_clear(chgy.get_ap_dimchange_t());
228 if (a) { *chgx.get_ap_dimchange_t() = *a; free(a); }
229 else { ap_dimchange_init(chgx.get_ap_dimchange_t(), 0, 0); }
230 if (b) { *chgy.get_ap_dimchange_t() = *b; free(b); }
231 else { ap_dimchange_init(chgy.get_ap_dimchange_t(), 0, 0); }
232 if (!ee)
throw std::invalid_argument(
"apron::environment::lce(const environment&, const environment&, dimchange&, dimchange&) incompatible variable types");
236inline environment
lce(
const std::vector<environment>& x)
238 ap_environment_t** ar = (ap_environment_t**)malloc(
sizeof(ap_environment_t*)*x.size());
239 ap_dimchange_t** r = NULL;
241 for (
size_t i=0; i<x.size(); i++) ar[i] = x[i].e;
242 ap_environment_t* ee = ap_environment_lce_array(ar, x.size(), &r);
245 for (
size_t i=0; i<x.size(); i++)
246 if (r[i]) ap_dimchange_free(r[i]);
249 if (!ee)
throw std::invalid_argument(
"apron::environment::lce(const vector<environment>&) incompatible variable types");
253inline environment
lce(
const environment* env,
size_t env_size)
255 ap_dimchange_t** r = NULL;
256 ap_environment_t* ee =
257 ap_environment_lce_array(
reinterpret_cast<ap_environment_t**
>(
const_cast<environment*
>(env)),
260 for (
size_t i=0; i<env_size; i++)
261 if (r[i]) ap_dimchange_free(r[i]);
264 if (!ee)
throw std::invalid_argument(
"apron::environment::lce(const environment*, size_t) incompatible variable types");
268inline environment
lce(
const std::vector<environment>& x, std::vector<dimchange>& chg)
270 if (x.size()>chg.size())
throw std::invalid_argument(
"apron::environment::lce(const vector<environment>&, vector<dimchange>&) dimchange vector too short");
271 ap_environment_t** ar = (ap_environment_t**)malloc(
sizeof(ap_environment_t*)*x.size());
272 ap_dimchange_t** r = NULL;
274 for (
size_t i=0; i<x.size(); i++) ar[i] = x[i].e;
275 ap_environment_t* ee = ap_environment_lce_array(ar, x.size(), &r);
277 for (
size_t i=0; i<x.size(); i++) {
278 ap_dimchange_clear(chg[i].get_ap_dimchange_t());
280 *chg[i].get_ap_dimchange_t() = *(r[i]);
284 ap_dimchange_init(chg[i].get_ap_dimchange_t(), 0, 0);
288 if (!ee)
throw std::invalid_argument(
"apron::environment::lce(const vector<environment>&, vector<dimchange>&) incompatible variable types");
292inline environment
lce(
const environment* env, dimchange* chg,
size_t env_size)
294 ap_dimchange_t** r = NULL;
295 ap_environment_t* ee =
296 ap_environment_lce_array(
reinterpret_cast<ap_environment_t**
>(
const_cast<environment*
>(env)),
298 for (
size_t i=0; i<env_size; i++) {
299 ap_dimchange_clear(chg[i].get_ap_dimchange_t());
301 *chg[i].get_ap_dimchange_t() = *(r[i]);
305 ap_dimchange_init(chg[i].get_ap_dimchange_t(), 0, 0);
309 if (!ee)
throw std::invalid_argument(
"apron::environment::lce(const environment*, dimchange*, size_t) incompatible variable types");
315 ap_dimchange_t* d = ap_environment_dimchange(x.e,y.e);
316 if (!d)
throw std::invalid_argument(
"apron::environment::get_dimchange(const environment&, const environment &) not a super-type");
318 *c.get_ap_dimchange_t() = *d;
345 if (d==AP_DIM_MAX)
throw std::invalid_argument(
"apron::environment::operator[](const var&) variable not in environment");
351 return *
reinterpret_cast<var*
>(&
e->var_of_dim[d]);
357 if (d==AP_DIM_MAX)
throw std::invalid_argument(
"apron::environment::get_dim(const var&) variable not in environment");
363 if (d >=
e->intdim+
e->realdim)
throw std::out_of_range(
"environment::get_var");
364 return *
reinterpret_cast<var*
>(&
e->var_of_dim[d]);
369 std::vector<var> v = std::vector<var>(
e->intdim+
e->realdim,
"");
370 for (
size_t i=0; i<
e->intdim+
e->realdim; i++) v[i] =
e->var_of_dim[i];
378inline bool operator==(
const environment& x,
const environment& y)
380 return ap_environment_is_eq(x.e, y.e);
383inline bool operator!=(
const environment& x,
const environment& y)
385 return !ap_environment_is_eq(x.e, y.e);
388inline bool operator<=(
const environment& x,
const environment& y)
390 return ap_environment_is_leq(x.e, y.e);
393inline bool operator>=(
const environment& x,
const environment& y)
395 return ap_environment_is_leq(y.e, x.e);
398inline int cmp(
const environment& x,
const environment& y)
400 return ap_environment_compare(x.e, y.e);
406inline std::ostream&
operator<< (std::ostream& os,
const environment& s)
408 for (
size_t i=0; i<s.e->intdim+s.e->realdim; i++) {
409 char* c = ap_var_operations->to_string(s.e->var_of_dim[i]);
410 os << i <<
": " << c << (i<s.e->intdim ?
" (int)" :
" (real)") << std::endl;
418 ap_environment_fdump(stream,
e);
bool operator==(const abstract0 &x, const abstract0 &y)
Definition apxx_abstract0_inline.hh:409
bool operator<=(const abstract0 &x, const abstract0 &y)
Definition apxx_abstract0_inline.hh:421
bool operator>=(const abstract0 &x, const abstract0 &y)
Definition apxx_abstract0_inline.hh:428
bool operator!=(const abstract0 &x, const abstract0 &y)
Definition apxx_abstract0_inline.hh:416
std::ostream & operator<<(std::ostream &os, const abstract0 &s)
Definition apxx_abstract0_inline.hh:292
int cmp(const coeff &a, const coeff &b)
Definition apxx_coeff_inline.hh:414
static void apxx_environment_get_names_pair(const std::vector< std::pair< var, var > > &n, ap_var_t **x, ap_var_t **y)
Definition apxx_environment_inline.hh:29
environment lce(const environment &x, const environment &y)
Definition apxx_environment_inline.hh:212
static ap_var_t * apxx_environment_get_names(const std::vector< var > &n)
Definition apxx_environment_inline.hh:20
dimchange get_dimchange(const environment &x, const environment &y)
Definition apxx_environment_inline.hh:313
Dimension permutation object (ap_dimperm_t wrapper).
Definition apxx_dimension.hh:292
const ap_dimperm_t * get_ap_dimperm_t() const
Returns a pointer to the internal APRON object stored in *this.
Definition apxx_dimension_inline.hh:422
Level 1 environment (ap_environment_t wrapper).
Definition apxx_environment.hh:51
const ap_environment_t * get_ap_environment_t() const
Returns a pointer to the internal APRON object pointed by *this.
Definition apxx_environment_inline.hh:425
ap_environment_t * e
Definition apxx_environment.hh:55
void print(FILE *stream=stdout) const
Prints to a C stream.
Definition apxx_environment_inline.hh:416
size_t realdim() const
Returns the number of real dimensions in the environment.
Definition apxx_environment_inline.hh:332
const environment & operator=(const environment &x)
Assignment (reference counter manipulation).
Definition apxx_environment_inline.hh:79
environment add(const std::vector< var > &intdim, const std::vector< var > &realdim) const
Returns a copy of the environment with some integer and/or real variable names added.
Definition apxx_environment_inline.hh:92
environment remove(const std::vector< var > &dims) const
Returns a copy of the environment with some variable names removed.
Definition apxx_environment_inline.hh:139
std::vector< var > get_vars() const
Returns (a copy of) the full map from dimensions to variable names.
Definition apxx_environment_inline.hh:367
bool contains(const var &x) const
Whether the environment contains the variable name x.
Definition apxx_environment_inline.hh:337
ap_dim_t get_dim(const var &x) const
Returns the dimension associated with a variable name.
Definition apxx_environment_inline.hh:354
ap_dim_t operator[](const var &x) const
Returns the dimension associated with the variable name.
Definition apxx_environment_inline.hh:342
size_t intdim() const
Returns the number of integer dimensions in the environment.
Definition apxx_environment_inline.hh:327
const var & get_var(ap_dim_t d) const
Returns the variable name at a given dimension (bound-checked).
Definition apxx_environment_inline.hh:361
environment()
Creates a new empty environment.
Definition apxx_environment_inline.hh:44
environment rename(const std::vector< std::pair< var, var > > &dims) const
Returns a copy of the environment with some variable names substituted.
Definition apxx_environment_inline.hh:158
~environment()
Decrements the reference counter and, if null, actually frees the environment.
Definition apxx_environment_inline.hh:70
Variable name (ap_var_t wrapper).
Definition apxx_var.hh:39
const ap_var_t & get_ap_var_t() const
Returns a reference to the APRON object wrapped (no copy).
Definition apxx_var_inline.hh:156