00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef PPL_Congruence_System_defs_hh
00024 #define PPL_Congruence_System_defs_hh 1
00025
00026 #include "Congruence_System.types.hh"
00027 #include "Linear_Expression.types.hh"
00028 #include "Constraint.types.hh"
00029 #include "Congruence.types.hh"
00030 #include "Grid_Generator.types.hh"
00031 #include "Matrix.defs.hh"
00032 #include "Grid_Certificate.types.hh"
00033 #include <iosfwd>
00034
00035 namespace Parma_Polyhedra_Library {
00036
00037 namespace IO_Operators {
00038
00040
00045 std::ostream&
00046 operator<<(std::ostream& s, const Congruence_System& cgs);
00047
00048 }
00049
00050
00051
00053
00054 bool
00055 operator==(const Congruence_System& x, const Congruence_System& y);
00056
00057 }
00058
00059
00060 namespace std {
00061
00063
00064 void
00065 swap(Parma_Polyhedra_Library::Congruence_System& x,
00066 Parma_Polyhedra_Library::Congruence_System& y);
00067
00068 }
00069
00071
00127 class Parma_Polyhedra_Library::Congruence_System : private Matrix {
00128 public:
00130 Congruence_System();
00131
00133 explicit Congruence_System(const Congruence& cg);
00134
00143 explicit Congruence_System(const Constraint& c);
00144
00146 explicit Congruence_System(const Constraint_System& cs);
00147
00149 Congruence_System(const Congruence_System& cgs);
00150
00152 ~Congruence_System();
00153
00155 Congruence_System& operator=(const Congruence_System& cgs);
00156
00158 static dimension_type max_space_dimension();
00159
00161 dimension_type space_dimension() const;
00162
00167 bool is_equal_to(const Congruence_System& cgs) const;
00168
00173 bool has_linear_equalities() const;
00174
00176 void clear();
00177
00185 void insert(const Congruence& cg);
00186
00198 void insert(const Constraint& c);
00199
00200
00201
00208 void insert(const Congruence_System& cgs);
00209
00214 void recycling_insert(Congruence_System& cgs);
00215
00217 static const Congruence_System& zero_dim_empty();
00218
00220
00234 class const_iterator
00235 : public std::iterator<std::forward_iterator_tag,
00236 Congruence,
00237 ptrdiff_t,
00238 const Congruence*,
00239 const Congruence&> {
00240 public:
00242 const_iterator();
00243
00245 const_iterator(const const_iterator& y);
00246
00248 ~const_iterator();
00249
00251 const_iterator& operator=(const const_iterator& y);
00252
00254 const Congruence& operator*() const;
00255
00257 const Congruence* operator->() const;
00258
00260 const_iterator& operator++();
00261
00263 const_iterator operator++(int);
00264
00269 bool operator==(const const_iterator& y) const;
00270
00275 bool operator!=(const const_iterator& y) const;
00276
00277 private:
00278 friend class Congruence_System;
00279
00281 Matrix::const_iterator i;
00282
00284 const Matrix* csp;
00285
00287 const_iterator(const Matrix::const_iterator& iter,
00288 const Congruence_System& cgs);
00289
00291 void skip_forward();
00292 };
00293
00299 const_iterator begin() const;
00300
00302 const_iterator end() const;
00303
00305 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00306
00311 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00312 bool OK() const;
00313
00314 PPL_OUTPUT_DECLARATIONS;
00315
00316 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00317
00322 #endif // PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00323 bool ascii_load(std::istream& s);
00324
00326 memory_size_type total_memory_in_bytes() const;
00327
00329 memory_size_type external_memory_in_bytes() const;
00330
00332 dimension_type num_equalities() const;
00333
00335 dimension_type num_proper_congruences() const;
00336
00338 void swap(Congruence_System& cgs);
00339
00354 void add_unit_rows_and_columns(dimension_type dims);
00355
00364 void concatenate(const Congruence_System& cgs);
00365
00366 protected:
00367
00369 bool satisfies_all_congruences(const Grid_Generator& g) const;
00370
00371 private:
00372
00374 void normalize_moduli();
00375
00377
00381 bool increase_space_dimension(const dimension_type new_space_dim);
00382
00390 void insert_verbatim(const Congruence& cg);
00391
00392 friend class const_iterator;
00393
00394 friend class Grid;
00395 friend class Grid_Certificate;
00396
00397 friend void std::swap(Parma_Polyhedra_Library::Congruence_System& x,
00398 Parma_Polyhedra_Library::Congruence_System& y);
00399
00400 friend bool
00401 Parma_Polyhedra_Library::operator==(const Congruence_System& x,
00402 const Congruence_System& y);
00403
00405 Congruence& operator[](dimension_type k);
00406
00408 const Congruence& operator[](dimension_type k) const;
00409
00419 bool has_a_free_dimension() const;
00420
00459 void affine_preimage(dimension_type v,
00460 const Linear_Expression& expr,
00461 Coefficient_traits::const_reference denominator);
00462
00464
00475 void resize_no_copy(dimension_type new_n_rows, dimension_type new_n_columns);
00476 };
00477
00478
00479
00480 #endif // !defined(PPL_Congruence_System_defs_hh)