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));
364 :
sz(size),
c(ap_interval_array_alloc(size))
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]);
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()));
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()));
395 ap_interval_array_free(c,
sz);
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]);
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()));
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]);
454 for (
size_t i=0;i<s.sz;i++)
455 os << s.get(i) <<
" ";
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,
" ");
477 {
return reinterpret_cast<interval**
>(
c); }
481 if (i >=
sz)
throw std::out_of_range(
"apron::interval_array::get(size_t)");
482 return reinterpret_cast<interval&
>(*c[i]);
487 if (i >=
sz)
throw std::out_of_range(
"apron::interval_array::get(size_t)");
488 return reinterpret_cast<interval&
>(*c[i]);
493 return reinterpret_cast<interval&
>(*c[i]);
498 return reinterpret_cast<interval&
>(*c[i]);
void print(FILE *stream=stdout) const
Prints to a C stream.
Definition: apxx_interval.hh:252
interval & set(const interval &x)
Copies an interval into *this.
Definition: apxx_interval.hh:147
interval & get(size_t i)
Definition: apxx_interval.hh:480
~interval_array()
Frees the space occupied by the array and all its elements.
Definition: apxx_interval.hh:394
void swap(coeff &a, coeff &b)
Definition: apxx_coeff.hh:382
void print(FILE *stream=stdout) const
Prints to a C stream.
Definition: apxx_interval.hh:460
size_t size() const
Returns the array size.
Definition: apxx_interval.hh:474
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
size_t sz
Array size.
Definition: apxx_interval.hh:306
interval_array & operator=(const interval_array &x)
Copies an interval array into *this.
Definition: apxx_interval.hh:403
bool operator==(const abstract0 &x, const abstract0 &y)
Definition: apxx_abstract0.hh:410
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
interval ** contents()
Returns a pointer to the start of the array of elements used internally.
Definition: apxx_interval.hh:477
ap_interval_t ** c
Array of pointers to intervals.
Definition: apxx_interval.hh:307
interval operator-() const
Returns a new interval which is the opposite of *this.
Definition: apxx_interval.hh:322
void neg()
Negates *this.
Definition: apxx_interval.hh:317
long hash() const
Returns a hash code.
Definition: apxx_interval.hh:329
bool is_top() const
Whether *this equals ]-oo;+oo[.
Definition: apxx_interval.hh:261
bool operator>=(const abstract0 &x, const abstract0 &y)
Definition: apxx_abstract0.hh:429
order
Returned by ordering functions.
Definition: apxx_interval.hh:66
bool operator!=(const abstract0 &x, const abstract0 &y)
Definition: apxx_abstract0.hh:417
const ap_interval_t *const * get_ap_interval_t_array() const
Returns a pointer to the internal APRON object stored in *this.
Definition: apxx_interval.hh:506
interval & operator=(const interval &x)
Copies an interval into *this.
Definition: apxx_interval.hh:126
bool is_bottom() const
Whether *this represents an empty interval.
Definition: apxx_interval.hh:266
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
interval & operator[](size_t i)
Returns a (modifiable) reference to an element, no bound checking.
Definition: apxx_interval.hh:492
friend std::ostream & operator<<(std::ostream &os, const interval_array &s)
Printing.
Definition: apxx_interval.hh:452
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