PPL  1.2
Generator_System_inlines.hh
Go to the documentation of this file.
1 /* Generator_System 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_Generator_System_inlines_hh
25 #define PPL_Generator_System_inlines_hh 1
26 
27 #include "Generator_defs.hh"
28 
29 namespace Parma_Polyhedra_Library {
30 
31 inline
33  : sys(NECESSARILY_CLOSED, r) {
34 }
35 
36 inline
38  : sys(g.topology(), r) {
39  sys.insert(g);
40 }
41 
42 inline
44  : sys(gs.sys) {
45 }
46 
47 inline
50  : sys(gs.sys, r) {
51 }
52 
53 inline
55  : sys(topol, r) {
56 }
57 
58 inline
60  const dimension_type space_dim,
62  : sys(topol, space_dim, r) {
63 }
64 
65 inline
67 }
68 
69 inline Generator_System&
71  Generator_System tmp = y;
72  swap(*this, tmp);
73  return *this;
74 }
75 
76 inline Representation
78  return sys.representation();
79 }
80 
81 inline void
83  sys.set_representation(r);
84 }
85 
86 inline dimension_type
89 }
90 
91 inline dimension_type
93  return sys.space_dimension();
94 }
95 
96 inline void
98  const dimension_type old_space_dim = space_dimension();
99  sys.set_space_dimension_no_ok(space_dim);
100 
101  if (space_dim < old_space_dim) {
102  // We may have invalid lines and rays now.
104  }
105 
106 #ifndef NDEBUG
107  for (dimension_type i = 0; i < sys.num_rows(); ++i) {
108  PPL_ASSERT(sys[i].OK());
109  }
110 #endif
111  PPL_ASSERT(sys.OK());
112  PPL_ASSERT(OK());
113 }
114 
115 inline void
117  sys.clear();
118 }
119 
120 inline const Generator&
122  return sys[k];
123 }
124 
125 inline void
128  sys.remove_space_dimensions(vars);
129 }
130 
131 inline void
134  sys.shift_space_dimensions(v, n);
135 }
136 
137 inline void
139 ::permute_space_dimensions(const std::vector<Variable>& cycle) {
140  sys.permute_space_dimensions(cycle);
141 }
142 
143 inline void
146  sys.swap_space_dimensions(v1, v2);
147 }
148 
149 inline dimension_type
151  return sys.num_rows();
152 }
153 
154 inline void
156  sys.add_universe_rows_and_space_dimensions(n);
157 }
158 
159 inline Topology
161  return sys.topology();
162 }
163 
164 inline dimension_type
166  return sys.first_pending_row();
167 }
168 
169 inline void
171  sys.unset_pending_rows();
172 }
173 
174 inline void
176  sys.set_sorted(b);
177 }
178 
179 inline bool
181  return sys.is_sorted();
182 }
183 
184 inline void
186  sys.set_index_first_pending_row(i);
187 }
188 
189 inline bool
191  return sys.is_necessarily_closed();
192 }
193 
194 inline void
196  sys.assign_with_pending(y.sys);
197 }
198 
199 inline dimension_type
201  return sys.num_pending_rows();
202 }
203 
204 inline void
206  return sys.sort_pending_and_remove_duplicates();
207 }
208 
209 inline void
211  sys.sort_and_remove_with_sat(sat);
212 }
213 
214 inline void
216  sys.sort_rows();
217 }
218 
219 inline bool
221  return sys.check_sorted();
222 }
223 
224 inline dimension_type
226  return sys.num_lines_or_equalities();
227 }
228 
229 inline void
231  sys.remove_row(i, keep_sorted);
232 }
233 
234 inline void
236  bool keep_sorted) {
237  sys.remove_rows(first, last, keep_sorted);
238 }
239 
240 inline void
241 Generator_System::remove_rows(const std::vector<dimension_type>& indexes) {
242  sys.remove_rows(indexes);
243 }
244 
245 inline void
247  sys.remove_trailing_rows(n);
248 }
249 
250 inline dimension_type
251 Generator_System::gauss(dimension_type n_lines_or_equalities) {
252  return sys.gauss(n_lines_or_equalities);
253 }
254 
255 inline void
257  sys.back_substitute(n_lines_or_equalities);
258 }
259 
260 inline void
262  sys.strong_normalize();
263 }
264 
265 inline void
267  sys.merge_rows_assign(y.sys);
268 }
269 
270 inline void
272  sys.insert(y.sys);
273 }
274 
275 inline void
277  sys.insert_pending(r.sys);
278 }
279 
280 inline bool
282  return x.sys == y.sys;
283 }
284 
285 inline bool
287  return !(x == y);
288 }
289 
290 inline
292  : i(), gsp(0) {
293 }
294 
295 inline
297  : i(y.i), gsp(y.gsp) {
298 }
299 
300 inline
302 }
303 
304 inline
307  i = y.i;
308  gsp = y.gsp;
309  return *this;
310 }
311 
312 inline const Generator&
314  return *i;
315 }
316 
317 inline const Generator*
319  return i.operator->();
320 }
321 
324  ++i;
325  if (!gsp->is_necessarily_closed()) {
326  skip_forward();
327  }
328  return *this;
329 }
330 
333  const Generator_System_const_iterator tmp = *this;
334  operator++();
335  return tmp;
336 }
337 
338 inline bool
340  return i == y.i;
341 }
342 
343 inline bool
345  return i != y.i;
346 }
347 
348 inline
351  const Generator_System& gs)
352  : i(iter), gsp(&gs.sys) {
353 }
354 
355 inline bool
357  return sys.has_no_rows();
358 }
359 
360 inline bool
362  return sys.has_no_rows();
363 }
364 
367  const_iterator i(sys.begin(), *this);
368  if (!sys.is_necessarily_closed()) {
369  i.skip_forward();
370  }
371  return i;
372 }
373 
376  const const_iterator i(sys.end(), *this);
377  return i;
378 }
379 
380 inline const Generator_System&
382  PPL_ASSERT(zero_dim_univ_p != 0);
383  return *zero_dim_univ_p;
384 }
385 
386 inline void
388  swap(sys, y.sys);
389 }
390 
391 inline memory_size_type
393  return sys.external_memory_in_bytes();
394 }
395 
396 inline memory_size_type
398  return external_memory_in_bytes() + sizeof(*this);
399 }
400 
401 inline void
403  sys.simplify();
405 }
406 
408 inline void
410  x.m_swap(y);
411 }
412 
413 } // namespace Parma_Polyhedra_Library
414 
415 #endif // !defined(PPL_Generator_System_inlines_hh)
void remove_row(dimension_type i, bool keep_sorted=false)
Makes the system shrink by removing its i-th row.
void simplify()
Applies Gaussian elimination and back-substitution so as to provide a partial simplification of the s...
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
Definition: Box_inlines.hh:264
void merge_rows_assign(const Generator_System &y)
Assigns to *this the result of merging its rows with those of y, obtaining a sorted system...
void sort_and_remove_with_sat(Bit_Matrix &sat)
Sorts the system, removing duplicates, keeping the saturation matrix consistent.
dimension_type first_pending_row() const
Returns the index of the first pending row.
static const Generator_System & zero_dim_univ()
Returns the singleton system containing only Generator::zero_dim_point().
size_t dimension_type
An unsigned integral type for representing space dimensions.
An std::set of variables' indexes.
A line, ray, point or closure point.
void add_universe_rows_and_space_dimensions(dimension_type n)
Adds n rows and space dimensions to the system.
void remove_trailing_rows(dimension_type n)
Makes the system shrink by removing its n trailing rows.
void skip_forward()
*this skips to the next generator, skipping those closure points that are immediately followed by a m...
void remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the generator system.
void shift_space_dimensions(Variable v, dimension_type n)
const Generator * operator->() const
Indirect member selector.
const Generator & operator*() const
Dereference operator.
void permute_space_dimensions(const std::vector< Variable > &cycle)
Permutes the space dimensions of the matrix.
dimension_type gauss(dimension_type n_lines_or_equalities)
Minimizes the subsystem of equations contained in *this.
void assign_with_pending(const Generator_System &y)
Full assignment operator: pending rows are copied as pending.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
const Linear_System< Generator > * gsp
A const pointer to the Linear_System.
bool is_sorted() const
Returns the value of the sortedness flag.
Generator_System_const_iterator & operator=(const Generator_System_const_iterator &y)
Assignment operator.
void set_index_first_pending_row(dimension_type i)
Sets the index of the first pending row to i.
A dimension of the vector space.
void sort_pending_and_remove_duplicates()
Sorts the pending rows and eliminates those that also occur in the non-pending part of the system...
const Generator & operator[](dimension_type k) const
Returns a constant reference to the k- th generator of the system.
bool is_necessarily_closed() const
Returns true if and only if the system topology is NECESSARILY_CLOSED.
void clear()
Removes all the generators from the generator system and sets its space dimension to 0...
void remove_invalid_lines_and_rays()
Removes all the invalid lines and rays.
Representation representation() const
Returns the current representation of *this.
void remove_rows(dimension_type first, dimension_type last, bool keep_sorted=false)
Makes the system shrink by removing the rows in [first,last).
void swap_space_dimensions(Variable v1, Variable v2)
Swaps the coefficients of the variables v1 and v2 .
void insert_pending(const Generator_System &r)
Adds a copy of the rows of `y' to the pending part of `*this'.
Swapping_Vector< Row >::const_iterator const_iterator
Generator_System & operator=(const Generator_System &y)
Assignment operator.
void sort_rows()
Sorts the non-pending rows (in growing order) and eliminates duplicated ones.
void set_representation(Representation r)
Converts *this to the specified representation.
void m_swap(Generator_System &y)
Swaps *this with y.
static const Generator_System * zero_dim_univ_p
Holds (between class initialization and finalization) a pointer to the singleton system containing on...
The entire library is confined to this namespace.
Definition: version.hh:61
Generator_System(Representation r=default_representation)
Default constructor: builds an empty system of generators.
void set_sorted(bool b)
Sets the sortedness flag of the system to b.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
const_iterator end() const
Returns the past-the-end const_iterator.
const_iterator begin() const
Returns the const_iterator pointing to the first generator, if *this is not empty; otherwise...
bool check_sorted() const
Returns true if and only if *this is sorted, without checking for duplicates.
Linear_System< Generator >::const_iterator i
The const iterator over the Linear_System.
void back_substitute(dimension_type n_lines_or_equalities)
Back-substitutes the coefficients to reduce the complexity of the system.
bool operator!=(const Generator_System_const_iterator &y) const
Returns true if and only if *this and y are different.
void set_space_dimension(dimension_type space_dim)
Sets the space dimension of the rows in the system to space_dim .
static dimension_type max_space_dimension()
Returns the maximum space dimension a Linear_System can handle.
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
bool OK() const
Checks if all the invariants are satisfied.
static dimension_type max_space_dimension()
Returns the maximum space dimension a Generator_System can handle.
dimension_type num_pending_rows() const
Returns the number of rows that are in the pending part of the system.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void swap(Generator_System &x, Generator_System &y)
dimension_type num_lines_or_equalities() const
Returns the number of rows in the system that represent either lines or equalities.
void insert(const Generator &g)
Inserts in *this a copy of the generator g, increasing the number of space dimensions if needed...
bool empty() const
Returns true if and only if *this has no generators.
Generator_System_const_iterator & operator++()
Prefix increment operator.
void strong_normalize()
Strongly normalizes the system.
bool operator==(const Generator_System_const_iterator &y) const
Returns true if and only if *this and y are identical.
void unset_pending_rows()
Sets the index to indicate that the system has no pending rows.
Topology
Kinds of polyhedra domains.