PPL  1.2
Pointset_Powerset_inlines.hh
Go to the documentation of this file.
1 /* Pointset_Powerset class implementation: inline functions.
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_Pointset_Powerset_inlines_hh
25 #define PPL_Pointset_Powerset_inlines_hh 1
26 
27 #include "Constraint_defs.hh"
30 #include "Congruence_defs.hh"
33 #include "C_Polyhedron_defs.hh"
34 #include "NNC_Polyhedron_defs.hh"
35 #include <algorithm>
36 #include <deque>
37 
38 namespace Parma_Polyhedra_Library {
39 
40 template <typename PSET>
41 inline dimension_type
43  return space_dim;
44 }
45 
46 template <typename PSET>
47 inline dimension_type
50 }
51 
52 template <typename PSET>
53 inline
55  Degenerate_Element kind)
56  : Base(), space_dim(num_dimensions) {
57  Pointset_Powerset& x = *this;
58  if (kind == UNIVERSE) {
59  x.sequence.push_back(Determinate<PSET>(PSET(num_dimensions, kind)));
60  }
61  PPL_ASSERT_HEAVY(x.OK());
62 }
63 
64 template <typename PSET>
65 inline
68  : Base(y), space_dim(y.space_dim) {
69 }
70 
71 template <typename PSET>
72 inline
74  Complexity_Class complexity)
75  : Base(), space_dim(ph.space_dimension()) {
76  Pointset_Powerset& x = *this;
77  if (complexity == ANY_COMPLEXITY) {
78  if (ph.is_empty()) {
79  return;
80  }
81  }
82  else {
83  x.reduced = false;
84  }
85  x.sequence.push_back(Determinate<PSET>(PSET(ph, complexity)));
86  x.reduced = false;
87  PPL_ASSERT_HEAVY(OK());
88 }
89 
90 template <typename PSET>
91 inline
93  Complexity_Class complexity)
94  : Base(), space_dim(ph.space_dimension()) {
95  Pointset_Powerset& x = *this;
96  if (complexity == ANY_COMPLEXITY) {
97  if (ph.is_empty()) {
98  return;
99  }
100  }
101  else {
102  x.reduced = false;
103  }
104  x.sequence.push_back(Determinate<PSET>(PSET(ph, complexity)));
105  PPL_ASSERT_HEAVY(OK());
106 }
107 
108 template <typename PSET>
109 inline
112  : Base(), space_dim(gr.space_dimension()) {
113  Pointset_Powerset& x = *this;
114  if (!gr.is_empty()) {
115  x.sequence.push_back(Determinate<PSET>(PSET(gr)));
116  }
117  PPL_ASSERT_HEAVY(OK());
118 }
119 
120 template <typename PSET>
121 template <typename QH1, typename QH2, typename R>
122 inline
125  Complexity_Class complexity)
126  : Base(), space_dim(prp.space_dimension()) {
127  Pointset_Powerset& x = *this;
128  if (complexity == ANY_COMPLEXITY) {
129  if (prp.is_empty()) {
130  return;
131  }
132  }
133  else {
134  x.reduced = false;
135  }
136  x.sequence.push_back(Determinate<PSET>(PSET(prp, complexity)));
137  x.reduced = false;
138  PPL_ASSERT_HEAVY(OK());
139 }
140 
141 template <typename PSET>
142 template <typename Interval>
145  : Base(), space_dim(box.space_dimension()) {
146  Pointset_Powerset& x = *this;
147  if (!box.is_empty()) {
148  x.sequence.push_back(Determinate<PSET>(PSET(box)));
149  }
150  PPL_ASSERT_HEAVY(OK());
151 }
152 
153 template <typename PSET>
154 template <typename T>
157  : Base(), space_dim(os.space_dimension()) {
158  Pointset_Powerset& x = *this;
159  if (!os.is_empty()) {
160  x.sequence.push_back(Determinate<PSET>(PSET(os)));
161  }
162  PPL_ASSERT_HEAVY(OK());
163 }
164 
165 template <typename PSET>
166 template <typename T>
169  : Base(), space_dim(bds.space_dimension()) {
170  Pointset_Powerset& x = *this;
171  if (!bds.is_empty()) {
172  x.sequence.push_back(Determinate<PSET>(PSET(bds)));
173  }
174  PPL_ASSERT_HEAVY(OK());
175 }
176 
177 template <typename PSET>
178 inline
180  : Base(Determinate<PSET>(cs)), space_dim(cs.space_dimension()) {
181  PPL_ASSERT_HEAVY(OK());
182 }
183 
184 template <typename PSET>
185 inline
187  : Base(Determinate<PSET>(cgs)), space_dim(cgs.space_dimension()) {
188  PPL_ASSERT_HEAVY(OK());
189 }
190 
191 template <typename PSET>
194  Pointset_Powerset& x = *this;
195  x.Base::operator=(y);
196  x.space_dim = y.space_dim;
197  return x;
198 }
199 
200 template <typename PSET>
201 inline void
203  Pointset_Powerset& x = *this;
204  x.Base::m_swap(y);
205  using std::swap;
206  swap(x.space_dim, y.space_dim);
207 }
208 
209 template <typename PSET>
210 template <typename QH>
213  Pointset_Powerset& x = *this;
215  swap(x, ps);
216  return x;
217 }
218 
219 template <typename PSET>
220 inline void
222  Pointset_Powerset& x = *this;
224  Det_PSET::lift_op_assign(std::mem_fun_ref(&PSET::intersection_assign)));
225 }
226 
227 template <typename PSET>
228 inline void
230  Pointset_Powerset& x = *this;
232  Det_PSET::lift_op_assign(std::mem_fun_ref(&PSET::time_elapse_assign)));
233 }
234 
235 template <typename PSET>
236 inline Poly_Con_Relation
238  return relation_with_aux(c);
239 }
240 
241 template <typename PSET>
242 inline Poly_Con_Relation
244  return relation_with_aux(cg);
245 }
246 
247 template <typename PSET>
248 inline bool
251  // This code is only used when PSET is an abstraction of NNC_Polyhedron.
252  const Pointset_Powerset<NNC_Polyhedron> xx(*this);
254  return xx.geometrically_covers(yy);
255 }
256 
257 template <typename PSET>
258 inline bool
261  // This code is only used when PSET is an abstraction of NNC_Polyhedron.
262  const Pointset_Powerset<NNC_Polyhedron> xx(*this);
264  return xx.geometrically_covers(yy) && yy.geometrically_covers(xx);
265 }
266 
267 template <>
268 inline bool
271  const Pointset_Powerset& x = *this;
272  return x.geometrically_covers(y) && y.geometrically_covers(x);
273 }
274 
275 template <>
276 inline bool
279  const Pointset_Powerset& x = *this;
280  return x.geometrically_covers(y) && y.geometrically_covers(x);
281 }
282 
283 template <typename PSET>
284 inline memory_size_type
287 }
288 
289 template <typename PSET>
290 inline memory_size_type
292  return sizeof(*this) + external_memory_in_bytes();
293 }
294 
295 template <typename PSET>
296 inline int32_t
298  return hash_code_from_dimension(space_dimension());
299 }
300 
301 template <typename PSET>
302 inline void
305  // This code is only used when PSET is an abstraction of NNC_Polyhedron.
306  Pointset_Powerset<NNC_Polyhedron> nnc_this(*this);
308  nnc_this.difference_assign(nnc_y);
309  *this = nnc_this;
310 }
311 
313 template <typename PSET>
314 inline bool
315 check_containment(const PSET& ph, const Pointset_Powerset<PSET>& ps) {
316  // This code is only used when PSET is an abstraction of NNC_Polyhedron.
317  const NNC_Polyhedron ph_nnc = NNC_Polyhedron(ph.constraints());
318  const Pointset_Powerset<NNC_Polyhedron> ps_nnc(ps);
319  return check_containment(ph_nnc, ps_nnc);
320 }
321 
323 template <>
324 inline bool
327  return check_containment(NNC_Polyhedron(ph),
329 }
330 
332 template <typename PSET>
333 inline void
335  x.m_swap(y);
336 }
337 
338 } // namespace Parma_Polyhedra_Library
339 
340 #endif // !defined(PPL_Pointset_Powerset_inlines_hh)
Poly_Con_Relation relation_with(const Constraint &c) const
Returns the relations holding between the powerset *this and the constraint c.
The partially reduced product of two abstractions.
dimension_type max_space_dimension()
Returns the maximum space dimension this library can handle.
A linear equality or inequality.
void swap(CO_Tree &x, CO_Tree &y)
Sequence sequence
The sequence container holding powerset's elements.
size_t dimension_type
An unsigned integral type for representing space dimensions.
static dimension_type max_space_dimension()
Returns the maximum space dimension a Pointset_Powerset can handle.
bool is_empty() const
Returns true if and only if *this is an empty polyhedron.
void swap(Pointset_Powerset< PSET > &x, Pointset_Powerset< PSET > &y)
bool is_empty() const
Returns true if and only if *this is an empty box.
Definition: Box_inlines.hh:183
void time_elapse_assign(const Pointset_Powerset &y)
Assigns to *this the result of computing the time-elapse between *this and y.
bool OK() const
Checks if all the invariants are satisfied.
bool geometrically_equals(const Pointset_Powerset &y) const
Returns true if and only if *this is geometrically equal to y, i.e., if (the elements of) *this and y...
void difference_assign(const Pointset_Powerset &y)
Assigns to *this an (a smallest) over-approximation as a powerset of the disjunct domain of the set-t...
A wrapper for PPL pointsets, providing them with a determinate constraint system interface, as defined in [Bag98].
void m_swap(Pointset_Powerset &y)
Swaps *this with y.
bool is_empty() const
Returns true if and only if *this is an empty BDS.
The powerset construction on a base-level domain.
int32_t hash_code() const
Returns a 32-bit hash code for *this.
Complexity_Class
Complexity pseudo-classes.
bool geometrically_covers(const Pointset_Powerset &y) const
Returns true if and only if *this geometrically covers y, i.e., if any point (in some element) of y i...
bool reduced
If true, *this is Omega-reduced.
Degenerate_Element
Kinds of degenerate abstract elements.
Enable_If< Is_Native< T >::value, memory_size_type >::type external_memory_in_bytes(const T &)
For native types, returns the size in bytes of the memory managed by the type of the (unused) paramet...
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Pointset_Powerset(dimension_type num_dimensions=0, Degenerate_Element kind=UNIVERSE)
Builds a universe (top) or empty (bottom) Pointset_Powerset.
A not necessarily closed convex polyhedron.
A not necessarily closed, iso-oriented hyperrectangle.
Definition: Box_defs.hh:299
A closed convex polyhedron.
int32_t hash_code_from_dimension(dimension_type dim)
Returns the hash code for space dimension dim.
bool check_containment(const PSET &ph, const Pointset_Powerset< PSET > &ps)
The universe element, i.e., the whole vector space.
The powerset construction instantiated on PPL pointset domains.
The entire library is confined to this namespace.
Definition: version.hh:61
bool check_containment(const C_Polyhedron &ph, const Pointset_Powerset< C_Polyhedron > &ps)
void intersection_assign(const Pointset_Powerset &y)
Assigns to *this the intersection of *this and y.
A bounded difference shape.
bool is_empty() const
Returns true if and only if either of the components of *this are empty.
memory_size_type external_memory_in_bytes() const
Returns a lower bound to the size in bytes of the memory managed by *this.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
Coefficient c
Definition: PIP_Tree.cc:64
bool is_empty() const
Returns true if and only if *this is an empty OS.
dimension_type space_dim
The number of dimensions of the enclosing vector space.
memory_size_type total_memory_in_bytes() const
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
Pointset_Powerset & operator=(const Pointset_Powerset &y)
The assignment operator (*this and y can be dimension-incompatible).
void pairwise_apply_assign(const Powerset &y, Binary_Operator_Assign op_assign)
Assigns to *this the result of applying op_assign pairwise to the elements in *this and y...
bool is_empty() const
Returns true if and only if *this is an empty grid.
Definition: Grid_public.cc:742
The relation between a polyhedron and a constraint.