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_defs_hh
00024 #define PPL_Congruence_defs_hh 1
00025
00026 #include "Congruence.types.hh"
00027 #include "Scalar_Products.types.hh"
00028 #include "Row.defs.hh"
00029 #include "Grid.types.hh"
00030 #include "Polyhedron.types.hh"
00031 #include "Variable.defs.hh"
00032 #include "Constraint.types.hh"
00033 #include "Linear_Expression.types.hh"
00034 #include "Linear_Row.types.hh"
00035 #include "Congruence_System.defs.hh"
00036 #include <iosfwd>
00037
00038 namespace Parma_Polyhedra_Library {
00039
00040 namespace IO_Operators {
00041
00043
00045 std::ostream&
00046 operator<<(std::ostream& s, const Congruence& c);
00047
00048
00049
00051 std::ostream&
00052 operator<<(std::ostream& s, const Congruence_System& cgs);
00053
00054
00055 }
00056
00057
00058
00060
00061 bool
00062 operator==(const Congruence& x, const Congruence& y);
00063
00065
00066 bool
00067 operator!=(const Congruence& x, const Congruence& y);
00068
00070
00071 Congruence
00072 operator%=(const Linear_Expression& e1, const Linear_Expression& e2);
00073
00075
00076 Congruence
00077 operator%=(const Linear_Expression& e, Coefficient_traits::const_reference n);
00078
00080
00086 Congruence
00087 operator/(const Congruence& cg, Coefficient_traits::const_reference k);
00088
00090
00091 Congruence
00092 operator/(const Constraint& c, Coefficient_traits::const_reference m);
00093
00094 }
00095
00096 namespace std {
00097
00099
00100 void
00101 swap(Parma_Polyhedra_Library::Congruence& x,
00102 Parma_Polyhedra_Library::Congruence& y);
00103
00104 }
00105
00107
00210 class Parma_Polyhedra_Library::Congruence : private Row {
00211 public:
00213 Congruence(const Congruence& cg);
00214
00216
00220 explicit Congruence(const Constraint& c);
00221
00223 ~Congruence();
00224
00226 Congruence& operator=(const Congruence& cg);
00227
00229 static dimension_type max_space_dimension();
00230
00232 dimension_type space_dimension() const;
00233
00235
00239 Coefficient_traits::const_reference coefficient(Variable v) const;
00240
00242 Coefficient_traits::const_reference inhomogeneous_term() const;
00243
00245 Coefficient_traits::const_reference modulus() const;
00246
00248
00253 Congruence&
00254 operator/=(Coefficient_traits::const_reference k);
00255
00265 bool is_tautological() const;
00266
00277 bool is_inconsistent() const;
00278
00280
00283 bool is_proper_congruence() const;
00284
00286
00289 bool is_equality() const;
00290
00295 bool is_equal_at_dimension(dimension_type dim,
00296 const Congruence& cg) const;
00297
00299 static void initialize();
00300
00302 static void finalize();
00303
00309 static const Congruence& zero_dim_integrality();
00310
00315 static const Congruence& zero_dim_false();
00316
00318 static Congruence
00319 create(const Linear_Expression& e1, const Linear_Expression& e2);
00320
00322 static Congruence
00323 create(const Linear_Expression& e, Coefficient_traits::const_reference n);
00324
00326 static Congruence
00327 create(Coefficient_traits::const_reference n, const Linear_Expression& e);
00328
00333 memory_size_type total_memory_in_bytes() const;
00334
00336 memory_size_type external_memory_in_bytes() const;
00337
00338 PPL_OUTPUT_DECLARATIONS
00339
00340 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00341
00345 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00346 bool ascii_load(std::istream& s);
00347
00349 bool OK() const;
00350
00351 protected:
00352
00354
00359 void sign_normalize();
00360
00362
00366 void normalize();
00367
00369
00373 void strong_normalize();
00374
00375 private:
00380 static const Congruence* zero_dim_false_p;
00381
00387 static const Congruence* zero_dim_integrality_p;
00388
00390 void set_is_equality();
00391
00393 void negate(dimension_type start, dimension_type end);
00394
00396 Congruence();
00397
00399 Congruence(const Congruence& cg,
00400 dimension_type sz,
00401 dimension_type capacity);
00402
00404 Congruence(const Constraint& c,
00405 dimension_type sz,
00406 dimension_type capacity);
00407
00409
00414 Congruence(const Congruence& cg, Coefficient_traits::const_reference k);
00415
00417
00427 Congruence(Linear_Expression& le,
00428 Coefficient_traits::const_reference m);
00429
00431 void swap(Congruence& y);
00432
00437 void
00438 throw_invalid_argument(const char* method, const char* message) const;
00439
00444 void
00445 throw_dimension_incompatible(const char* method,
00446 const char* v_name,
00447 Variable v) const;
00448
00449 friend Congruence
00450 operator/(const Congruence& cg, Coefficient_traits::const_reference k);
00451 friend Congruence
00452 operator/(const Constraint& c, Coefficient_traits::const_reference m);
00453
00454 friend bool
00455 operator==(const Congruence& x, const Congruence& y);
00456
00457 friend bool
00458 operator!=(const Congruence& x, const Congruence& y);
00459
00460 friend std::ostream&
00461 Parma_Polyhedra_Library::IO_Operators
00462 ::operator<<(std::ostream& s,
00463 const Congruence_System& cgs);
00464
00465 friend class Parma_Polyhedra_Library::Scalar_Products;
00466 friend class Parma_Polyhedra_Library::Constraint;
00467 friend class Parma_Polyhedra_Library::Congruence_System;
00468 friend class Parma_Polyhedra_Library::Congruence_System::const_iterator;
00469
00470
00471 friend class Parma_Polyhedra_Library::Grid;
00472 friend class Parma_Polyhedra_Library::Linear_Expression;
00473
00474 friend void
00475 std::swap(Parma_Polyhedra_Library::Congruence& x,
00476 Parma_Polyhedra_Library::Congruence& y);
00477 };
00478
00479 #include "Congruence.inlines.hh"
00480
00481 #endif // !defined(PPL_Congruence_defs_hh)