00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef PPL_Congruence_defs_hh
00025 #define PPL_Congruence_defs_hh 1
00026
00027 #include "Congruence.types.hh"
00028 #include "Scalar_Products.types.hh"
00029 #include "Row.defs.hh"
00030 #include "Grid.types.hh"
00031 #include "Polyhedron.types.hh"
00032 #include "Variable.defs.hh"
00033 #include "Constraint.types.hh"
00034 #include "Linear_Expression.types.hh"
00035 #include "Linear_Row.types.hh"
00036 #include "Congruence_System.defs.hh"
00037 #include <iosfwd>
00038
00039 namespace Parma_Polyhedra_Library {
00040
00041 namespace IO_Operators {
00042
00044
00046 std::ostream&
00047 operator<<(std::ostream& s, const Congruence& c);
00048
00049
00050
00052 std::ostream&
00053 operator<<(std::ostream& s, const Congruence_System& cgs);
00054
00055
00056 }
00057
00058
00059
00061
00062 bool
00063 operator==(const Congruence& x, const Congruence& y);
00064
00066
00067 bool
00068 operator!=(const Congruence& x, const Congruence& y);
00069
00071
00072 Congruence
00073 operator%=(const Linear_Expression& e1, const Linear_Expression& e2);
00074
00076
00077 Congruence
00078 operator%=(const Linear_Expression& e, Coefficient_traits::const_reference n);
00079
00081
00087 Congruence
00088 operator/(const Congruence& cg, Coefficient_traits::const_reference k);
00089
00091
00092 Congruence
00093 operator/(const Constraint& c, Coefficient_traits::const_reference m);
00094
00095 }
00096
00097 namespace std {
00098
00100
00101 void
00102 swap(Parma_Polyhedra_Library::Congruence& x,
00103 Parma_Polyhedra_Library::Congruence& y);
00104
00105 }
00106
00108
00211 class Parma_Polyhedra_Library::Congruence : private Row {
00212 public:
00214 Congruence(const Congruence& cg);
00215
00217
00221 explicit Congruence(const Constraint& c);
00222
00224 ~Congruence();
00225
00227 Congruence& operator=(const Congruence& cg);
00228
00230 static dimension_type max_space_dimension();
00231
00233 dimension_type space_dimension() const;
00234
00236
00240 Coefficient_traits::const_reference coefficient(Variable v) const;
00241
00243 Coefficient_traits::const_reference inhomogeneous_term() const;
00244
00246 Coefficient_traits::const_reference modulus() const;
00247
00249
00254 Congruence&
00255 operator/=(Coefficient_traits::const_reference k);
00256
00266 bool is_tautological() const;
00267
00278 bool is_inconsistent() const;
00279
00281
00284 bool is_proper_congruence() const;
00285
00287
00290 bool is_equality() const;
00291
00296 bool is_equal_at_dimension(dimension_type dim,
00297 const Congruence& cg) const;
00298
00300 static void initialize();
00301
00303 static void finalize();
00304
00310 static const Congruence& zero_dim_integrality();
00311
00316 static const Congruence& zero_dim_false();
00317
00319 static Congruence
00320 create(const Linear_Expression& e1, const Linear_Expression& e2);
00321
00323 static Congruence
00324 create(const Linear_Expression& e, Coefficient_traits::const_reference n);
00325
00327 static Congruence
00328 create(Coefficient_traits::const_reference n, const Linear_Expression& e);
00329
00334 memory_size_type total_memory_in_bytes() const;
00335
00337 memory_size_type external_memory_in_bytes() const;
00338
00339 PPL_OUTPUT_DECLARATIONS
00340
00345 bool ascii_load(std::istream& s);
00346
00348 bool OK() const;
00349
00350 protected:
00351
00353
00358 void sign_normalize();
00359
00361
00365 void normalize();
00366
00368
00372 void strong_normalize();
00373
00374 private:
00379 static const Congruence* zero_dim_false_p;
00380
00386 static const Congruence* zero_dim_integrality_p;
00387
00389 void set_is_equality();
00390
00392 void negate(dimension_type start, dimension_type end);
00393
00395 Congruence();
00396
00398 Congruence(const Congruence& cg,
00399 dimension_type sz,
00400 dimension_type capacity);
00401
00403 Congruence(const Constraint& c,
00404 dimension_type sz,
00405 dimension_type capacity);
00406
00408
00413 Congruence(const Congruence& cg, Coefficient_traits::const_reference k);
00414
00416
00426 Congruence(Linear_Expression& le,
00427 Coefficient_traits::const_reference m);
00428
00430 void swap(Congruence& y);
00431
00436 void
00437 throw_invalid_argument(const char* method, const char* message) const;
00438
00443 void
00444 throw_dimension_incompatible(const char* method,
00445 const char* v_name,
00446 Variable v) const;
00447
00448 friend Congruence
00449 operator/(const Congruence& cg, Coefficient_traits::const_reference k);
00450 friend Congruence
00451 operator/(const Constraint& c, Coefficient_traits::const_reference m);
00452
00453 friend bool
00454 operator==(const Congruence& x, const Congruence& y);
00455
00456 friend bool
00457 operator!=(const Congruence& x, const Congruence& y);
00458
00459 friend std::ostream&
00460 Parma_Polyhedra_Library::IO_Operators
00461 ::operator<<(std::ostream& s,
00462 const Congruence_System& cgs);
00463
00464 friend class Parma_Polyhedra_Library::Scalar_Products;
00465 friend class Parma_Polyhedra_Library::Constraint;
00466 friend class Parma_Polyhedra_Library::Congruence_System;
00467 friend class Parma_Polyhedra_Library::Congruence_System::const_iterator;
00468
00469
00470 friend class Parma_Polyhedra_Library::Grid;
00471 friend class Parma_Polyhedra_Library::Linear_Expression;
00472
00473 friend void
00474 std::swap(Parma_Polyhedra_Library::Congruence& x,
00475 Parma_Polyhedra_Library::Congruence& y);
00476 };
00477
00478 #include "Congruence.inlines.hh"
00479
00480 #endif // !defined(PPL_Congruence_defs_hh)