24 inline varname::varname(
const std::vector<std::string>& names)
28 template<
class charT,
class Traits>
30 std::basic_ostream<charT,Traits>&
31 operator<<(std::basic_ostream<charT,Traits>& os,
const varname& v)
33 std::vector<std::string>*& vv =
36 if (v.names.size()) vv =
new std::vector<std::string>(v.names);
41 template<
class charT,
class Traits>
43 std::vector<std::string>*
get_varname(std::basic_ostream<charT,Traits>& os)
60 ap_dimchange_init(&
c, intdim, realdim);
65 ap_dimchange_init(&
c, intdim, realdim);
66 memcpy(
c.dim, d,
sizeof(ap_dim_t) * (intdim + realdim));
71 ap_dimchange_init(&
c, x.c.intdim, x.c.realdim);
72 memcpy(
c.dim, x.c.dim,
sizeof(ap_dim_t) * (x.c.intdim + x.c.realdim));
73 if (inv) ap_dimchange_add_invert(&
c);
78 if (d.size()<intdim+realdim)
79 throw std::invalid_argument(
"apron::dimchange::dimchange(size_t, size_t, const vector<ap_dim_t>&) vector too short");
80 ap_dimchange_init(&
c, intdim, realdim);
81 for (
size_t i=0; i<intdim+realdim; i++)
91 ap_dimchange_clear(&
c);
101 ap_dimchange_clear(&
c);
102 ap_dimchange_init(&
c, x.c.intdim, x.c.realdim);
103 memcpy(
c.dim, x.c.dim,
sizeof(ap_dim_t) * (x.c.intdim + x.c.realdim));
110 memcpy(
c.dim, d,
sizeof(ap_dim_t) * (
c.intdim +
c.realdim));
116 if (d.size()<
c.intdim+
c.realdim)
117 throw std::invalid_argument(
"apron::dimchange::operator=(const vector<ap_dim_t>&) vector too short");
118 for (
size_t i=0; i<
c.intdim+
c.realdim; i++)
138 if (dim >=
c.intdim +
c.realdim)
throw std::out_of_range(
"apron::dimchange::get(size_t)");
144 if (dim >=
c.intdim +
c.realdim)
throw std::out_of_range(
"apron::dimchange::get(size_t)");
162 inline std::ostream&
operator<< (std::ostream& os,
const dimchange& s)
165 os <<
"dimchange: intdim=" << s.c.intdim <<
", realdim=" << s.c.realdim << std::endl;
167 size_t sz = (*names).size();
168 for (
size_t i=0;i<s.c.intdim+s.c.realdim;i++)
169 if (s.c.dim[i] < sz) os << (*names)[s.c.dim[i]] <<
" ";
170 else os <<
"x" << s.c.dim[i] <<
" ";
173 for (
size_t i=0;i<s.c.intdim+s.c.realdim;i++)
174 os <<
"x" << s.c.dim[i] <<
" ";
176 return os << std::endl;
181 ap_dimchange_fprint(stream, const_cast<ap_dimchange_t*>(&
c));
190 ap_dimchange_add_invert(&
c);
195 dimchange r = *
this; ap_dimchange_add_invert(&r.c);
225 ap_dimperm_init(&
c,
size);
230 ap_dimperm_init(&
c,
size);
231 memcpy(
c.dim, d,
sizeof(ap_dim_t) * (
size));
236 ap_dimperm_init(&
c, t.size);
237 ap_dimperm_set_id(&
c);
242 ap_dimperm_init(&
c, x.c.size);
243 if (inv) ap_dimperm_invert(&
c, const_cast<ap_dimperm_t*>(&x.c));
244 else memcpy(
c.dim, x.c.dim,
sizeof(ap_dim_t) * (x.c.size));
249 ap_dimperm_init(&
c, x.c.size);
250 ap_dimperm_compose( &
c, const_cast<ap_dimperm_t*>(&x.c), const_cast<ap_dimperm_t*>(&y.c) );
255 ap_dimperm_init(&
c, d.size());
256 for (
size_t i=0; i<d.size(); i++)
266 ap_dimperm_clear(&
c);
276 if (x.c.size!=
c.size) {
277 ap_dimperm_clear(&
c);
278 ap_dimperm_init(&
c, x.c.size);
280 memcpy(
c.dim, x.c.dim,
sizeof(ap_dim_t) *
c.size);
287 if (t.size!=
c.size) {
288 ap_dimperm_clear(&
c);
289 ap_dimperm_init(&
c, t.size);
291 ap_dimperm_set_id(&
c);
297 memcpy(
c.dim, d,
sizeof(ap_dim_t) *
c.size);
303 if (
c.size!=d.size()) {
304 ap_dimperm_clear(&
c);
305 ap_dimperm_init(&
c, d.size());
307 for (
size_t i=0; i<
c.size; i++)
c.dim[i] = d[i];
332 if (dim >=
c.size)
throw std::out_of_range(
"apron::dimperm::get(size_t)");
338 if (dim >=
c.size)
throw std::out_of_range(
"apron::dimperm::get(size_t)");
346 inline std::ostream&
operator<< (std::ostream& os,
const dimperm& s)
349 os <<
"dimperm: size=" << s.c.size << std::endl;
351 size_t sz = (*names).size();
352 for (
size_t i=0;i<s.c.size;i++) {
353 if (i<sz) os << (*names)[i];
356 if (s.c.dim[i]<sz) os << (*names)[s.c.dim[i]];
357 else os <<
"x" << s.c.dim[i];
362 for (
size_t i=0;i<s.c.size;i++)
363 os <<
"x" << i <<
" -> " <<
"x" << s.c.dim[i] << std::endl;
370 ap_dimperm_fprint(stream, const_cast<ap_dimperm_t*>(&
c));
381 if (
c.size!=y.c.size)
382 throw std::invalid_argument(
"apron::dimperm::operator*= (const dimperm&) size mismatch");
385 ap_dimperm_compose(&
c, &
c, const_cast<ap_dimperm_t*>(&tmp.c));
388 ap_dimperm_compose(&
c, &
c, const_cast<ap_dimperm_t*>(&y.c));
392 inline dimperm
operator* (
const dimperm& x,
const dimperm& y)
394 if (x.c.size!=y.c.size)
395 throw std::invalid_argument(
"apron::dimperm::operator* (const dimperm&, const dimperm&) size mismatch");
396 dimperm r = x.c.size;
397 ap_dimperm_compose(&r.c, const_cast<ap_dimperm_t*>(&x.c), const_cast<ap_dimperm_t*>(&y.c));
407 ap_dimperm_invert(&
c, &tmp.c);
413 ap_dimperm_invert(&r.c, const_cast<ap_dimperm_t*>(&
c));
dimperm & operator=(const dimperm &x)
Copies x.
Definition: apxx_dimension.hh:274
ap_dim_t & get(size_t dim)
Returns a (modifiable) reference to an index in the underlying array (bound-checked).
Definition: apxx_dimension.hh:137
dimperm(size_t size=0)
Makes an uninitialized dimperm of the given size.
Definition: apxx_dimension.hh:224
const ap_dimperm_t * get_ap_dimperm_t() const
Returns a pointer to the internal APRON object stored in *this.
Definition: apxx_dimension.hh:423
std::ostream & operator<<(std::ostream &os, const abstract0 &s)
Definition: apxx_abstract0.hh:293
size_t size() const
Returns the size of the permutation.
Definition: apxx_dimension.hh:316
const ap_dimchange_t * get_ap_dimchange_t() const
Returns a pointer to the internal APRON object stored in *this.
Definition: apxx_dimension.hh:205
dimchange operator-() const
Returns the inverse of *this.
Definition: apxx_dimension.hh:194
ap_dimchange_t c
Structure managed by APRON.
Definition: apxx_dimension.hh:106
dimchange(size_t intdim=0, size_t realdim=0)
Makes an uninitialized dimchange.
Definition: apxx_dimension.hh:59
~dimperm()
Definition: apxx_dimension.hh:265
ap_dim_t & operator[](size_t dim)
Returns a (modifiable) reference to the image of dim.
Definition: apxx_dimension.hh:321
void print(FILE *stream=stdout) const
Prints to a C stream.
Definition: apxx_dimension.hh:369
ap_dim_t & get(size_t dim)
Returns a (modifiable) reference to the image of dim (bound-checked).
Definition: apxx_dimension.hh:331
dimchange & operator=(const dimchange &x)
(Deep) copy.
Definition: apxx_dimension.hh:99
void print(FILE *stream=stdout) const
Prints to a C stream.
Definition: apxx_dimension.hh:180
dimperm operator *(const dimperm &x, const dimperm &y)
Definition: apxx_dimension.hh:393
dimperm & operator *=(const dimperm &y)
Composes *this with y.
Definition: apxx_dimension.hh:380
size_t get_realdim() const
Returns the number of real dimensions to add/remove.
Definition: apxx_dimension.hh:132
size_t get_intdim() const
Returns the number of integer dimensions to add/remove.
Definition: apxx_dimension.hh:127
~dimchange()
Definition: apxx_dimension.hh:90
std::vector< std::string > * get_varname(std::basic_ostream< charT, Traits > &os)
Definition: apxx_dimension.hh:44
void add_invert()
Inverts *this.
Definition: apxx_dimension.hh:189
ap_dim_t & operator[](size_t dim)
Returns a (modifiable) reference to an index in the underlying array.
Definition: apxx_dimension.hh:149
dimperm operator-() const
Returns a new dimperm that is the inverse of *this.
Definition: apxx_dimension.hh:411
void invert()
Inverts *this.
Definition: apxx_dimension.hh:405
ap_dimperm_t c
Structure managed by APRON.
Definition: apxx_dimension.hh:296
static const int xindex
Index to stream-local data, allocated with xalloc.
Definition: apxx_dimension.hh:48