24 #include "ppl-config.h"
28 #include "assertions.hh"
37 : expr(c.expression(), c.space_dimension(), r),
41 "constraint c must be an equality.");
48 : expr(c.expression(), new_space_dimension, r),
52 "constraint c must be an equality.");
58 expr.sign_normalize();
71 c = expr.inhomogeneous_term();
78 expr.set_inhomogeneous_term(
c);
87 Coefficient gcd = expr.gcd(0, expr.space_dimension() + 1);
95 if (gcd != 0 && gcd != 1) {
116 Coefficient_traits::const_reference denominator) {
151 const char* message)
const {
152 std::ostringstream s;
153 s <<
"PPL::Congruence::" << method <<
":" << std::endl
155 throw std::invalid_argument(s.str());
162 std::ostringstream s;
163 s <<
"this->space_dimension() == " << space_dimension() <<
", "
165 const std::string str = s.str();
166 throw_invalid_argument(method, str.c_str());
204 s <<
" (mod " << c.
modulus() <<
")";
212 return (inhomogeneous_term() == 0) && expr.all_homogeneous_terms_are_zero();
214 return (inhomogeneous_term() % modulus() == 0) && expr.all_homogeneous_terms_are_zero();
220 return (inhomogeneous_term() != 0) && expr.all_homogeneous_terms_are_zero();
223 return (inhomogeneous_term() % modulus() != 0) && expr.all_homogeneous_terms_are_zero();
229 s <<
" m " << modulus_ << std::endl;
239 if (!(s >> str) || str !=
"m") {
243 if (!(s >> modulus_)) {
256 std::cerr <<
"Congruence has a negative modulus " << modulus() <<
"."
271 PPL_ASSERT(zero_dim_false_p == 0);
275 PPL_ASSERT(zero_dim_integrality_p == 0);
276 zero_dim_integrality_p
282 PPL_ASSERT(zero_dim_false_p != 0);
283 delete zero_dim_false_p;
284 zero_dim_false_p = 0;
286 PPL_ASSERT(zero_dim_integrality_p != 0);
287 delete zero_dim_integrality_p;
288 zero_dim_integrality_p = 0;
A transparent adapter for Linear_Expression objects.
Coefficient_traits::const_reference modulus() const
Returns a const reference to the modulus of *this.
void sign_normalize()
Normalizes the signs.
A linear equality or inequality.
void affine_preimage(Variable v, const Linear_Expression &expr, Coefficient_traits::const_reference denominator)
bool is_equality() const
Returns true if and only if *this is an equality constraint.
size_t dimension_type
An unsigned integral type for representing space dimensions.
Coefficient_traits::const_reference get(dimension_type i) const
Returns the i-th coefficient.
#define PPL_DIRTY_TEMP_COEFFICIENT(id)
Declare a local variable named id, of type Coefficient, and containing an unknown initial value...
bool is_inconsistent() const
Returns true if and only if *this is inconsistent (i.e., an always false congruence).
void strong_normalize()
Calls normalize, then divides out common factors.
static void initialize()
Initializes the class.
std::ostream & operator<<(std::ostream &s, const Ask_Tell< D > &x)
The standard C++ namespace.
expr_type expression() const
Partial read access to the (adapted) internal expression.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void ascii_dump() const
Writes to std::cerr an ASCII representation of *this.
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
bool is_proper_congruence() const
Returns true if the modulus is greater than zero.
A dimension of the vector space.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void normalize()
Normalizes signs and the inhomogeneous term.
static Congruence create(const Linear_Expression &e1, const Linear_Expression &e2, Representation r=default_representation)
Returns the congruence .
bool OK() const
Checks if all the invariants are satisfied.
static const Congruence * zero_dim_false_p
Holds (between class initialization and finalization) a pointer to the false (zero-dimension space) c...
Congruence(Representation r=default_representation)
Constructs the 0 = 0 congruence with space dimension 0 .
void throw_dimension_incompatible(const char *method, const char *v_name, Variable v) const
Throws a std::invalid_argument exception containing the appropriate error message.
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type ascii_load(std::istream &s, T &t)
void throw_invalid_argument(const char *method, const char *message) const
Throws a std::invalid_argument exception containing error message message.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
bool is_tautological() const
Returns true if and only if *this is a tautology (i.e., an always true congruence).
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
static void finalize()
Finalizes the class.
void neg_assign(GMP_Integer &x)
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
#define PPL_OUTPUT_DEFINITIONS(class_name)
The entire library is confined to this namespace.
const_iterator lower_bound(Variable v) const
void gcd_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
base_type::const_iterator const_iterator
The type of const iterators on coefficients.
static const Linear_Expression & zero()
Returns the (zero-dimension space) constant 0.
const_iterator begin() const
Iterator pointing to the first nonzero variable coefficient.
void scale(Coefficient_traits::const_reference factor)
Multiplies all the coefficients, including the modulus, by factor .
static const Congruence * zero_dim_integrality_p
Holds (between class initialization and finalization) a pointer to the true (zero-dimension space) co...