PPL  1.2
Pointset_Ask_Tell_inlines.hh
Go to the documentation of this file.
1 /* Pointset_Ask_Tell 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_Ask_Tell_inlines_hh
25 #define PPL_Pointset_Ask_Tell_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  if (kind == EMPTY) {
58  pair_insert(Determinate<PSET>(PSET(num_dimensions, UNIVERSE)),
59  Determinate<PSET>(PSET(num_dimensions, EMPTY)));
60  }
61  PPL_ASSERT_HEAVY(OK());
62 }
63 
64 template <typename PSET>
65 inline
67  : Base(y), space_dim(y.space_dim) {
68 }
69 
70 template <typename PSET>
71 inline
73  : Base(ph), space_dim(ph.space_dimension()) {
74 }
75 
76 template <typename PSET>
77 inline
79  : Base(Determinate<PSET>(cs)), space_dim(cs.space_dimension()) {
80  PPL_ASSERT_HEAVY(OK());
81 }
82 
83 template <typename PSET>
84 inline
86  : Base(Determinate<PSET>(cgs)), space_dim(cgs.space_dimension()) {
87  PPL_ASSERT_HEAVY(OK());
88 }
89 
90 template <typename PSET>
93  Pointset_Ask_Tell& x = *this;
94  x.Base::operator=(y);
95  x.space_dim = y.space_dim;
96  return x;
97 }
98 
99 template <typename PSET>
100 inline void
102  Pointset_Ask_Tell& x = *this;
103  x.Base::m_swap(y);
104  using std::swap;
105  swap(x.space_dim, y.space_dim);
106 }
107 
108 template <typename PSET>
109 template <typename QH>
112  Pointset_Ask_Tell& x = *this;
114  swap(x, pps);
115  return x;
116 }
117 
118 template <typename PSET>
119 inline void
121  Pointset_Ask_Tell& x = *this;
122  x.pairwise_apply_assign
123  (y,
124  Det_PSET::lift_op_assign(std::mem_fun_ref(&PSET::intersection_assign)));
125 }
126 
127 template <typename PSET>
128 inline void
130  Pointset_Ask_Tell& x = *this;
131  x.pairwise_apply_assign
132  (y,
133  Det_PSET::lift_op_assign(std::mem_fun_ref(&PSET::time_elapse_assign)));
134 }
135 
136 template <typename PSET>
137 inline bool
140  const Pointset_Ask_Tell<NNC_Polyhedron> xx(*this);
142  return xx.geometrically_covers(yy);
143 }
144 
145 template <typename PSET>
146 inline bool
149  const Pointset_Ask_Tell<NNC_Polyhedron> xx(*this);
151  return xx.geometrically_covers(yy) && yy.geometrically_covers(xx);
152 }
153 
154 template <>
155 inline bool
158  const Pointset_Ask_Tell& x = *this;
159  return x.geometrically_covers(y) && y.geometrically_covers(x);
160 }
161 
162 template <typename PSET>
163 inline memory_size_type
166 }
167 
168 template <typename PSET>
169 inline memory_size_type
171  return sizeof(*this) + external_memory_in_bytes();
172 }
173 
174 template <typename PSET>
175 inline int32_t
177  return hash_code_from_dimension(space_dimension());
178 }
179 
180 template <>
181 inline void
184  Pointset_Ask_Tell<NNC_Polyhedron> nnc_this(*this);
186  nnc_this.poly_difference_assign(nnc_y);
187  *this = nnc_this;
188 }
189 
191 template <typename PSET>
192 inline bool
193 check_containment(const PSET& ph, const Pointset_Ask_Tell<PSET>& ps) {
194  const NNC_Polyhedron pph = NNC_Polyhedron(ph.constraints());
195  const Pointset_Ask_Tell<NNC_Polyhedron> pps(ps);
196  return check_containment(pph, pps);
197 }
198 
200 template <>
201 inline bool
204  return check_containment(NNC_Polyhedron(ph),
206 }
207 
209 template <typename PSET>
210 inline void
212  x.m_swap(y);
213 }
214 
215 } // namespace Parma_Polyhedra_Library
216 
217 #endif // !defined(PPL_Pointset_Ask_Tell_inlines_hh)
void time_elapse_assign(const Pointset_Ask_Tell &y)
Assigns to *this the result of computing the time-elapse between *this and y.
The empty element, i.e., the empty set.
dimension_type max_space_dimension()
Returns the maximum space dimension this library can handle.
void swap(CO_Tree &x, CO_Tree &y)
void swap(Pointset_Ask_Tell< PSET > &x, Pointset_Ask_Tell< PSET > &y)
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
bool check_containment(const PSET &ph, const Pointset_Ask_Tell< PSET > &ps)
Pointset_Ask_Tell(dimension_type num_dimensions=0, Degenerate_Element kind=UNIVERSE)
Builds a universe (top) or empty (bottom) Pointset_Ask_Tell.
void intersection_assign(const Pointset_Ask_Tell &y)
Assigns to *this the intersection of *this and y.
memory_size_type total_memory_in_bytes() const
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
memory_size_type external_memory_in_bytes() const
Returns a lower bound to the size in bytes of the memory managed by *this.
A wrapper for PPL pointsets, providing them with a determinate constraint system interface, as defined in [Bag98].
bool geometrically_covers(const Pointset_Ask_Tell &y) const
Returns true if and only if *this geometrically covers y, i.e., if any point (in some element) of y i...
static dimension_type max_space_dimension()
Returns the maximum space dimension a Pointset_Ask_Tell can handle.
Degenerate_Element
Kinds of degenerate abstract elements.
The ask-and-tell construction instantiated on PPL polyhedra.
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...
A not necessarily closed convex polyhedron.
A closed convex polyhedron.
int32_t hash_code_from_dimension(dimension_type dim)
Returns the hash code for space dimension dim.
bool OK() const
Checks if all the invariants are satisfied.
dimension_type space_dim
The number of dimensions of the enclosing vector space.
The universe element, i.e., the whole vector space.
void m_swap(Pointset_Ask_Tell &y)
Swaps *this with y.
The entire library is confined to this namespace.
Definition: version.hh:61
Pointset_Ask_Tell & operator=(const Pointset_Ask_Tell &y)
The assignment operator (*this and y can be dimension-incompatible).
int32_t hash_code() const
Returns a 32-bit hash code for *this.
bool check_containment(const C_Polyhedron &ph, const Pointset_Ask_Tell< C_Polyhedron > &ps)
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void pair_insert(const Parma_Polyhedra_Library::Determinate< PSET > &a, const Parma_Polyhedra_Library::Determinate< PSET > &t)
The ask and tell construction on a base-level domain.
bool geometrically_equals(const Pointset_Ask_Tell &y) const
Returns true if and only if *this is geometrically equal to y, i.e., if (the elements of) *this and y...
void poly_difference_assign(const Pointset_Ask_Tell &y)
Assigns to *this the difference of *this and y.