APRONXX  0.9.12
/builddir/build/BUILD/apron-0.9.13/apronxx/apxx_lincons0.hh
Go to the documentation of this file.
1 /* -*- C++ -*-
2  * apxx_lincons0.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_LINCONS0_HH
17 #define __APXX_LINCONS0_HH
18 
19 #include <vector>
20 #include "ap_lincons0.h"
21 #include "apxx_linexpr0.hh"
22 
23 
24 namespace apron {
25 
26 
28 struct unsat {};
29 
30 
31 
32 /* ================================= */
33 /* lincons0 */
34 /* ================================= */
35 
36 
43 class lincons0 : public use_malloc {
44 
45 protected:
46 
47  ap_lincons0_t l;
48 
50  lincons0(ap_lincons0_t l);
51 
52  friend class abstract0;
53 
54 public:
55 
56 
57  /* constructors */
58  /* ============ */
59 
62 
69  lincons0(ap_constyp_t constyp=AP_CONS_SUPEQ);
70 
76  lincons0(ap_constyp_t constyp, const linexpr0& lin);
77 
82  lincons0(ap_constyp_t constyp, const linexpr0& lin, const scalar& modulo);
83 
85  lincons0(const lincons0& x);
86 
88  lincons0(const lincons0& x, const dimchange& d);
89 
91  lincons0(const lincons0& x, const dimperm& d);
92 
94  lincons0(unsat x);
95 
97 
98 
99  /* destructor */
100  /* ========== */
101 
104 
106  ~lincons0();
107 
109 
110 
111  /* assignment */
112  /* ========== */
113 
116 
118  lincons0& operator= (const lincons0& x);
119 
122 
128  void set_modulo(const scalar& c);
129 
135  void set_linexpr(const linexpr0& c);
136 
138 
139 
140  /* dimension operations */
141  /* ==================== */
142 
145 
150  void resize(size_t size);
151 
156  void add_dimensions(const dimchange& d);
157 
162  void permute_dimensions(const dimperm& d);
163 
165 
166 
167  /* access */
168  /* ====== */
169 
172 
173  /* size */
174 
179  size_t size() const;
180 
181 
182  /* get */
183 
188  ap_constyp_t& get_constyp();
189 
194  const ap_constyp_t& get_constyp() const;
195 
197  bool has_modulo() const;
198 
204  bool has_linexpr() const;
205 
210  scalar& get_modulo();
211 
216  const scalar& get_modulo() const;
217 
223 
228  const linexpr0& get_linexpr() const;
229 
234  coeff& get_cst();
235 
240  const coeff& get_cst() const;
241 
248  coeff& operator[](ap_dim_t dim);
249 
256  const coeff& operator[](ap_dim_t dim) const;
257 
259 
260 
261  /* print */
262  /* ===== */
263 
266 
274  friend std::ostream& operator<< (std::ostream& os, const lincons0& s);
275 
277  void print(char** name_of_dim=NULL, FILE* stream=stdout) const;
278 
280 
281 
282  /* tests */
283  /* ===== */
284 
287 
293  bool is_unsat() const;
294 
299  bool is_linear() const;
300 
306  bool is_quasilinear() const;
307 
308  // TODO: equal, compare (currently not in ap_lincons0.h) ???
309 
311 
312  /* TODO: evaluation, linearization, intelligent constructors */
313 
314 
315  /* C-level compatibility */
316  /* ===================== */
317 
320 
322  const ap_lincons0_t* get_ap_lincons0_t() const;
323 
325  ap_lincons0_t* get_ap_lincons0_t();
326 
328 };
329 
330 
331 
332 /* ================================= */
333 /* lincons0_array */
334 /* ================================= */
335 
336 
341 class lincons0_array : public use_malloc {
342 
343 protected:
344 
345  ap_lincons0_array_t a;
346 
348  lincons0_array(ap_lincons0_array_t& a) : a(a) {}
349 
350  friend class lincons1_array;
351  friend class abstract0;
352 
353 public:
354 
355  /* constructors */
356  /* ============ */
357 
360 
365  lincons0_array(size_t size);
366 
368  lincons0_array(const lincons0_array& x);
369 
371  lincons0_array(const lincons0_array& x, const dimchange& d);
372 
374  lincons0_array(const lincons0_array& x, const dimperm& d);
375 
377  lincons0_array(size_t size, const lincons0 x[]);
378 
380  lincons0_array(const std::vector<lincons0>& x);
381 
383 
384 
385  /* destructor */
386  /* ========== */
387 
390 
392  ~lincons0_array();
393 
395 
396 
397  /* assignment */
398  /* ========== */
399 
402 
405 
410  lincons0_array& operator= (const lincons0 x[]);
411 
413  lincons0_array& operator= (const std::vector<lincons0>& x);
414 
416 
417 
418  /* dimension operations */
419  /* ==================== */
420 
423 
425  void resize(size_t size);
426 
428  void add_dimensions(const dimchange& d);
429 
431  void permute_dimensions(const dimperm& d);
432 
434 
435 
436  /* access */
437  /* ====== */
438 
441 
443  size_t size() const;
444 
446  lincons0* contents();
447 
449  const lincons0* contents() const;
450 
452  lincons0& operator[](size_t i);
453 
455  const lincons0& operator[](size_t i) const;
456 
461  lincons0& get(size_t i);
462 
467  const lincons0& get(size_t i) const;
468 
470 
471 
472  /* conversion */
473  /* ========== */
474 
477 
479  operator std::vector<lincons0>() const;
480 
482 
483 
484  /* print */
485  /* ===== */
486 
489 
497  friend std::ostream& operator<< (std::ostream& os, const lincons0_array& s);
498 
500  void print(char** name_of_dim = NULL, FILE* stream=stdout) const;
501 
503 
504 
505  /* tests */
506  /* ===== */
507 
510 
512  bool is_linear() const;
513 
515  bool is_quasilinear() const;
516 
518 
519 
520  /* C-level compatibility */
521  /* ===================== */
522 
525 
527  const ap_lincons0_array_t* get_ap_lincons0_array_t() const;
528 
530  ap_lincons0_array_t* get_ap_lincons0_array_t();
531 
533 
534 };
535 
536 #include "apxx_lincons0_inline.hh"
537 
538 }
539 
540 #endif /* __APXX_LINCONS0_HH */
apxx_lincons0_inline.hh
apron::lincons0::permute_dimensions
void permute_dimensions(const dimperm &d)
Applies a permutation to the underlying linear expression.
Definition: apxx_lincons0_inline.hh:114
apron::lincons0_array::add_dimensions
void add_dimensions(const dimchange &d)
Applies add_dimensions to all constraints in the array.
Definition: apxx_lincons0_inline.hh:361
apron::abstract0
Level 0 abstract value (ap_abstract0_t* wrapper).
Definition: apxx_abstract0.hh:78
apron::lincons0::operator<<
friend std::ostream & operator<<(std::ostream &os, const lincons0 &s)
Printing.
apron::lincons0::get_cst
coeff & get_cst()
Returns a (modifiable) reference to the constant coefficient.
Definition: apxx_lincons0_inline.hh:191
apron::lincons0::get_constyp
ap_constyp_t & get_constyp()
Returns a (modifiable) reference to the constraint type.
Definition: apxx_lincons0_inline.hh:135
apron::lincons0::has_linexpr
bool has_linexpr() const
Whether the constraint has a valid linear expression.
Definition: apxx_lincons0_inline.hh:150
apron::lincons1_array
Array of linear constraints (ap_lincons1_array_t wrapper).
Definition: apxx_lincons1.hh:331
apron::lincons0::lincons0
lincons0(ap_lincons0_t l)
Internal use only. Performs a shallow copy and takes ownership of the contents.
Definition: apxx_lincons0_inline.hh:23
apron::lincons0::set_linexpr
void set_linexpr(const linexpr0 &c)
Sets the underlying linear expression to c (copied).
Definition: apxx_lincons0_inline.hh:185
apron::dimchange
Dimension change object (ap_dimchange_t wrapper).
Definition: apxx_dimension.hh:102
apron::coeff
Coefficient (ap_coeff_t wrapper).
Definition: apxx_coeff.hh:36
apron::lincons0::get_modulo
scalar & get_modulo()
Returns a (modifiable) reference to the auxiliary scalar.
Definition: apxx_lincons0_inline.hh:155
apron::lincons0::get_ap_lincons0_t
const ap_lincons0_t * get_ap_lincons0_t() const
Returns a pointer to the internal APRON object stored in *this.
Definition: apxx_lincons0_inline.hh:252
apron::lincons0_array::permute_dimensions
void permute_dimensions(const dimperm &d)
Applies permute_dimensions to all constraints in the array.
Definition: apxx_lincons0_inline.hh:366
apron::lincons0_array::lincons0_array
lincons0_array(ap_lincons0_array_t &a)
Internal use only. Performs a shallow copy and takes ownership of the contents.
Definition: apxx_lincons0.hh:348
apron::lincons0::print
void print(char **name_of_dim=NULL, FILE *stream=stdout) const
Prints to a C stream.
Definition: apxx_lincons0_inline.hh:220
apron::lincons0::lincons0
lincons0(ap_constyp_t constyp=AP_CONS_SUPEQ)
Creates a new (non-modulo) constraint from an empty linear expression.
apron::lincons0::size
size_t size() const
Returns the size of the underlying linear expression.
Definition: apxx_lincons0_inline.hh:126
apron::lincons0::set_modulo
void set_modulo(const scalar &c)
Sets the auxiliary scalar modulo to c (copied).
Definition: apxx_lincons0_inline.hh:167
apron::dim
Represents a dimension (i.e., variable by index) in an expression tree.
Definition: apxx_texpr0.hh:33
apron::lincons0::l
ap_lincons0_t l
Structure managed by APRON.
Definition: apxx_lincons0.hh:47
apron::lincons0_array::operator<<
friend std::ostream & operator<<(std::ostream &os, const lincons0_array &s)
Printing.
apron::use_malloc
Inherited by most wrappers to map new and delete to malloc and free.
Definition: apxx_scalar.hh:69
apron::lincons0_array::get_ap_lincons0_array_t
const ap_lincons0_array_t * get_ap_lincons0_array_t() const
Returns a pointer to the internal APRON object stored in *this.
Definition: apxx_lincons0_inline.hh:462
apron::lincons0::is_quasilinear
bool is_quasilinear() const
Whether the underlying linear expression has only scalar coefficients, except maybe for the constant ...
Definition: apxx_lincons0_inline.hh:241
apxx_linexpr0.hh
apron::lincons0_array::operator=
lincons0_array & operator=(const lincons0_array &x)
(Deep) copy.
Definition: apxx_lincons0_inline.hh:322
apron::dimperm
Dimension permutation object (ap_dimperm_t wrapper).
Definition: apxx_dimension.hh:292
apron::lincons0::operator=
lincons0 & operator=(const lincons0 &x)
(Deep) copy.
Definition: apxx_lincons0_inline.hh:81
apron::lincons0_array::resize
void resize(size_t size)
Resizes the array.
Definition: apxx_lincons0_inline.hh:356
apron::lincons0_array::~lincons0_array
~lincons0_array()
Frees the space used by the array and all its constraints.
Definition: apxx_lincons0_inline.hh:313
apron::lincons0_array::print
void print(char **name_of_dim=NULL, FILE *stream=stdout) const
Prints to a C stream.
Definition: apxx_lincons0_inline.hh:438
apron::lincons0::is_linear
bool is_linear() const
Whether the underlying linear expression has only scalar coefficients.
Definition: apxx_lincons0_inline.hh:235
apron::lincons0::~lincons0
~lincons0()
Frees the constraint, including the embedded linear expression and optional modulo scalar.
Definition: apxx_lincons0_inline.hh:72
apron::lincons0_array::is_quasilinear
bool is_quasilinear() const
Whether all constraints are quasi-linear.
Definition: apxx_lincons0_inline.hh:452
apron::lincons0::get_linexpr
linexpr0 & get_linexpr()
Returns a (modifiable) reference to the underlying linear expression.
Definition: apxx_lincons0_inline.hh:173
apron::lincons0::add_dimensions
void add_dimensions(const dimchange &d)
Changes the dimension of the underlying linear expression.
Definition: apxx_lincons0_inline.hh:108
apron::lincons0_array::operator[]
lincons0 & operator[](size_t i)
Returns a (modifiable) reference to an element, no bound checking.
Definition: apxx_lincons0_inline.hh:390
apron::linexpr0
Level 0 linear expression (ap_linexpr0_t wrapper).
Definition: apxx_linexpr0.hh:44
apron::lincons0::operator[]
coeff & operator[](ap_dim_t dim)
Returns a (modifiable) reference to the coefficient corresponding to the given dimension.
Definition: apxx_lincons0_inline.hh:197
apron::lincons0::is_unsat
bool is_unsat() const
Whether the constraint is unsatisfiable.
Definition: apxx_lincons0_inline.hh:229
apron::lincons0_array::is_linear
bool is_linear() const
Whether all constraints are linear.
Definition: apxx_lincons0_inline.hh:447
apron::unsat
Unsatisfiable constraint, to simplify initialisations and assignments.
Definition: apxx_lincons0.hh:28
apron::lincons0::has_modulo
bool has_modulo() const
Whether the constraint has a valid auxiliary scalar (used in modulo constraints).
Definition: apxx_lincons0_inline.hh:145
apron::lincons0
Level 0 linear constraint (ap_lincons0_t wrapper).
Definition: apxx_lincons0.hh:43
apron::lincons0_array
Array of linear constraints (ap_lincons0_array_t wrapper).
Definition: apxx_lincons0.hh:341
apron::lincons0_array::get
lincons0 & get(size_t i)
Returns a (modifiable) reference to an element (bound-checked).
Definition: apxx_lincons0_inline.hh:400
apron::lincons0_array::contents
lincons0 * contents()
Returns a pointer to the start of the internal array holding the constraints.
Definition: apxx_lincons0_inline.hh:380
apron::lincons0::resize
void resize(size_t size)
Resizes the underlying linear expression.
Definition: apxx_lincons0_inline.hh:101
apron::scalar
Scalar (ap_scalar_t wrapper).
Definition: apxx_scalar.hh:89
apron::lincons0_array::a
ap_lincons0_array_t a
Structure managed by APRON.
Definition: apxx_lincons0.hh:345
apron::lincons0_array::size
size_t size() const
Returns the size of the array.
Definition: apxx_lincons0_inline.hh:375
apron
Definition: apxx_abstract0.hh:27