PPL  1.2
Congruence_System_defs.hh
Go to the documentation of this file.
1 /* Congruence_System class declaration.
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_Congruence_System_defs_hh
25 #define PPL_Congruence_System_defs_hh 1
26 
29 #include "Constraint_types.hh"
30 #include "Congruence_types.hh"
31 #include "Grid_Generator_types.hh"
32 #include "Swapping_Vector_defs.hh"
33 #include "Congruence_defs.hh"
35 #include <iosfwd>
36 #include <cstddef>
37 
38 namespace Parma_Polyhedra_Library {
39 
41 bool
42 operator==(const Congruence_System& x, const Congruence_System& y);
43 
44 }
45 
47 
104 public:
105 
107 
109 
111  explicit Congruence_System(Representation r = default_representation);
112 
115  Representation r = default_representation);
116 
118  explicit Congruence_System(const Congruence& cg,
119  Representation r = default_representation);
120 
129  explicit Congruence_System(const Constraint& c,
130  Representation r = default_representation);
131 
133  explicit Congruence_System(const Constraint_System& cs,
134  Representation r = default_representation);
135 
137 
143 
146 
149 
152 
155 
158 
161 
164 
169  bool is_equal_to(const Congruence_System& y) const;
170 
175  bool has_linear_equalities() const;
176 
178  void clear();
179 
187  void insert(const Congruence& cg);
188 
195  void insert(Congruence& cg, Recycle_Input);
196 
208  void insert(const Constraint& c);
209 
210  // TODO: Consider adding a insert(cg, Recycle_Input).
211 
218  void insert(const Congruence_System& y);
219 
225 
227  static void initialize();
228 
230  static void finalize();
231 
233  static const Congruence_System& zero_dim_empty();
234 
236 
251  : public std::iterator<std::forward_iterator_tag,
252  Congruence,
253  std::ptrdiff_t,
254  const Congruence*,
255  const Congruence&> {
256  public:
258  const_iterator();
259 
261  const_iterator(const const_iterator& y);
262 
264  ~const_iterator();
265 
268 
270  const Congruence& operator*() const;
271 
273  const Congruence* operator->() const;
274 
277 
280 
285  bool operator==(const const_iterator& y) const;
286 
291  bool operator!=(const const_iterator& y) const;
292 
293  private:
294  friend class Congruence_System;
295 
298 
301 
304  const Congruence_System& cgs);
305 
307  void skip_forward();
308  };
309 
311  bool empty() const;
312 
318  const_iterator begin() const;
319 
321  const_iterator end() const;
322 
324 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
325 
330 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
331  bool OK() const;
332 
334 
340  bool ascii_load(std::istream& s);
341 
344 
347 
350 
353 
355  void m_swap(Congruence_System& y);
356 
373 
375 
386  void permute_space_dimensions(const std::vector<Variable>& cycle);
387 
390 
392 
396  bool set_space_dimension(dimension_type new_space_dim);
397 
398  // Note: the following method is protected to allow tests/Grid/congruences2
399  // to call it using a derived class.
400 protected:
402  bool satisfies_all_congruences(const Grid_Generator& g) const;
403 
404 private:
406  dimension_type num_rows() const;
407 
409  bool has_no_rows() const;
410 
412  const Congruence& operator[](dimension_type k) const;
413 
415  void normalize_moduli();
416 
455  void affine_preimage(Variable v,
456  const Linear_Expression& expr,
457  Coefficient_traits::const_reference denominator);
458 
459  // TODO: Consider making this private.
472  void concatenate(const Congruence_System& y);
473 
482 
484 
488  void remove_rows(dimension_type first, dimension_type last,
489  bool keep_sorted);
490 
492 
498 
500 
502 
504 
514  bool has_a_free_dimension() const;
515 
516  friend class Grid;
517 
518  friend bool
519  operator==(const Congruence_System& x, const Congruence_System& y);
520 };
521 
522 namespace Parma_Polyhedra_Library {
523 
524 namespace IO_Operators {
525 
527 
532 std::ostream&
533 operator<<(std::ostream& s, const Congruence_System& cgs);
534 
535 } // namespace IO_Operators
536 
538 void
539 swap(Congruence_System& x, Congruence_System& y);
540 
541 } // namespace Parma_Polyhedra_Library
542 
543 // Congruence_System_inlines.hh is not included here on purpose.
544 
545 #endif // !defined(PPL_Congruence_System_defs_hh)
void swap_space_dimensions(Variable v1, Variable v2)
Swaps the columns having indexes i and j.
A linear equality or inequality.
void swap(CO_Tree &x, CO_Tree &y)
void set_representation(Representation r)
Converts *this to the specified representation.
static dimension_type max_space_dimension()
Returns the maximum space dimension a Congruence_System can handle.
size_t dimension_type
An unsigned integral type for representing space dimensions.
void insert(const Congruence &cg)
Inserts in *this a copy of the congruence cg, increasing the number of space dimensions if needed...
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
const Congruence * operator->() const
Indirect member selector.
bool operator!=(const const_iterator &y) const
Returns true if and only if *this and y are different.
void concatenate(const Congruence_System &y)
Concatenates copies of the congruences from y onto *this.
bool set_space_dimension(dimension_type new_space_dim)
Sets the number of space dimensions to new_space_dim.
std::ostream & operator<<(std::ostream &s, const Ask_Tell< D > &x)
const_iterator end() const
Returns the past-the-end const_iterator.
static const Congruence_System & zero_dim_empty()
Returns the system containing only Congruence::zero_dim_false().
dimension_type num_equalities() const
Returns the number of equalities.
void insert_verbatim(Congruence &cg, Recycle_Input)
Inserts in *this the congruence cg, stealing its contents and increasing the number of space dimensio...
const_iterator & operator=(const const_iterator &y)
Assignment operator.
void normalize_moduli()
Adjusts all expressions to have the same moduli.
const_iterator & operator++()
Prefix increment operator.
A dimension of the vector space.
bool satisfies_all_congruences(const Grid_Generator &g) const
Returns true if g satisfies all the congruences.
const Congruence & operator*() const
Dereference operator.
#define PPL_OUTPUT_DECLARATIONS
static void initialize()
Initializes the class.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
const Swapping_Vector< Congruence > * csp
A const pointer to the vector of congruences.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
const Congruence & operator[](dimension_type k) const
Returns a constant reference to the k- th congruence of the system.
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
Representation representation() const
Returns the current representation of *this.
bool OK() const
Checks if all the invariants are satisfied.
dimension_type num_proper_congruences() const
Returns the number of proper congruences.
const_iterator begin() const
Returns the const_iterator pointing to the first congruence, if this is not empty; otherwise...
bool has_linear_equalities() const
Returns true if and only if *this contains one or more linear equalities.
void affine_preimage(Variable v, const Linear_Expression &expr, Coefficient_traits::const_reference denominator)
Substitutes a given column of coefficients by a given affine expression.
Congruence_System & operator=(const Congruence_System &y)
Assignment operator.
void permute_space_dimensions(const std::vector< Variable > &cycle)
Permutes the space dimensions of the system.
static const Congruence_System * zero_dim_empty_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
dimension_type num_rows() const
Returns the number of rows in the system.
bool empty() const
Returns true if and only if *this has no congruences.
bool has_a_free_dimension() const
Returns true if and only if any of the dimensions in *this is free of constraint. ...
std::vector< T >::const_iterator const_iterator
Sparse representation: only the nonzero coefficient are stored. If there are many nonzero coefficient...
bool is_equal_to(const Congruence_System &y) const
Returns true if and only if *this is exactly equal to y.
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
bool has_no_rows() const
Returns true if num_rows()==0.
Coefficient c
Definition: PIP_Tree.cc:64
Congruence_System(Representation r=default_representation)
Default constructor: builds an empty system of congruences.
Swapping_Vector< Congruence >::const_iterator i
The const iterator over the vector of congruences.
void skip_forward()
*this skips to the next non-trivial congruence.
void m_swap(Congruence_System &y)
Swaps *this with y.
void add_unit_rows_and_space_dimensions(dimension_type dims)
Adds dims rows and dims space dimensions to the matrix, initializing the added rows as in the unit co...
void remove_rows(dimension_type first, dimension_type last, bool keep_sorted)
Makes the system shrink by removing the rows in [first,last).
bool operator==(const const_iterator &y) const
Returns true if and only if *this and y are identical.
A grid line, parameter or grid point.
friend bool operator==(const Congruence_System &x, const Congruence_System &y)
void clear()
Removes all the congruences and sets the space dimension to 0.
static void finalize()
Finalizes the class.