28 inline void interval::init()
30 c.inf = ap_scalar_alloc();
31 c.sup = ap_scalar_alloc();
34 inline interval::interval(ap_interval_t* i)
48 ap_interval_set(&
c, const_cast<ap_interval_t*>(&x.c));
54 ap_interval_set_scalar(&
c,
55 const_cast<ap_scalar_t*>(inf.get_ap_scalar_t()),
56 const_cast<ap_scalar_t*>(sup.get_ap_scalar_t()));
62 ap_interval_set_int(&
c, inf, sup);
68 ap_interval_set_int(&
c, inf, sup);
74 ap_interval_set_double(&
c, inf, sup);
80 ap_interval_set_frac(&
c, inf.num, inf.den, sup.num, sup.den);
86 ap_interval_set_mpq(&
c,
87 const_cast<mpq_class&>(inf).get_mpq_t(),
88 const_cast<mpq_class&>(sup).get_mpq_t());
94 ap_interval_set_mpfr(&
c,inf,sup);
100 ap_interval_set_top(&
c);
106 ap_interval_set_bottom(&
c);
115 ap_scalar_free(
c.inf);
116 ap_scalar_free(
c.sup);
127 ap_interval_set(&
c, const_cast<ap_interval_t*>(&x.c));
133 ap_interval_set_top(&
c);
139 ap_interval_set_bottom(&
c);
148 ap_interval_set(&
c, const_cast<ap_interval_t*>(&x.c));
152 inline interval&
interval::set(
const scalar& inf,
const scalar& sup)
154 ap_interval_set_scalar(&
c,
155 const_cast<ap_scalar_t*>(inf.get_ap_scalar_t()),
156 const_cast<ap_scalar_t*>(sup.get_ap_scalar_t()));
162 ap_interval_set_int(&
c, inf, sup);
168 ap_interval_set_int(&
c, inf, sup);
174 ap_interval_set_double(&
c, inf, sup);
178 inline interval&
interval::set(
const frac& inf,
const frac& sup)
180 ap_interval_set_frac(&
c, inf.num, inf.den, sup.num, sup.den);
184 inline interval&
interval::set(
const mpq_class& inf,
const mpq_class& sup)
186 ap_interval_set_mpq(&
c,
187 const_cast<mpq_class&>(inf).get_mpq_t(),
188 const_cast<mpq_class&>(sup).get_mpq_t());
194 ap_interval_set_mpfr(&
c,inf,sup);
200 ap_interval_set_top(&
c);
206 ap_interval_set_bottom(&
c);
213 inline void swap(interval& a, interval &b)
215 ap_interval_swap(&a.c, &b.c);
224 return reinterpret_cast<scalar&>(*
c.inf);
229 return reinterpret_cast<scalar&>(*
c.sup);
234 return reinterpret_cast<const scalar&>(*
c.inf);
239 return reinterpret_cast<const scalar&>(*
c.sup);
246 inline std::ostream&
operator<< (std::ostream& os,
const interval& s)
248 return os <<
'[' << s.get_inf() <<
',' << s.get_sup() <<
']';
253 ap_interval_fprint(stream, const_cast<ap_interval_t*>(&
c));
262 return ap_interval_is_top(const_cast<ap_interval_t*>(&
c));
267 return ap_interval_is_bottom(const_cast<ap_interval_t*>(&
c));
272 return ap_interval_is_leq(const_cast<ap_interval_t*>(&a.c),
273 const_cast<ap_interval_t*>(&b.c));
278 return ap_interval_is_leq(const_cast<ap_interval_t*>(&b.c),
279 const_cast<ap_interval_t*>(&a.c));
282 inline bool operator< (
const interval&a,
const interval &b)
284 return ap_interval_cmp(const_cast<ap_interval_t*>(&a.c),
285 const_cast<ap_interval_t*>(&b.c)) == -1;
288 inline bool operator> (
const interval&a,
const interval &b)
290 return ap_interval_cmp(const_cast<ap_interval_t*>(&a.c),
291 const_cast<ap_interval_t*>(&b.c)) == 1;
296 return ap_interval_equal(const_cast<ap_interval_t*>(&a.c),
297 const_cast<ap_interval_t*>(&b.c));
302 return !ap_interval_equal(const_cast<ap_interval_t*>(&a.c),
303 const_cast<ap_interval_t*>(&b.c));
308 return (
interval::order)ap_interval_cmp(const_cast<ap_interval_t*>(&a.c),
309 const_cast<ap_interval_t*>(&b.c));
318 ap_interval_neg(&
c, &
c);
330 return ap_interval_hash(const_cast<ap_interval_t*>(&
c));
363 inline interval_array::interval_array(
size_t size)
364 : sz(size), c(ap_interval_array_alloc(size))
367 inline interval_array::interval_array(
const interval_array &x)
368 : sz(x.sz), c(ap_interval_array_alloc(x.sz))
370 for (
size_t i=0;i<sz;i++)
371 ap_interval_set(c[i], x.c[i]);
374 inline interval_array::interval_array(
const std::vector<interval>& x)
375 : sz(x.size()), c(ap_interval_array_alloc(x.size()))
377 for (
size_t i=0;i<sz;i++)
378 ap_interval_set(c[i], const_cast<ap_interval_t*>(x[i].get_ap_interval_t()));
381 inline interval_array::interval_array(
size_t size,
const interval x[])
382 : sz(size), c(ap_interval_array_alloc(size))
384 for (
size_t i=0;i<size;i++)
385 ap_interval_set(c[i], const_cast<ap_interval_t*>(x[i].get_ap_interval_t()));
393 inline interval_array::~interval_array()
395 ap_interval_array_free(c, sz);
402 inline interval_array& interval_array::operator= (
const interval_array &x)
406 ap_interval_array_free(c, sz);
408 c = ap_interval_array_alloc(sz);
410 for (
size_t i=0;i<sz;i++)
411 ap_interval_set(c[i], x.c[i]);
416 inline interval_array& interval_array::operator= (
const std::vector<interval>& x)
418 if (sz != x.size()) {
419 ap_interval_array_free(c, sz);
421 c = ap_interval_array_alloc(sz);
423 for (
size_t i=0;i<sz;i++)
424 ap_interval_set(c[i], const_cast<ap_interval_t*>(x[i].get_ap_interval_t()));
428 inline interval_array& interval_array::operator= (
const interval x[])
430 for (
size_t i=0;i<sz;i++)
431 ap_interval_set(c[i], const_cast<ap_interval_t*>(x[i].get_ap_interval_t()));
439 inline interval_array::operator std::vector<interval>()
const 441 std::vector<interval> v = std::vector<interval>(sz);
442 for (
size_t i=0;i<sz;i++)
443 ap_interval_set(v[i].get_ap_interval_t(), c[i]);
451 inline std::ostream&
operator<< (std::ostream& os,
const interval_array& s)
454 for (
size_t i=0;i<s.sz;i++)
455 os << s.get(i) <<
" ";
459 inline void interval_array::print(FILE* stream)
const 461 fprintf(stream,
"{ " );
462 for (
size_t i=0;i<sz;i++) {
463 ap_interval_fprint(stream, const_cast<ap_interval_t*>(c[i]));
464 fprintf(stream,
" ");
473 inline size_t interval_array::size()
const 476 inline interval** interval_array::contents()
477 {
return reinterpret_cast<interval**>(c); }
479 inline interval& interval_array::get(
size_t i)
481 if (i >= sz)
throw std::out_of_range(
"apron::interval_array::get(size_t)");
482 return reinterpret_cast<interval&>(*c[i]);
485 inline const interval& interval_array::get(
size_t i)
const 487 if (i >= sz)
throw std::out_of_range(
"apron::interval_array::get(size_t)");
488 return reinterpret_cast<interval&>(*c[i]);
491 inline interval& interval_array::operator[](
size_t i)
493 return reinterpret_cast<interval&>(*c[i]);
496 inline const interval& interval_array::operator[](
size_t i)
const 498 return reinterpret_cast<interval&>(*c[i]);
505 inline const ap_interval_t *
const * interval_array::get_ap_interval_t_array()
const 510 inline ap_interval_t** interval_array::get_ap_interval_t_array()
interval & set(const interval &x)
Copies an interval into *this.
Definition: apxx_interval.hh:147
std::ostream & operator<<(std::ostream &os, const abstract0 &s)
Definition: apxx_abstract0.hh:293
void swap(coeff &a, coeff &b)
Definition: apxx_coeff.hh:382
int cmp(const coeff &a, const coeff &b)
Definition: apxx_coeff.hh:415
~interval()
Definition: apxx_interval.hh:114
interval()
Makes a new interval [0,0] with double bounds.
Definition: apxx_interval.hh:41
ap_interval_t c
Structure managed by APRON.
Definition: apxx_interval.hh:50
bool operator==(const abstract0 &x, const abstract0 &y)
Definition: apxx_abstract0.hh:410
bool is_bottom() const
Whether *this represents an empty interval.
Definition: apxx_interval.hh:266
scalar & get_inf()
Gets a (modifiable) reference to the lower bound.
Definition: apxx_interval.hh:223
bool operator>(const abstract0 &x, const abstract0 &y)
Definition: apxx_abstract0.hh:434
void init()
Internal initialisation.
Definition: apxx_interval.hh:29
bool is_top() const
Whether *this equals ]-oo;+oo[.
Definition: apxx_interval.hh:261
void neg()
Negates *this.
Definition: apxx_interval.hh:317
void print(FILE *stream=stdout) const
Prints to a C stream.
Definition: apxx_interval.hh:252
bool operator>=(const abstract0 &x, const abstract0 &y)
Definition: apxx_abstract0.hh:429
order
Returned by ordering functions.
Definition: apxx_interval.hh:66
long hash() const
Returns a hash code.
Definition: apxx_interval.hh:329
bool operator!=(const abstract0 &x, const abstract0 &y)
Definition: apxx_abstract0.hh:417
std::ostream & operator<<(std::ostream &os, const interval &s)
Definition: apxx_interval_inline.hh:246
interval & operator=(const interval &x)
Copies an interval into *this.
Definition: apxx_interval.hh:126
interval operator-() const
Returns a new interval which is the opposite of *this.
Definition: apxx_interval.hh:322
const ap_interval_t * get_ap_interval_t() const
Returns a pointer to the internal APRON object stored in *this.
Definition: apxx_interval.hh:337
bool operator<=(const abstract0 &x, const abstract0 &y)
Definition: apxx_abstract0.hh:422
scalar & get_sup()
Gets a (modifiable) reference to the upper bound.
Definition: apxx_interval.hh:228
bool operator<(const abstract0 &x, const abstract0 &y)
Definition: apxx_abstract0.hh:439
interval_array(size_t size, ap_interval_t **c)
Internal use only. Reference an array created with ap_interval_array_alloc.
Definition: apxx_interval.hh:356