APRONXX  0.9.7
/builddir/build/BUILD/apron-0.9.10/apronxx/apxx_interval.hh
Go to the documentation of this file.
1 /* -*- C++ -*-
2  * apxx_interval.hh
3  *
4  * APRON Library / C++ class wrappers
5  *
6  * Copyright (C) Antoine Mine' 2007
7  *
8  */
9 /* This file is part of the APRON Library, released under LGPL license
10  with an exception allowing the redistribution of statically linked
11  executables.
12 
13  Please read the COPYING file packaged in the distribution.
14 */
15 
16 #ifndef __APXX_INTERVAL_HH
17 #define __APXX_INTERVAL_HH
18 
19 #include <vector>
20 #include "ap_interval.h"
21 #include "apxx_scalar.hh"
22 
23 
24 namespace apron {
25 
27 struct top {
28  top() {}
29 };
30 
31 
33 struct bottom {
34  bottom() {}
35 };
36 
37 
38 /* ================================= */
39 /* interval */
40 /* ================================= */
41 
42 
47 class interval : public use_malloc {
48 
49 protected:
50  ap_interval_t c;
51 
53  void init();
54 
56  interval(ap_interval_t* i);
57 
58  friend class abstract0;
59  friend class abstract1;
60  friend class linexpr0;
61  friend class texpr0;
62 
63 public:
64 
66  enum order {
67  INCLUDED = -1,
68  EQUAL = 0,
69  CONTAINS = 1,
70  LESS = -2,
71  GREATER = 2,
72  };
73 
74 
75  /* constructors */
76  /* ============ */
77 
80 
82  interval();
83 
85  interval(const interval& x);
86 
88  interval(const scalar& inf, const scalar& sup);
89 
91  interval(int inf, int sup);
92 
94  interval(long inf, long sup);
95 
97  interval(double inf, double sup);
98 
100  interval(const frac& inf, const frac& sup);
101 
103  interval(const mpq_class& inf, const mpq_class& sup);
106  interval(mpfr_t inf, mpfr_t sup);
107 
109  interval(top t);
110 
112  interval(bottom t);
113 
115 
116 
117  /* destructor */
118  /* ========== */
119 
122 
123  ~interval();
124 
127 
128  /* assignments */
129  /* =========== */
130 
133 
134  /* = */
135 
137  interval& operator= (const interval& x);
140  interval& operator= (top t);
141 
143  interval& operator= (bottom t);
144 
145 
146  /* set */
149  interval& set(const interval& x);
150 
152  interval& set(const scalar& inf, const scalar& sup);
155  interval& set(int inf, int sup);
156 
158  interval& set(long inf, long sup);
159 
161  interval& set(double inf, double sup);
162 
164  interval& set(const frac& inf, const frac& sup);
165 
167  interval& set(const mpq_class& inf, const mpq_class& sup);
168 
170  interval& set(mpfr_t inf, mpfr_t sup);
171 
173  interval& set(top t);
174 
176  interval& set(bottom t);
177 
178 
179  /* swap */
180 
182  friend void swap(interval& a, interval &b);
183 
186 
187  /* access */
188  /* ====== */
189 
192 
194  scalar& get_inf();
195 
197  scalar& get_sup();
198 
200  const scalar& get_inf() const;
201 
203  const scalar& get_sup() const;
204 
206 
207 
208  /* print */
209  /* ===== */
210 
213 
215  friend std::ostream& operator<< (std::ostream& os, const interval& s);
216 
218  void print(FILE* stream=stdout) const;
219 
221 
222 
223  /* tests */
224  /* ===== */
225 
230  bool is_top() const;
231 
233  bool is_bottom() const;
234 
236  friend bool operator<= (const interval&a, const interval &b);
237 
239  friend bool operator>= (const interval&a, const interval &b);
240 
242  friend bool operator< (const interval&a, const interval &b);
243 
245  friend bool operator> (const interval&a, const interval &b);
246 
248  friend bool operator== (const interval&a, const interval &b);
249 
251  friend bool operator!= (const interval&a, const interval &b);
254  friend order cmp (const interval&a, const interval &b);
255 
257 
258 
259  /* other operators */
260  /* =============== */
264 
266  void neg();
267 
269  interval operator- () const;
270 
272  long hash() const;
273 
275 
276 
277  /* C API compatibility */
278  /* =================== */
279 
282 
284  const ap_interval_t* get_ap_interval_t() const;
285 
287  ap_interval_t* get_ap_interval_t();
288 
290 };
291 
292 
293 
294 
295 /* ================================= */
296 /* interval_array */
297 /* ================================= */
298 
299 
302 class interval_array : public use_malloc {
303 
304 protected:
305 
306  size_t sz;
307  ap_interval_t** c;
308 
310  interval_array(size_t size, ap_interval_t** c);
311 
312  friend class abstract0;
313  friend class abstract1;
314 
315 public:
316 
317  /* constructors */
318  /* ============ */
319 
327  interval_array(size_t size);
328 
330  interval_array(const interval_array &x);
331 
333  interval_array(const std::vector<interval>& x);
334 
336  interval_array(size_t size, const interval x[]);
339 
340 
341  /* destructor */
342  /* ========== */
343 
346 
348  ~interval_array();
349 
351 
352 
353  /* assignment */
354  /* ========== */
355 
358 
363  interval_array& operator= (const interval_array &x);
369  interval_array& operator= (const std::vector<interval>& x);
370 
376  interval_array& operator= (const interval x[]);
377 
379 
380 
381  /* conversion */
382  /* ========== */
383 
386 
388  operator std::vector<interval>() const;
389 
391 
392 
393  /* print */
394  /* ===== */
395 
398 
400  friend std::ostream& operator<< (std::ostream& os, const interval_array& s);
401 
403  void print(FILE* stream=stdout) const;
404 
406 
407 
408  /* access */
409  /* ====== */
410 
413 
415  size_t size() const;
416 
418  interval** contents();
419 
421  interval& operator[](size_t i);
422 
424  const interval& operator[](size_t i) const;
425 
430  interval& get(size_t i);
431 
436  const interval& get(size_t i) const;
437 
439 
441  /* C-level compatibility */
442  /* ===================== */
443 
446 
448  const ap_interval_t * const * get_ap_interval_t_array() const;
449 
451  ap_interval_t** get_ap_interval_t_array();
454 };
455 
456 
457 #include "apxx_interval_inline.hh"
458 
459 }
461 #endif /* __APXX_INTERVAL_HH */
Definition: apxx_abstract0.hh:27
top()
Definition: apxx_interval.hh:28
interval(bottom t)
Makes a new empty interval [+1;-1].
Definition: apxx_interval.hh:104
array of interval(s).
Definition: apxx_interval.hh:302
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
texpr0::builder neg(const texpr0::builder &a, ap_texpr_rtype_t rtype=AP_RTYPE_REAL, ap_texpr_rdir_t rdir=AP_RDIR_NEAREST)
Definition: apxx_texpr0.hh:814
Level 0 abstract value (ap_abstract0_t* wrapper).
Definition: apxx_abstract0.hh:78
int cmp(const coeff &a, const coeff &b)
Definition: apxx_coeff.hh:415
size_t sz
Array size.
Definition: apxx_interval.hh:306
texpr0::builder operator-(const texpr0::builder &a)
Definition: apxx_texpr0.hh:854
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 operator>(const abstract0 &x, const abstract0 &y)
Definition: apxx_abstract0.hh:434
Level 0 arbitrary expression tree (ap_texpr0_t wrapper).
Definition: apxx_texpr0.hh:92
bool operator>=(const abstract0 &x, const abstract0 &y)
Definition: apxx_abstract0.hh:429
order
Returned by ordering functions.
Definition: apxx_interval.hh:66
Empty interval or domain, to simplify initialisations and assignments.
Definition: apxx_interval.hh:33
Level 1 abstract value (ap_abstract1_t wrapper).
Definition: apxx_abstract1.hh:42
Full interval (]-oo,+oo[) or domain, to simplify initialisations and assignments. ...
Definition: apxx_interval.hh:27
bool operator!=(const abstract0 &x, const abstract0 &y)
Definition: apxx_abstract0.hh:417
Interval (ap_interval_t wrapper).
Definition: apxx_interval.hh:47
Inherited by most wrappers to map new and delete to malloc and free.
Definition: apxx_scalar.hh:69
A fraction with native int coefficients, to simplify initialisations and assignments.
Definition: apxx_scalar.hh:41
bool operator<=(const abstract0 &x, const abstract0 &y)
Definition: apxx_abstract0.hh:422
bottom()
Definition: apxx_interval.hh:34
Level 0 linear expression (ap_linexpr0_t wrapper).
Definition: apxx_linexpr0.hh:44
bool operator<(const abstract0 &x, const abstract0 &y)
Definition: apxx_abstract0.hh:439
Scalar (ap_scalar_t wrapper).
Definition: apxx_scalar.hh:89