PPL  1.2
Parma_Polyhedra_Library::Congruence Class Reference

A linear congruence. More...

#include <Congruence_defs.hh>

Collaboration diagram for Parma_Polyhedra_Library::Congruence:

Public Types

typedef Expression_Adapter_Transparent< Linear_Expressionexpr_type
 The type of the (adapted) internal expression. More...
 

Public Member Functions

 Congruence (Representation r=default_representation)
 Constructs the 0 = 0 congruence with space dimension 0 . More...
 
 Congruence (const Congruence &cg)
 Ordinary copy constructor. More...
 
 Congruence (const Congruence &cg, Representation r)
 Copy constructor with specified representation. More...
 
 Congruence (const Constraint &c, Representation r=default_representation)
 Copy-constructs (modulo 0) from equality constraint c. More...
 
 ~Congruence ()
 Destructor. More...
 
Congruenceoperator= (const Congruence &y)
 Assignment operator. More...
 
Representation representation () const
 Returns the current representation of *this. More...
 
void set_representation (Representation r)
 Converts *this to the specified representation. More...
 
dimension_type space_dimension () const
 Returns the dimension of the vector space enclosing *this. More...
 
void permute_space_dimensions (const std::vector< Variable > &cycles)
 
expr_type expression () const
 Partial read access to the (adapted) internal expression. More...
 
Coefficient_traits::const_reference coefficient (Variable v) const
 Returns the coefficient of v in *this. More...
 
Coefficient_traits::const_reference inhomogeneous_term () const
 Returns the inhomogeneous term of *this. More...
 
Coefficient_traits::const_reference modulus () const
 Returns a const reference to the modulus of *this. More...
 
void set_modulus (Coefficient_traits::const_reference m)
 
void scale (Coefficient_traits::const_reference factor)
 Multiplies all the coefficients, including the modulus, by factor . More...
 
void affine_preimage (Variable v, const Linear_Expression &expr, Coefficient_traits::const_reference denominator)
 
Congruenceoperator/= (Coefficient_traits::const_reference k)
 Multiplies k into the modulus of *this. More...
 
bool is_tautological () const
 Returns true if and only if *this is a tautology (i.e., an always true congruence). More...
 
bool is_inconsistent () const
 Returns true if and only if *this is inconsistent (i.e., an always false congruence). More...
 
bool is_proper_congruence () const
 Returns true if the modulus is greater than zero. More...
 
bool is_equality () const
 Returns true if *this is an equality. More...
 
memory_size_type total_memory_in_bytes () const
 Returns a lower bound to the total size in bytes of the memory occupied by *this. More...
 
memory_size_type external_memory_in_bytes () const
 Returns the size in bytes of the memory managed by *this. More...
 
bool OK () const
 Checks if all the invariants are satisfied. More...
 
void ascii_dump () const
 Writes to std::cerr an ASCII representation of *this. More...
 
void ascii_dump (std::ostream &s) const
 Writes to s an ASCII representation of *this. More...
 
void print () const
 Prints *this to std::cerr using operator<<. More...
 
bool ascii_load (std::istream &s)
 Loads from s an ASCII representation of the internal representation of *this. More...
 
void m_swap (Congruence &y)
 Swaps *this with y. More...
 
 Congruence (const Congruence &cg, dimension_type new_space_dimension)
 Copy-constructs with the specified space dimension. More...
 
 Congruence (const Congruence &cg, dimension_type new_space_dimension, Representation r)
 Copy-constructs with the specified space dimension and representation. More...
 
 Congruence (const Constraint &cg, dimension_type new_space_dimension, Representation r=default_representation)
 
 Congruence (Linear_Expression &le, Coefficient_traits::const_reference m, Recycle_Input)
 Constructs from Linear_Expression le, using modulus m. More...
 
void swap_space_dimensions (Variable v1, Variable v2)
 Swaps the coefficients of the variables v1 and v2 . More...
 
void set_space_dimension (dimension_type n)
 
void shift_space_dimensions (Variable v, dimension_type n)
 
void sign_normalize ()
 Normalizes the signs. More...
 
void normalize ()
 Normalizes signs and the inhomogeneous term. More...
 
void strong_normalize ()
 Calls normalize, then divides out common factors. More...
 

Static Public Member Functions

static dimension_type max_space_dimension ()
 Returns the maximum space dimension a Congruence can handle. More...
 
static void initialize ()
 Initializes the class. More...
 
static void finalize ()
 Finalizes the class. More...
 
static const Congruencezero_dim_integrality ()
 Returns a reference to the true (zero-dimension space) congruence $0 = 1 \pmod{1}$, also known as the integrality congruence. More...
 
static const Congruencezero_dim_false ()
 Returns a reference to the false (zero-dimension space) congruence $0 = 1 \pmod{0}$. More...
 
static Congruence create (const Linear_Expression &e1, const Linear_Expression &e2, Representation r=default_representation)
 Returns the congruence $e1 = e2 \pmod{1}$. More...
 
static Congruence create (const Linear_Expression &e, Coefficient_traits::const_reference n, Representation r=default_representation)
 Returns the congruence $e = n \pmod{1}$. More...
 
static Congruence create (Coefficient_traits::const_reference n, const Linear_Expression &e, Representation r=default_representation)
 Returns the congruence $n = e \pmod{1}$. More...
 

Static Public Attributes

static const Representation default_representation = SPARSE
 The representation used for new Congruences. More...
 

Private Member Functions

bool is_equal_at_dimension (Variable v, const Congruence &cg) const
 Returns true if *this is equal to cg in dimension v. More...
 
void throw_invalid_argument (const char *method, const char *message) const
 Throws a std::invalid_argument exception containing error message message. More...
 
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. More...
 

Private Attributes

Linear_Expression expr
 
Coefficient modulus_
 

Static Private Attributes

static const Congruencezero_dim_false_p = 0
 Holds (between class initialization and finalization) a pointer to the false (zero-dimension space) congruence $0 = 1 \pmod{0}$. More...
 
static const Congruencezero_dim_integrality_p = 0
 Holds (between class initialization and finalization) a pointer to the true (zero-dimension space) congruence $0 = 1 \pmod{1}$, also known as the integrality congruence. More...
 

Friends

class Scalar_Products
 
class Grid
 
bool operator== (const Congruence &x, const Congruence &y)
 
bool operator!= (const Congruence &x, const Congruence &y)
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &s, const Congruence &c)
 
bool operator== (const Congruence &x, const Congruence &y)
 Returns true if and only if x and y are equivalent. More...
 
bool operator!= (const Congruence &x, const Congruence &y)
 Returns false if and only if x and y are equivalent. More...
 
std::ostream & operator<< (std::ostream &s, const Congruence &c)
 Output operators. More...
 
Congruence operator%= (const Linear_Expression &e1, const Linear_Expression &e2)
 Returns the congruence $e1 = e2 \pmod{1}$. More...
 
Congruence operator%= (const Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the congruence $e = n \pmod{1}$. More...
 
Congruence operator/ (const Congruence &cg, Coefficient_traits::const_reference k)
 Returns a copy of cg, multiplying k into the copy's modulus. More...
 
Congruence operator/ (const Constraint &c, Coefficient_traits::const_reference m)
 Creates a congruence from c, with m as the modulus. More...
 
void swap (Congruence &x, Congruence &y)
 
Congruence operator%= (const Linear_Expression &e1, const Linear_Expression &e2)
 
Congruence operator%= (const Linear_Expression &e, Coefficient_traits::const_reference n)
 
Congruence operator/ (const Congruence &cg, Coefficient_traits::const_reference k)
 
Congruence operator/ (const Constraint &c, Coefficient_traits::const_reference m)
 
bool operator== (const Congruence &x, const Congruence &y)
 
bool operator!= (const Congruence &x, const Congruence &y)
 
void swap (Congruence &x, Congruence &y)
 

Detailed Description

A linear congruence.

An object of the class Congruence is a congruence:

  • $\cg = \sum_{i=0}^{n-1} a_i x_i + b = 0 \pmod m$

where $n$ is the dimension of the space, $a_i$ is the integer coefficient of variable $x_i$, $b$ is the integer inhomogeneous term and $m$ is the integer modulus; if $m = 0$, then $\cg$ represents the equality congruence $\sum_{i=0}^{n-1} a_i x_i + b = 0$ and, if $m \neq 0$, then the congruence $\cg$ is said to be a proper congruence.

How to build a congruence
Congruences $\pmod{1}$ are typically built by applying the congruence symbol `%=' to a pair of linear expressions. Congruences with modulus m are typically constructed by building a congruence $\pmod{1}$ using the given pair of linear expressions and then adding the modulus m using the modulus symbol is `/'.

The space dimension of a congruence is defined as the maximum space dimension of the arguments of its constructor.

In the following examples it is assumed that variables x, y and z are defined as follows:
Variable x(0);
Variable y(1);
Variable z(2);
Example 1
The following code builds the equality congruence $3x + 5y - z = 0$, having space dimension $3$:
Congruence eq_cg((3*x + 5*y - z %= 0) / 0);
The following code builds the congruence $4x = 2y - 13 \pmod{1}$, having space dimension $2$:
Congruence mod1_cg(4*x %= 2*y - 13);
The following code builds the congruence $4x = 2y - 13 \pmod{2}$, having space dimension $2$:
Congruence mod2_cg((4*x %= 2*y - 13) / 2);
An unsatisfiable congruence on the zero-dimension space $\Rset^0$ can be specified as follows: Equivalent, but more involved ways are the following:
Congruence false_cg1((Linear_Expression::zero() %= 1) / 0);
Congruence false_cg2((Linear_Expression::zero() %= 1) / 2);
In contrast, the following code defines an unsatisfiable congruence having space dimension $3$:
Congruence false_cg3((0*z %= 1) / 0);
How to inspect a congruence
Several methods are provided to examine a congruence and extract all the encoded information: its space dimension, its modulus and the value of its integer coefficients.
Example 2
The following code shows how it is possible to access the modulus as well as each of the coefficients. Given a congruence with linear expression e and modulus m (in this case $x - 5y + 3z = 4 \pmod{5}$), we construct a new congruence with the same modulus m but where the linear expression is $2 e$ ( $2x - 10y + 6z = 8 \pmod{5}$).
Congruence cg1((x - 5*y + 3*z %= 4) / 5);
cout << "Congruence cg1: " << cg1 << endl;
const Coefficient& m = cg1.modulus();
if (m == 0)
cout << "Congruence cg1 is an equality." << endl;
else {
Linear_Expression e;
for (dimension_type i = cg1.space_dimension(); i-- > 0; )
e += 2 * cg1.coefficient(Variable(i)) * Variable(i);
e += 2 * cg1.inhomogeneous_term();
Congruence cg2((e %= 0) / m);
cout << "Congruence cg2: " << cg2 << endl;
}
The actual output could be the following:
Congruence cg1: A - 5*B + 3*C %= 4 / 5
Congruence cg2: 2*A - 10*B + 6*C %= 8 / 5
Note that, in general, the particular output obtained can be syntactically different from the (semantically equivalent) congruence considered.

Definition at line 161 of file Congruence_defs.hh.

Member Typedef Documentation

The type of the (adapted) internal expression.

Definition at line 214 of file Congruence_defs.hh.

Constructor & Destructor Documentation

Parma_Polyhedra_Library::Congruence::Congruence ( Representation  r = default_representation)
inlineexplicit

Constructs the 0 = 0 congruence with space dimension 0 .

Definition at line 32 of file Congruence_inlines.hh.

References OK().

33  : expr(r) {
34  PPL_ASSERT(OK());
35 }
bool OK() const
Checks if all the invariants are satisfied.
Definition: Congruence.cc:252
Parma_Polyhedra_Library::Congruence::Congruence ( const Congruence cg)
inline

Ordinary copy constructor.

Note
The new Congruence will have the same representation as `cg', not default_representation, so that they are indistinguishable.

Definition at line 38 of file Congruence_inlines.hh.

39  : expr(cg.expr), modulus_(cg.modulus_) {
40 }
Parma_Polyhedra_Library::Congruence::Congruence ( const Congruence cg,
Representation  r 
)
inline

Copy constructor with specified representation.

Definition at line 43 of file Congruence_inlines.hh.

44  : expr(cg.expr, r), modulus_(cg.modulus_) {
45 }
Parma_Polyhedra_Library::Congruence::Congruence ( const Constraint c,
Representation  r = default_representation 
)
explicit

Copy-constructs (modulo 0) from equality constraint c.

Exceptions
std::invalid_argumentThrown if c is an inequality.

Definition at line 36 of file Congruence.cc.

References Parma_Polyhedra_Library::Constraint::is_equality(), and throw_invalid_argument().

37  : expr(c.expression(), c.space_dimension(), r),
38  modulus_(0) {
39  if (!c.is_equality()) {
40  throw_invalid_argument("Congruence(c, r)",
41  "constraint c must be an equality.");
42  }
43 }
void throw_invalid_argument(const char *method, const char *message) const
Throws a std::invalid_argument exception containing error message message.
Definition: Congruence.cc:150
Coefficient c
Definition: PIP_Tree.cc:64
Parma_Polyhedra_Library::Congruence::~Congruence ( )
inline

Destructor.

Definition at line 89 of file Congruence_inlines.hh.

89  {
90 }
Parma_Polyhedra_Library::Congruence::Congruence ( const Congruence cg,
dimension_type  new_space_dimension 
)
inline

Copy-constructs with the specified space dimension.

Note
The new Congruence will have the same representation as `cg', not default_representation, for consistency with the copy constructor.

Definition at line 48 of file Congruence_inlines.hh.

References OK().

50  : expr(cg.expr, new_space_dimension), modulus_(cg.modulus_) {
51  PPL_ASSERT(OK());
52 }
bool OK() const
Checks if all the invariants are satisfied.
Definition: Congruence.cc:252
Parma_Polyhedra_Library::Congruence::Congruence ( const Congruence cg,
dimension_type  new_space_dimension,
Representation  r 
)
inline

Copy-constructs with the specified space dimension and representation.

Definition at line 55 of file Congruence_inlines.hh.

References OK().

58  : expr(cg.expr, new_space_dimension, r), modulus_(cg.modulus_) {
59  PPL_ASSERT(OK());
60 }
bool OK() const
Checks if all the invariants are satisfied.
Definition: Congruence.cc:252
Parma_Polyhedra_Library::Congruence::Congruence ( const Constraint cg,
dimension_type  new_space_dimension,
Representation  r = default_representation 
)

Copy-constructs from a constraint, with the specified space dimension and (optional) representation.

Definition at line 45 of file Congruence.cc.

References Parma_Polyhedra_Library::Constraint::is_equality(), and throw_invalid_argument().

48  : expr(c.expression(), new_space_dimension, r),
49  modulus_(0) {
50  if (!c.is_equality()) {
51  throw_invalid_argument("Congruence(c, space_dim, r)",
52  "constraint c must be an equality.");
53  }
54 }
void throw_invalid_argument(const char *method, const char *message) const
Throws a std::invalid_argument exception containing error message message.
Definition: Congruence.cc:150
Coefficient c
Definition: PIP_Tree.cc:64
Parma_Polyhedra_Library::Congruence::Congruence ( Linear_Expression le,
Coefficient_traits::const_reference  m,
Recycle_Input   
)
inline

Constructs from Linear_Expression le, using modulus m.

Builds a congruence with modulus m, stealing the coefficients from le.

Note
The new Congruence will have the same representation as `le'.
Parameters
leThe Linear_Expression holding the coefficients.
mThe modulus for the congruence, which must be zero or greater.

Definition at line 93 of file Congruence_inlines.hh.

References expr, OK(), and swap().

96  : modulus_(m) {
97  PPL_ASSERT(m >= 0);
98  swap(expr, le);
99 
100  PPL_ASSERT(OK());
101 }
bool OK() const
Checks if all the invariants are satisfied.
Definition: Congruence.cc:252
void swap(Congruence &x, Congruence &y)
bool le(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)

Member Function Documentation

void Parma_Polyhedra_Library::Congruence::affine_preimage ( Variable  v,
const Linear_Expression expr,
Coefficient_traits::const_reference  denominator 
)

Definition at line 115 of file Congruence.cc.

References c, Parma_Polyhedra_Library::Coefficient_zero(), Parma_Polyhedra_Library::Linear_Expression::get(), PPL_DIRTY_TEMP_COEFFICIENT, Parma_Polyhedra_Library::Variable::space_dimension(), and Parma_Polyhedra_Library::Linear_Expression::space_dimension().

116  {
118  c = expr.get(v);
119 
120  if (c == 0) {
121  return;
122  }
123 
124  scale(denominator);
125 
126  expr.linear_combine(e, 1, c, 0, e.space_dimension() + 1);
127 
128  if (v.space_dimension() > e.space_dimension() || e.get(v) == 0) {
129  // Not invertible
130  expr.set(v, Coefficient_zero());
131  }
132  else {
133  c *= e.get(v);
134  expr.set(v, c);
135  }
136 }
void set(dimension_type i, Coefficient_traits::const_reference n)
Sets the i-th coefficient to n.
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...
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
Coefficient c
Definition: PIP_Tree.cc:64
void linear_combine(const Linear_Expression &y, Variable v)
void scale(Coefficient_traits::const_reference factor)
Multiplies all the coefficients, including the modulus, by factor .
Definition: Congruence.cc:103
void Parma_Polyhedra_Library::Congruence::ascii_dump ( ) const

Writes to std::cerr an ASCII representation of *this.

void Parma_Polyhedra_Library::Congruence::ascii_dump ( std::ostream &  s) const

Writes to s an ASCII representation of *this.

Definition at line 227 of file Congruence.cc.

227  {
228  expr.ascii_dump(s);
229  s << " m " << modulus_ << std::endl;
230 }
void ascii_dump() const
Writes to std::cerr an ASCII representation of *this.
bool Parma_Polyhedra_Library::Congruence::ascii_load ( std::istream &  s)

Loads from s an ASCII representation of the internal representation of *this.

Definition at line 235 of file Congruence.cc.

Referenced by Parma_Polyhedra_Library::Congruence_System::ascii_load().

235  {
236  expr.ascii_load(s);
237 
238  std::string str;
239  if (!(s >> str) || str != "m") {
240  return false;
241  }
242 
243  if (!(s >> modulus_)) {
244  return false;
245  }
246 
247  PPL_ASSERT(OK());
248  return true;
249 }
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
bool OK() const
Checks if all the invariants are satisfied.
Definition: Congruence.cc:252
Coefficient_traits::const_reference Parma_Polyhedra_Library::Congruence::coefficient ( Variable  v) const
inline

Returns the coefficient of v in *this.

Exceptions
std::invalid_argumentthrown if the index of v is greater than or equal to the space dimension of *this.

Definition at line 210 of file Congruence_inlines.hh.

References Parma_Polyhedra_Library::Linear_Expression::coefficient(), expr, Parma_Polyhedra_Library::Variable::space_dimension(), space_dimension(), and throw_dimension_incompatible().

Referenced by Parma_Polyhedra_Library::Box< ITV >::add_congruence_no_check(), Parma_Polyhedra_Library::Grid::expand_space_dimension(), and is_equal_at_dimension().

210  {
211  if (v.space_dimension() > space_dimension()) {
212  throw_dimension_incompatible("coefficient(v)", "v", v);
213  }
214  return expr.coefficient(v);
215 }
Coefficient_traits::const_reference coefficient(Variable v) const
Returns the coefficient of v in *this.
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.
Definition: Congruence.cc:159
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
PPL::Congruence Parma_Polyhedra_Library::Congruence::create ( const Linear_Expression e1,
const Linear_Expression e2,
Representation  r = default_representation 
)
static

Returns the congruence $e1 = e2 \pmod{1}$.

Definition at line 139 of file Congruence.cc.

References Parma_Polyhedra_Library::Linear_Expression::space_dimension().

Referenced by operator%=().

141  {
142  Linear_Expression e(e1,
143  std::max(e1.space_dimension(), e2.space_dimension()),
144  r);
145  e -= e2;
146  return Congruence(e, 1, Recycle_Input());
147 }
Congruence(Representation r=default_representation)
Constructs the 0 = 0 congruence with space dimension 0 .
Congruence Parma_Polyhedra_Library::Congruence::create ( const Linear_Expression e,
Coefficient_traits::const_reference  n,
Representation  r = default_representation 
)
inlinestatic

Returns the congruence $e = n \pmod{1}$.

Definition at line 104 of file Congruence_inlines.hh.

106  {
107  Linear_Expression diff(e, r);
108  diff -= n;
109  const Congruence cg(diff, 1, Recycle_Input());
110  return cg;
111 }
Congruence(Representation r=default_representation)
Constructs the 0 = 0 congruence with space dimension 0 .
Congruence Parma_Polyhedra_Library::Congruence::create ( Coefficient_traits::const_reference  n,
const Linear_Expression e,
Representation  r = default_representation 
)
inlinestatic

Returns the congruence $n = e \pmod{1}$.

Definition at line 114 of file Congruence_inlines.hh.

116  {
117  Linear_Expression diff(e, r);
118  diff -= n;
119  const Congruence cg(diff, 1, Recycle_Input());
120  return cg;
121 }
Congruence(Representation r=default_representation)
Constructs the 0 = 0 congruence with space dimension 0 .
memory_size_type Parma_Polyhedra_Library::Congruence::external_memory_in_bytes ( ) const
inline

Returns the size in bytes of the memory managed by *this.

Definition at line 255 of file Congruence_inlines.hh.

References expr, Parma_Polyhedra_Library::external_memory_in_bytes(), Parma_Polyhedra_Library::Linear_Expression::external_memory_in_bytes(), and modulus_.

Referenced by total_memory_in_bytes().

255  {
258 }
Enable_If< Is_Native< T >::value, memory_size_type >::type external_memory_in_bytes(const T &)
For native types, returns the size in bytes of the memory managed by the type of the (unused) paramet...
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
void Parma_Polyhedra_Library::Congruence::finalize ( )
static

Finalizes the class.

Definition at line 281 of file Congruence.cc.

Referenced by Parma_Polyhedra_Library::Init::~Init().

281  {
282  PPL_ASSERT(zero_dim_false_p != 0);
283  delete zero_dim_false_p;
284  zero_dim_false_p = 0;
285 
286  PPL_ASSERT(zero_dim_integrality_p != 0);
287  delete zero_dim_integrality_p;
289 }
static const Congruence * zero_dim_false_p
Holds (between class initialization and finalization) a pointer to the false (zero-dimension space) c...
static const Congruence * zero_dim_integrality_p
Holds (between class initialization and finalization) a pointer to the true (zero-dimension space) co...
Coefficient_traits::const_reference Parma_Polyhedra_Library::Congruence::inhomogeneous_term ( ) const
inline
void Parma_Polyhedra_Library::Congruence::initialize ( )
static

Initializes the class.

Definition at line 270 of file Congruence.cc.

References Parma_Polyhedra_Library::Linear_Expression::zero().

Referenced by Parma_Polyhedra_Library::Init::Init().

270  {
271  PPL_ASSERT(zero_dim_false_p == 0);
273  = new Congruence((Linear_Expression::zero() %= Coefficient(-1)) / 0);
274 
275  PPL_ASSERT(zero_dim_integrality_p == 0);
278 }
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 .
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
static const Linear_Expression & zero()
Returns the (zero-dimension space) constant 0.
static const Congruence * zero_dim_integrality_p
Holds (between class initialization and finalization) a pointer to the true (zero-dimension space) co...
bool Parma_Polyhedra_Library::Congruence::is_equal_at_dimension ( Variable  v,
const Congruence cg 
) const
inlineprivate

Returns true if *this is equal to cg in dimension v.

Definition at line 249 of file Congruence_inlines.hh.

References coefficient(), and modulus().

Referenced by Parma_Polyhedra_Library::Grid::select_wider_congruences().

250  {
251  return coefficient(v) * cg.modulus() == cg.coefficient(v) * modulus();
252 }
Coefficient_traits::const_reference modulus() const
Returns a const reference to the modulus of *this.
Coefficient_traits::const_reference coefficient(Variable v) const
Returns the coefficient of v in *this.
bool Parma_Polyhedra_Library::Congruence::is_equality ( ) const
inline

Returns true if *this is an equality.

A modulus of zero denotes a linear equality.

Definition at line 244 of file Congruence_inlines.hh.

References modulus().

Referenced by Parma_Polyhedra_Library::Polyhedron::add_congruence(), Parma_Polyhedra_Library::BD_Shape< T >::add_congruence(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_congruence(), Parma_Polyhedra_Library::Box< ITV >::add_congruence_no_check(), Parma_Polyhedra_Library::Polyhedron::add_congruences(), Parma_Polyhedra_Library::Constraint::Constraint(), Parma_Polyhedra_Library::Box_Helpers::extract_interval_congruence(), Parma_Polyhedra_Library::Grid::multiply_grid(), Parma_Polyhedra_Library::Congruences_Reduction< D1, D2 >::product_reduce(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::BD_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::Polyhedron::refine_with_congruence(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::Polyhedron::relation_with(), Parma_Polyhedra_Library::Grid::relation_with(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), Parma_Polyhedra_Library::Congruence_System::satisfies_all_congruences(), Parma_Polyhedra_Library::Grid::simplify(), and Parma_Polyhedra_Library::Grid::simplify_using_context_assign().

244  {
245  return modulus() == 0;
246 }
Coefficient_traits::const_reference modulus() const
Returns a const reference to the modulus of *this.
bool Parma_Polyhedra_Library::Congruence::is_inconsistent ( ) const

Returns true if and only if *this is inconsistent (i.e., an always false congruence).

An inconsistent congruence has one of the following two forms:

  • an equality: $\sum_{i=0}^{n-1} 0 x_i + b == 0$ where $b \neq 0$; or
  • a proper congruence: $\sum_{i=0}^{n-1} 0 x_i + b \%= 0 / m$, where $b \neq 0 \pmod{m}$.

Definition at line 218 of file Congruence.cc.

Referenced by Parma_Polyhedra_Library::Polyhedron::add_congruence(), Parma_Polyhedra_Library::BD_Shape< T >::add_congruence(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_congruence(), Parma_Polyhedra_Library::Box< ITV >::add_congruence_no_check(), Parma_Polyhedra_Library::Grid::add_congruence_no_check(), Parma_Polyhedra_Library::Polyhedron::add_congruences(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::BD_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::Polyhedron::relation_with(), Parma_Polyhedra_Library::Grid::relation_with(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), and Parma_Polyhedra_Library::BD_Shape< T >::relation_with().

218  {
219  if (is_equality()) {
221  }
222 
224 }
Coefficient_traits::const_reference modulus() const
Returns a const reference to the modulus of *this.
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
bool is_equality() const
Returns true if *this is an equality.
bool all_homogeneous_terms_are_zero() const
Returns true if and only if all the homogeneous terms of *this are .
bool Parma_Polyhedra_Library::Congruence::is_tautological ( ) const

Returns true if and only if *this is a tautology (i.e., an always true congruence).

A tautological congruence has one the following two forms:

  • an equality: $\sum_{i=0}^{n-1} 0 x_i + 0 == 0$; or
  • a proper congruence: $\sum_{i=0}^{n-1} 0 x_i + b \%= 0 / m$, where $b = 0 \pmod{m}$.

Definition at line 210 of file Congruence.cc.

Referenced by Parma_Polyhedra_Library::Polyhedron::add_congruence(), Parma_Polyhedra_Library::BD_Shape< T >::add_congruence(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_congruence(), Parma_Polyhedra_Library::Box< ITV >::add_congruence_no_check(), Parma_Polyhedra_Library::Polyhedron::add_congruences(), Parma_Polyhedra_Library::Polyhedron::refine_with_congruence(), and Parma_Polyhedra_Library::Grid::simplify_using_context_assign().

210  {
211  if (is_equality()) {
213  }
215 }
Coefficient_traits::const_reference modulus() const
Returns a const reference to the modulus of *this.
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
bool is_equality() const
Returns true if *this is an equality.
bool all_homogeneous_terms_are_zero() const
Returns true if and only if all the homogeneous terms of *this are .
void Parma_Polyhedra_Library::Congruence::m_swap ( Congruence y)
inline

Swaps *this with y.

Definition at line 266 of file Congruence_inlines.hh.

References expr, modulus_, swap(), and Parma_Polyhedra_Library::swap().

Referenced by swap().

266  {
267  using std::swap;
268  swap(expr, y.expr);
269  swap(modulus_, y.modulus_);
270 }
void swap(CO_Tree &x, CO_Tree &y)
void swap(Congruence &x, Congruence &y)
dimension_type Parma_Polyhedra_Library::Congruence::max_space_dimension ( )
inlinestatic

Returns the maximum space dimension a Congruence can handle.

Definition at line 200 of file Congruence_inlines.hh.

References Parma_Polyhedra_Library::Linear_Expression::max_space_dimension().

Referenced by Parma_Polyhedra_Library::Congruence_System::max_space_dimension().

200  {
202 }
static dimension_type max_space_dimension()
Returns the maximum space dimension a Linear_Expression can handle.
void Parma_Polyhedra_Library::Congruence::normalize ( )

Normalizes signs and the inhomogeneous term.

Applies sign_normalize, then reduces the inhomogeneous term to the smallest possible positive number.

Definition at line 62 of file Congruence.cc.

References c, and PPL_DIRTY_TEMP_COEFFICIENT.

62  {
63  PPL_ASSERT(OK());
65 
66  if (modulus_ == 0) {
67  return;
68  }
69 
72  // Factor the modulus out of the inhomogeneous term.
73  c %= modulus_;
74  if (c < 0) {
75  // Make inhomogeneous term positive.
76  c += modulus_;
77  }
79 
80  PPL_ASSERT(OK());
81 }
void sign_normalize()
Normalizes the signs.
Definition: Congruence.cc:57
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
#define PPL_DIRTY_TEMP_COEFFICIENT(id)
Declare a local variable named id, of type Coefficient, and containing an unknown initial value...
void set_inhomogeneous_term(Coefficient_traits::const_reference n)
Sets the inhomogeneous term of *this to n.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Congruence.cc:252
Coefficient c
Definition: PIP_Tree.cc:64
bool Parma_Polyhedra_Library::Congruence::OK ( ) const

Checks if all the invariants are satisfied.

Definition at line 252 of file Congruence.cc.

Referenced by Congruence(), Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Congruence_System::insert_verbatim(), Parma_Polyhedra_Library::Congruence_System::OK(), Parma_Polyhedra_Library::Grid::reduce_equality_with_equality(), set_modulus(), and set_space_dimension().

252  {
253  // Modulus check.
254  if (modulus() < 0) {
255 #ifndef NDEBUG
256  std::cerr << "Congruence has a negative modulus " << modulus() << "."
257  << std::endl;
258 #endif
259  return false;
260  }
261 
262  // All tests passed.
263  return true;
264 }
Coefficient_traits::const_reference modulus() const
Returns a const reference to the modulus of *this.
Congruence & Parma_Polyhedra_Library::Congruence::operator/= ( Coefficient_traits::const_reference  k)
inline

Multiplies k into the modulus of *this.

If called with *this representing the congruence $ e_1 = e_2 \pmod{m}$, then it returns with *this representing the congruence $ e_1 = e_2 \pmod{mk}$.

Definition at line 169 of file Congruence_inlines.hh.

References modulus_.

169  {
170  if (k >= 0) {
171  modulus_ *= k;
172  }
173  else {
174  modulus_ *= -k;
175  }
176  return *this;
177 }
Congruence & Parma_Polyhedra_Library::Congruence::operator= ( const Congruence y)
inline

Assignment operator.

Definition at line 154 of file Congruence_inlines.hh.

References swap().

154  {
155  Congruence tmp = y;
156  swap(*this, tmp);
157  return *this;
158 }
void swap(Congruence &x, Congruence &y)
Congruence(Representation r=default_representation)
Constructs the 0 = 0 congruence with space dimension 0 .
void Parma_Polyhedra_Library::Congruence::permute_space_dimensions ( const std::vector< Variable > &  cycles)
inline

Definition at line 218 of file Congruence_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::permute_space_dimensions().

Referenced by Parma_Polyhedra_Library::Congruence_System::permute_space_dimensions().

218  {
220 }
void permute_space_dimensions(const std::vector< Variable > &cycle)
Permutes the space dimensions of the expression.
void Parma_Polyhedra_Library::Congruence::print ( ) const

Prints *this to std::cerr using operator<<.

Representation Parma_Polyhedra_Library::Congruence::representation ( ) const
inline

Returns the current representation of *this.

Definition at line 63 of file Congruence_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::representation().

Referenced by Parma_Polyhedra_Library::Congruence_System::OK().

63  {
64  return expr.representation();
65 }
Representation representation() const
Returns the current representation of *this.
void Parma_Polyhedra_Library::Congruence::scale ( Coefficient_traits::const_reference  factor)

Multiplies all the coefficients, including the modulus, by factor .

Definition at line 103 of file Congruence.cc.

Referenced by Parma_Polyhedra_Library::Grid::multiply_grid(), and Parma_Polyhedra_Library::Grid::reduce_congruence_with_equality().

103  {
104  if (factor == 1) {
105  // Nothing to do.
106  return;
107  }
108 
109  expr *= factor;
110  modulus_ *= factor;
111 }
void Parma_Polyhedra_Library::Congruence::set_modulus ( Coefficient_traits::const_reference  m)
inline

Sets the modulus of *this to m . If m is 0, the congruence becomes an equality.

Definition at line 233 of file Congruence_inlines.hh.

References modulus_, and OK().

Referenced by Parma_Polyhedra_Library::Grid::conversion(), and Parma_Polyhedra_Library::Grid::simplify().

233  {
234  modulus_ = m;
235  PPL_ASSERT(OK());
236 }
bool OK() const
Checks if all the invariants are satisfied.
Definition: Congruence.cc:252
void Parma_Polyhedra_Library::Congruence::set_representation ( Representation  r)
inline

Converts *this to the specified representation.

Definition at line 68 of file Congruence_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::set_representation().

Referenced by Parma_Polyhedra_Library::Congruence_System::concatenate(), and Parma_Polyhedra_Library::Congruence_System::insert_verbatim().

68  {
70 }
void set_representation(Representation r)
Converts *this to the specified representation.
void Parma_Polyhedra_Library::Congruence::set_space_dimension ( dimension_type  n)
inline

Sets the space dimension by n , adding or removing coefficients as needed.

Definition at line 78 of file Congruence_inlines.hh.

References expr, OK(), and Parma_Polyhedra_Library::Linear_Expression::set_space_dimension().

Referenced by Parma_Polyhedra_Library::Congruence_System::insert_verbatim(), and Parma_Polyhedra_Library::Grid::simplify().

78  {
80  PPL_ASSERT(OK());
81 }
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
bool OK() const
Checks if all the invariants are satisfied.
Definition: Congruence.cc:252
void Parma_Polyhedra_Library::Congruence::shift_space_dimensions ( Variable  v,
dimension_type  n 
)
inline

Shift by n positions the coefficients of variables, starting from the coefficient of v. This increases the space dimension by n.

Definition at line 84 of file Congruence_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::shift_space_dimensions().

Referenced by Parma_Polyhedra_Library::Congruence_System::concatenate().

84  {
86 }
void shift_space_dimensions(Variable v, dimension_type n)
void Parma_Polyhedra_Library::Congruence::sign_normalize ( )

Normalizes the signs.

The signs of the coefficients and the inhomogeneous term are normalized, leaving the first non-zero homogeneous coefficient positive.

Definition at line 57 of file Congruence.cc.

dimension_type Parma_Polyhedra_Library::Congruence::space_dimension ( ) const
inline

Returns the dimension of the vector space enclosing *this.

Definition at line 205 of file Congruence_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::space_dimension().

Referenced by Parma_Polyhedra_Library::Box< ITV >::add_congruence(), Parma_Polyhedra_Library::Polyhedron::add_congruence(), Parma_Polyhedra_Library::BD_Shape< T >::add_congruence(), Parma_Polyhedra_Library::Grid::add_congruence(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_congruence(), Parma_Polyhedra_Library::Box< ITV >::add_congruence_no_check(), Parma_Polyhedra_Library::Grid::add_congruence_no_check(), Parma_Polyhedra_Library::Scalar_Products::assign(), coefficient(), Parma_Polyhedra_Library::Box_Helpers::extract_interval_congruence(), Parma_Polyhedra_Library::Scalar_Products::homogeneous_assign(), Parma_Polyhedra_Library::Congruence_System::insert_verbatim(), Parma_Polyhedra_Library::Congruence_System::OK(), operator<<(), operator==(), Parma_Polyhedra_Library::Scalar_Products::reduced_assign(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::BD_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::Box< ITV >::refine_with_congruence(), Parma_Polyhedra_Library::Polyhedron::refine_with_congruence(), Parma_Polyhedra_Library::BD_Shape< T >::refine_with_congruence(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_with_congruence(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::Polyhedron::relation_with(), Parma_Polyhedra_Library::Grid::relation_with(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), Parma_Polyhedra_Library::Box< ITV >::throw_dimension_incompatible(), Parma_Polyhedra_Library::Octagonal_Shape< T >::throw_dimension_incompatible(), Parma_Polyhedra_Library::BD_Shape< T >::throw_dimension_incompatible(), Parma_Polyhedra_Library::Grid::throw_dimension_incompatible(), and Parma_Polyhedra_Library::Polyhedron::throw_dimension_incompatible().

205  {
206  return expr.space_dimension();
207 }
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void Parma_Polyhedra_Library::Congruence::strong_normalize ( )

Calls normalize, then divides out common factors.

Strongly normalized Congruences have equivalent semantics if and only if they have the same syntax (as output by operator<<).

Definition at line 84 of file Congruence.cc.

References Parma_Polyhedra_Library::gcd_assign().

Referenced by Parma_Polyhedra_Library::Congruence_System::insert(), Parma_Polyhedra_Library::Congruence_System::operator<<(), and operator==().

84  {
85  normalize();
86 
87  Coefficient gcd = expr.gcd(0, expr.space_dimension() + 1);
88  if (gcd == 0) {
89  gcd = modulus_;
90  }
91  else {
92  gcd_assign(gcd, modulus_, gcd);
93  }
94 
95  if (gcd != 0 && gcd != 1) {
96  expr /= gcd;
97  modulus_ /= gcd;
98  }
99  PPL_ASSERT(OK());
100 }
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Coefficient gcd(dimension_type start, dimension_type end) const
Returns the gcd of the nonzero coefficients in [start,end). If all the coefficients in this range are...
void normalize()
Normalizes signs and the inhomogeneous term.
Definition: Congruence.cc:62
bool OK() const
Checks if all the invariants are satisfied.
Definition: Congruence.cc:252
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
void gcd_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
void Parma_Polyhedra_Library::Congruence::swap_space_dimensions ( Variable  v1,
Variable  v2 
)
inline

Swaps the coefficients of the variables v1 and v2 .

Definition at line 273 of file Congruence_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::swap_space_dimensions().

273  {
274  expr.swap_space_dimensions(v1, v2);
275 }
void swap_space_dimensions(Variable v1, Variable v2)
Swaps the coefficients of the variables v1 and v2 .
void Parma_Polyhedra_Library::Congruence::throw_dimension_incompatible ( const char *  method,
const char *  v_name,
Variable  v 
) const
private

Throws a std::invalid_argument exception containing the appropriate error message.

Definition at line 159 of file Congruence.cc.

References Parma_Polyhedra_Library::Variable::space_dimension().

Referenced by coefficient().

161  {
162  std::ostringstream s;
163  s << "this->space_dimension() == " << space_dimension() << ", "
164  << v_name << ".space_dimension() == " << v.space_dimension() << ".";
165  const std::string str = s.str();
166  throw_invalid_argument(method, str.c_str());
167 }
void throw_invalid_argument(const char *method, const char *message) const
Throws a std::invalid_argument exception containing error message message.
Definition: Congruence.cc:150
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void Parma_Polyhedra_Library::Congruence::throw_invalid_argument ( const char *  method,
const char *  message 
) const
private

Throws a std::invalid_argument exception containing error message message.

Definition at line 150 of file Congruence.cc.

Referenced by Congruence().

151  {
152  std::ostringstream s;
153  s << "PPL::Congruence::" << method << ":" << std::endl
154  << message;
155  throw std::invalid_argument(s.str());
156 }
memory_size_type Parma_Polyhedra_Library::Congruence::total_memory_in_bytes ( ) const
inline

Returns a lower bound to the total size in bytes of the memory occupied by *this.

Definition at line 261 of file Congruence_inlines.hh.

References external_memory_in_bytes().

261  {
262  return external_memory_in_bytes() + sizeof(*this);
263 }
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
const Congruence & Parma_Polyhedra_Library::Congruence::zero_dim_false ( )
inlinestatic
const Congruence & Parma_Polyhedra_Library::Congruence::zero_dim_integrality ( )
inlinestatic

Returns a reference to the true (zero-dimension space) congruence $0 = 1 \pmod{1}$, also known as the integrality congruence.

Definition at line 144 of file Congruence_inlines.hh.

References zero_dim_integrality_p.

Referenced by Parma_Polyhedra_Library::Grid::construct().

144  {
145  return *zero_dim_integrality_p;
146 }
static const Congruence * zero_dim_integrality_p
Holds (between class initialization and finalization) a pointer to the true (zero-dimension space) co...

Friends And Related Function Documentation

friend class Grid
friend

Definition at line 458 of file Congruence_defs.hh.

bool operator!= ( const Congruence x,
const Congruence y 
)
related

Returns false if and only if x and y are equivalent.

bool operator!= ( const Congruence x,
const Congruence y 
)
related

Definition at line 195 of file Congruence_inlines.hh.

195  {
196  return !(x == y);
197 }
bool operator!= ( const Congruence x,
const Congruence y 
)
friend
Congruence operator%= ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Definition at line 125 of file Congruence_inlines.hh.

References create().

125  {
126  return Congruence::create(e1, e2);
127 }
static Congruence create(const Linear_Expression &e1, const Linear_Expression &e2, Representation r=default_representation)
Returns the congruence .
Definition: Congruence.cc:139
Congruence operator%= ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Definition at line 131 of file Congruence_inlines.hh.

References create().

131  {
132  return Congruence::create(e, n);
133 }
static Congruence create(const Linear_Expression &e1, const Linear_Expression &e2, Representation r=default_representation)
Returns the congruence .
Definition: Congruence.cc:139
Congruence operator%= ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Returns the congruence $e1 = e2 \pmod{1}$.

Congruence operator%= ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Returns the congruence $e = n \pmod{1}$.

Congruence operator/ ( const Congruence cg,
Coefficient_traits::const_reference  k 
)
related

Definition at line 137 of file Congruence_inlines.hh.

137  {
138  Congruence ret = cg;
139  ret /= k;
140  return ret;
141 }
Congruence(Representation r=default_representation)
Constructs the 0 = 0 congruence with space dimension 0 .
Congruence operator/ ( const Constraint c,
Coefficient_traits::const_reference  m 
)
related

Definition at line 162 of file Congruence_inlines.hh.

162  {
163  Congruence ret(c);
164  ret /= m;
165  return ret;
166 }
Congruence(Representation r=default_representation)
Constructs the 0 = 0 congruence with space dimension 0 .
Coefficient c
Definition: PIP_Tree.cc:64
Congruence operator/ ( const Congruence cg,
Coefficient_traits::const_reference  k 
)
related

Returns a copy of cg, multiplying k into the copy's modulus.

If cg represents the congruence $ e_1 = e_2 \pmod{m}$, then the result represents the congruence $ e_1 = e_2 \pmod{mk}$.

Congruence operator/ ( const Constraint c,
Coefficient_traits::const_reference  m 
)
related

Creates a congruence from c, with m as the modulus.

std::ostream & operator<< ( std::ostream &  s,
const Congruence c 
)
related

Definition at line 171 of file Congruence.cc.

References Parma_Polyhedra_Library::Expression_Adapter< T >::begin(), Parma_Polyhedra_Library::Coefficient_zero(), expression(), inhomogeneous_term(), is_proper_congruence(), Parma_Polyhedra_Library::Expression_Adapter< T >::lower_bound(), modulus(), Parma_Polyhedra_Library::neg_assign(), PPL_DIRTY_TEMP_COEFFICIENT, and space_dimension().

171  {
172  const dimension_type num_variables = c.space_dimension();
174  bool first = true;
175  const Congruence::expr_type c_e = c.expression();
176  for (Congruence::expr_type::const_iterator i = c_e.begin(),
177  i_end = c_e.lower_bound(Variable(num_variables)); i != i_end; ++i) {
178  cv = *i;
179  if (!first) {
180  if (cv > 0) {
181  s << " + ";
182  }
183  else {
184  s << " - ";
185  neg_assign(cv);
186  }
187  }
188  else {
189  first = false;
190  }
191  if (cv == -1) {
192  s << "-";
193  }
194  else if (cv != 1) {
195  s << cv << "*";
196  }
197  s << i.variable();
198  }
199  if (first) {
200  s << Coefficient_zero();
201  }
202  s << " = " << -c.inhomogeneous_term();
203  if (c.is_proper_congruence()) {
204  s << " (mod " << c.modulus() << ")";
205  }
206  return s;
207 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
#define PPL_DIRTY_TEMP_COEFFICIENT(id)
Declare a local variable named id, of type Coefficient, and containing an unknown initial value...
void neg_assign(GMP_Integer &x)
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
base_type::const_iterator const_iterator
The type of const iterators on coefficients.
Coefficient c
Definition: PIP_Tree.cc:64
Expression_Adapter_Transparent< Linear_Expression > expr_type
The type of the (adapted) internal expression.
std::ostream & operator<< ( std::ostream &  s,
const Congruence c 
)
related

Output operators.

bool operator== ( const Congruence x,
const Congruence y 
)
related

Returns true if and only if x and y are equivalent.

bool operator== ( const Congruence x,
const Congruence y 
)
related

Definition at line 181 of file Congruence_inlines.hh.

References expr, Parma_Polyhedra_Library::Linear_Expression::is_equal_to(), modulus(), space_dimension(), and strong_normalize().

181  {
182  if (x.space_dimension() != y.space_dimension()) {
183  return false;
184  }
185  Congruence x_temp(x);
186  Congruence y_temp(y);
187  x_temp.strong_normalize();
188  y_temp.strong_normalize();
189  return x_temp.expr.is_equal_to(y_temp.expr)
190  && x_temp.modulus() == y_temp.modulus();
191 }
Congruence(Representation r=default_representation)
Constructs the 0 = 0 congruence with space dimension 0 .
bool operator== ( const Congruence x,
const Congruence y 
)
friend
friend class Scalar_Products
friend

Definition at line 457 of file Congruence_defs.hh.

void swap ( Congruence x,
Congruence y 
)
related

Definition at line 279 of file Congruence_inlines.hh.

References m_swap().

279  {
280  x.m_swap(y);
281 }
void swap ( Congruence x,
Congruence y 
)
related

Referenced by Congruence(), m_swap(), and operator=().

Member Data Documentation

const Representation Parma_Polyhedra_Library::Congruence::default_representation = SPARSE
static

The representation used for new Congruences.

Note
The copy constructor and the copy constructor with specified size use the representation of the original object, so that it is indistinguishable from the original object.

Definition at line 170 of file Congruence_defs.hh.

Coefficient Parma_Polyhedra_Library::Congruence::modulus_
private
const PPL::Congruence * Parma_Polyhedra_Library::Congruence::zero_dim_false_p = 0
staticprivate

Holds (between class initialization and finalization) a pointer to the false (zero-dimension space) congruence $0 = 1 \pmod{0}$.

Definition at line 415 of file Congruence_defs.hh.

Referenced by zero_dim_false().

const PPL::Congruence * Parma_Polyhedra_Library::Congruence::zero_dim_integrality_p = 0
staticprivate

Holds (between class initialization and finalization) a pointer to the true (zero-dimension space) congruence $0 = 1 \pmod{1}$, also known as the integrality congruence.

Definition at line 422 of file Congruence_defs.hh.

Referenced by zero_dim_integrality().


The documentation for this class was generated from the following files: