PPL  0.12.1
Congruence_System.defs.hh
Go to the documentation of this file.
00001 /* Congruence_System class declaration.
00002    Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
00003    Copyright (C) 2010-2012 BUGSENG srl (http://bugseng.com)
00004 
00005 This file is part of the Parma Polyhedra Library (PPL).
00006 
00007 The PPL is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 The PPL is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program; if not, write to the Free Software Foundation,
00019 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
00020 
00021 For the most up-to-date information see the Parma Polyhedra Library
00022 site: http://bugseng.com/products/ppl/ . */
00023 
00024 #ifndef PPL_Congruence_System_defs_hh
00025 #define PPL_Congruence_System_defs_hh 1
00026 
00027 #include "Congruence_System.types.hh"
00028 #include "Linear_Expression.types.hh"
00029 #include "Constraint.types.hh"
00030 #include "Congruence.types.hh"
00031 #include "Grid_Generator.types.hh"
00032 #include "Dense_Matrix.defs.hh"
00033 #include "Grid.types.hh"
00034 #include "Grid_Certificate.types.hh"
00035 #include <iosfwd>
00036 
00037 namespace Parma_Polyhedra_Library {
00038 
00039 namespace IO_Operators {
00040 
00042 
00047 std::ostream&
00048 operator<<(std::ostream& s, const Congruence_System& cgs);
00049 
00050 } // namespace IO_Operators
00051 
00053 
00054 void swap(Congruence_System& x, Congruence_System& y);
00055 
00056 } // namespace Parma_Polyhedra_Library
00057 
00059 
00115 class Parma_Polyhedra_Library::Congruence_System : private Dense_Matrix {
00116 public:
00118   Congruence_System();
00119 
00121   explicit Congruence_System(const Congruence& cg);
00122 
00131   explicit Congruence_System(const Constraint& c);
00132 
00134   explicit Congruence_System(const Constraint_System& cs);
00135 
00137   Congruence_System(const Congruence_System& cgs);
00138 
00140   ~Congruence_System();
00141 
00143   Congruence_System& operator=(const Congruence_System& y);
00144 
00146   static dimension_type max_space_dimension();
00147 
00149   dimension_type space_dimension() const;
00150 
00155   bool is_equal_to(const Congruence_System& y) const;
00156 
00161   bool has_linear_equalities() const;
00162 
00164   void clear();
00165 
00173   void insert(const Congruence& cg);
00174 
00186   void insert(const Constraint& c);
00187 
00188   // TODO: Consider adding a recycling_insert(cg).
00189 
00196   void insert(const Congruence_System& y);
00197 
00202   void recycling_insert(Congruence_System& cgs);
00203 
00205   static void initialize();
00206 
00208   static void finalize();
00209 
00211   static const Congruence_System& zero_dim_empty();
00212 
00214 
00228   class const_iterator
00229     : public std::iterator<std::forward_iterator_tag,
00230                            Congruence,
00231                            ptrdiff_t,
00232                            const Congruence*,
00233                            const Congruence&> {
00234   public:
00236     const_iterator();
00237 
00239     const_iterator(const const_iterator& y);
00240 
00242     ~const_iterator();
00243 
00245     const_iterator& operator=(const const_iterator& y);
00246 
00248     const Congruence& operator*() const;
00249 
00251     const Congruence* operator->() const;
00252 
00254     const_iterator& operator++();
00255 
00257     const_iterator operator++(int);
00258 
00263     bool operator==(const const_iterator& y) const;
00264 
00269     bool operator!=(const const_iterator& y) const;
00270 
00271   private:
00272     friend class Congruence_System;
00273 
00275     Dense_Matrix::const_iterator i;
00276 
00278     const Dense_Matrix* csp;
00279 
00281     const_iterator(const Dense_Matrix::const_iterator& iter,
00282                    const Congruence_System& cgs);
00283 
00285     void skip_forward();
00286   };
00287 
00289   bool empty() const;
00290 
00296   const_iterator begin() const;
00297 
00299   const_iterator end() const;
00300 
00302 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00303 
00308 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00309   bool OK() const;
00310 
00311   PPL_OUTPUT_DECLARATIONS
00312 
00318   bool ascii_load(std::istream& s);
00319 
00321   memory_size_type total_memory_in_bytes() const;
00322 
00324   memory_size_type external_memory_in_bytes() const;
00325 
00327   dimension_type num_equalities() const;
00328 
00330   dimension_type num_proper_congruences() const;
00331 
00333   void m_swap(Congruence_System& y);
00334 
00350   void add_unit_rows_and_columns(dimension_type dims);
00351 
00352 protected:
00353 
00355   bool satisfies_all_congruences(const Grid_Generator& g) const;
00356 
00357 private:
00362   static const Congruence_System* zero_dim_empty_p;
00363 
00365   explicit Congruence_System(dimension_type d);
00366 
00379   void concatenate(const Congruence_System& y);
00380 
00382   void normalize_moduli();
00383 
00385 
00389   bool increase_space_dimension(dimension_type new_space_dim);
00390 
00398   void insert_verbatim(const Congruence& cg);
00399 
00400   friend class const_iterator;
00401   friend class Grid;
00402   friend class Grid_Certificate;
00403 
00404   friend bool
00405   operator==(const Congruence_System& x, const Congruence_System& y);
00406 
00408   Congruence& operator[](dimension_type k);
00409 
00411   const Congruence& operator[](dimension_type k) const;
00412 
00422   bool has_a_free_dimension() const;
00423 
00462   void affine_preimage(dimension_type v,
00463                        const Linear_Expression& expr,
00464                        Coefficient_traits::const_reference denominator);
00465 
00473   void remove_higher_space_dimensions(dimension_type new_dimension);
00474 
00476 
00487   void resize_no_copy(dimension_type new_num_rows,
00488                       dimension_type new_num_columns);
00489 };
00490 
00491 // Congruence_System.inlines.hh is not included here on purpose.
00492 
00493 #endif // !defined(PPL_Congruence_System_defs_hh)