PPL  1.2
Parma_Polyhedra_Library::Congruence_System Class Reference

A system of congruences. More...

#include <Congruence_System_defs.hh>

Collaboration diagram for Parma_Polyhedra_Library::Congruence_System:

Classes

class  const_iterator
 An iterator over a system of congruences. More...
 

Public Types

typedef Congruence row_type
 

Public Member Functions

 Congruence_System (Representation r=default_representation)
 Default constructor: builds an empty system of congruences. More...
 
 Congruence_System (dimension_type d, Representation r=default_representation)
 Builds an empty (i.e. zero rows) system of dimension d. More...
 
 Congruence_System (const Congruence &cg, Representation r=default_representation)
 Builds the singleton system containing only congruence cg. More...
 
 Congruence_System (const Constraint &c, Representation r=default_representation)
 If c represents the constraint $ e_1 = e_2 $, builds the singleton system containing only constraint $ e_1 = e_2 \pmod{0}$. More...
 
 Congruence_System (const Constraint_System &cs, Representation r=default_representation)
 Builds a system containing copies of any equalities in cs. More...
 
 Congruence_System (const Congruence_System &cgs)
 Ordinary copy constructor. More...
 
 Congruence_System (const Congruence_System &cgs, Representation r)
 Copy constructor with specified representation. More...
 
 ~Congruence_System ()
 Destructor. More...
 
Congruence_Systemoperator= (const Congruence_System &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...
 
bool is_equal_to (const Congruence_System &y) const
 Returns true if and only if *this is exactly equal to y. More...
 
bool has_linear_equalities () const
 Returns true if and only if *this contains one or more linear equalities. More...
 
void clear ()
 Removes all the congruences and sets the space dimension to 0. More...
 
void insert (const Congruence &cg)
 Inserts in *this a copy of the congruence cg, increasing the number of space dimensions if needed. More...
 
void insert (Congruence &cg, Recycle_Input)
 Inserts in *this the congruence cg, stealing its contents and increasing the number of space dimensions if needed. More...
 
void insert (const Constraint &c)
 Inserts in *this a copy of the equality constraint c, seen as a modulo 0 congruence, increasing the number of space dimensions if needed. More...
 
void insert (const Congruence_System &y)
 Inserts in *this a copy of the congruences in y, increasing the number of space dimensions if needed. More...
 
void insert (Congruence_System &cgs, Recycle_Input)
 Inserts into *this the congruences in cgs, increasing the number of space dimensions if needed. More...
 
bool empty () const
 Returns true if and only if *this has no congruences. More...
 
const_iterator begin () const
 Returns the const_iterator pointing to the first congruence, if this is not empty; otherwise, returns the past-the-end const_iterator. More...
 
const_iterator end () const
 Returns the past-the-end const_iterator. 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 (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise. More...
 
memory_size_type total_memory_in_bytes () const
 Returns 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...
 
dimension_type num_equalities () const
 Returns the number of equalities. More...
 
dimension_type num_proper_congruences () const
 Returns the number of proper congruences. More...
 
void m_swap (Congruence_System &y)
 Swaps *this with y. More...
 
void add_unit_rows_and_space_dimensions (dimension_type dims)
 Adds dims rows and dims space dimensions to the matrix, initializing the added rows as in the unit congruence system. More...
 
void permute_space_dimensions (const std::vector< Variable > &cycle)
 Permutes the space dimensions of the system. More...
 
void swap_space_dimensions (Variable v1, Variable v2)
 Swaps the columns having indexes i and j. More...
 
bool set_space_dimension (dimension_type new_space_dim)
 Sets the number of space dimensions to new_space_dim. More...
 

Static Public Member Functions

static dimension_type max_space_dimension ()
 Returns the maximum space dimension a Congruence_System can handle. More...
 
static void initialize ()
 Initializes the class. More...
 
static void finalize ()
 Finalizes the class. More...
 
static const Congruence_Systemzero_dim_empty ()
 Returns the system containing only Congruence::zero_dim_false(). More...
 

Static Public Attributes

static const Representation default_representation = SPARSE
 

Protected Member Functions

bool satisfies_all_congruences (const Grid_Generator &g) const
 Returns true if g satisfies all the congruences. More...
 

Private Member Functions

dimension_type num_rows () const
 Returns the number of rows in the system. More...
 
bool has_no_rows () const
 Returns true if num_rows()==0. More...
 
const Congruenceoperator[] (dimension_type k) const
 Returns a constant reference to the k- th congruence of the system. More...
 
void normalize_moduli ()
 Adjusts all expressions to have the same moduli. More...
 
void affine_preimage (Variable v, const Linear_Expression &expr, Coefficient_traits::const_reference denominator)
 Substitutes a given column of coefficients by a given affine expression. More...
 
void concatenate (const Congruence_System &y)
 Concatenates copies of the congruences from y onto *this. More...
 
void insert_verbatim (Congruence &cg, Recycle_Input)
 Inserts in *this the congruence cg, stealing its contents and increasing the number of space dimensions if needed. More...
 
void remove_rows (dimension_type first, dimension_type last, bool keep_sorted)
 Makes the system shrink by removing the rows in [first,last). More...
 
void remove_trailing_rows (dimension_type n)
 
bool has_a_free_dimension () const
 Returns true if and only if any of the dimensions in *this is free of constraint. More...
 

Private Attributes

Swapping_Vector< Congruencerows
 
dimension_type space_dimension_
 
Representation representation_
 

Static Private Attributes

static const Congruence_Systemzero_dim_empty_p = 0
 Holds (between class initialization and finalization) a pointer to the singleton system containing only Congruence::zero_dim_false(). More...
 

Friends

class Grid
 
bool operator== (const Congruence_System &x, const Congruence_System &y)
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &s, const Congruence_System &cgs)
 
bool operator== (const Congruence_System &x, const Congruence_System &y)
 
bool operator== (const Congruence_System &x, const Congruence_System &y)
 
std::ostream & operator<< (std::ostream &s, const Congruence_System &cgs)
 Output operator. More...
 
void swap (Congruence_System &x, Congruence_System &y)
 
void swap (Congruence_System &x, Congruence_System &y)
 

Detailed Description

A system of congruences.

An object of the class Congruence_System is a system of congruences, i.e., a multiset of objects of the class Congruence. When inserting congruences in a system, space dimensions are automatically adjusted so that all the congruences in the system are defined on the same vector space.

In all the examples it is assumed that variables x and y are defined as follows:
Variable x(0);
Variable y(1);
Example 1
The following code builds a system of congruences corresponding to an integer grid in $\Rset^2$:
cgs.insert(x %= 0);
cgs.insert(y %= 0);
Note that: the congruence system is created with space dimension zero; the first and second congruence insertions increase the space dimension to $1$ and $2$, respectively.
Example 2
By adding to the congruence system of the previous example, the congruence $x + y = 1 \pmod{2}$:
cgs.insert((x + y %= 1) / 2);
we obtain the grid containing just those integral points where the sum of the x and y values is odd.
Example 3
The following code builds a system of congruences corresponding to the grid in $\Zset^2$ containing just the integral points on the x axis:
cgs.insert(x %= 0);
cgs.insert((y %= 0) / 0);
Note
After inserting a multiset of congruences in a congruence system, there are no guarantees that an exact copy of them can be retrieved: in general, only an equivalent congruence system will be available, where original congruences may have been reordered, removed (if they are trivial, duplicate or implied by other congruences), linearly combined, etc.

Definition at line 103 of file Congruence_System_defs.hh.

Member Typedef Documentation

Constructor & Destructor Documentation

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

Default constructor: builds an empty system of congruences.

Definition at line 68 of file Congruence_System_inlines.hh.

Parma_Polyhedra_Library::Congruence_System::Congruence_System ( dimension_type  d,
Representation  r = default_representation 
)
inlineexplicit

Builds an empty (i.e. zero rows) system of dimension d.

Definition at line 111 of file Congruence_System_inlines.hh.

Parma_Polyhedra_Library::Congruence_System::Congruence_System ( const Congruence cg,
Representation  r = default_representation 
)
inlineexplicit

Builds the singleton system containing only congruence cg.

Definition at line 75 of file Congruence_System_inlines.hh.

References insert().

76  : rows(),
78  representation_(r) {
79  insert(cg);
80 }
void insert(const Congruence &cg)
Inserts in *this a copy of the congruence cg, increasing the number of space dimensions if needed...
Parma_Polyhedra_Library::Congruence_System::Congruence_System ( const Constraint c,
Representation  r = default_representation 
)
inlineexplicit

If c represents the constraint $ e_1 = e_2 $, builds the singleton system containing only constraint $ e_1 = e_2 \pmod{0}$.

Exceptions
std::invalid_argumentThrown if c is not an equality constraint.

Definition at line 83 of file Congruence_System_inlines.hh.

References insert().

84  : rows(),
86  representation_(r) {
87  insert(c);
88 }
void insert(const Congruence &cg)
Inserts in *this a copy of the congruence cg, increasing the number of space dimensions if needed...
Coefficient c
Definition: PIP_Tree.cc:64
Parma_Polyhedra_Library::Congruence_System::Congruence_System ( const Constraint_System cs,
Representation  r = default_representation 
)
explicit

Builds a system containing copies of any equalities in cs.

Definition at line 41 of file Congruence_System.cc.

References Parma_Polyhedra_Library::Constraint_System::begin(), Parma_Polyhedra_Library::Constraint_System::end(), and insert().

43  : rows(),
44  space_dimension_(cs.space_dimension()),
45  representation_(r) {
46  for (Constraint_System::const_iterator i = cs.begin(),
47  cs_end = cs.end(); i != cs_end; ++i) {
48  if (i->is_equality()) {
49  insert(*i);
50  }
51  }
52 }
void insert(const Congruence &cg)
Inserts in *this a copy of the congruence cg, increasing the number of space dimensions if needed...
Constraint_System_const_iterator const_iterator
Parma_Polyhedra_Library::Congruence_System::Congruence_System ( const Congruence_System cgs)
inline

Ordinary copy constructor.

Note
The new Congruence_System will have the same Representation as `cgs' so that it's indistinguishable from `cgs'.

Definition at line 91 of file Congruence_System_inlines.hh.

92  : rows(cgs.rows),
93  space_dimension_(cgs.space_dimension_),
94  representation_(cgs.representation_) {
95 }
Parma_Polyhedra_Library::Congruence_System::Congruence_System ( const Congruence_System cgs,
Representation  r 
)
inline

Copy constructor with specified representation.

Definition at line 98 of file Congruence_System_inlines.hh.

References num_rows(), representation(), and rows.

100  : rows(cgs.rows),
101  space_dimension_(cgs.space_dimension_),
102  representation_(r) {
103  if (cgs.representation() != r) {
104  for (dimension_type i = 0; i < num_rows(); ++i) {
105  rows[i].set_representation(representation());
106  }
107  }
108 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
Representation representation() const
Returns the current representation of *this.
dimension_type num_rows() const
Returns the number of rows in the system.
Parma_Polyhedra_Library::Congruence_System::~Congruence_System ( )
inline

Destructor.

Definition at line 118 of file Congruence_System_inlines.hh.

118  {
119 }

Member Function Documentation

void Parma_Polyhedra_Library::Congruence_System::add_unit_rows_and_space_dimensions ( dimension_type  dims)

Adds dims rows and dims space dimensions to the matrix, initializing the added rows as in the unit congruence system.

Parameters
dimsThe number of rows and space dimensions to be added: must be strictly positive.

Turns the $r \times c$ matrix $A$ into the $(r+dims) \times (c+dims)$ matrix $\bigl(\genfrac{}{}{0pt}{}{0}{A} \genfrac{}{}{0pt}{}{B}{A}\bigr)$ where $B$ is the $dims \times dims$ unit matrix of the form $\bigl(\genfrac{}{}{0pt}{}{0}{1} \genfrac{}{}{0pt}{}{1}{0}\bigr)$. The matrix is expanded avoiding reallocation whenever possible.

Definition at line 463 of file Congruence_System.cc.

References Parma_Polyhedra_Library::Coefficient_zero(), Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), and Parma_Polyhedra_Library::swap().

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

463  {
464  const dimension_type old_num_rows = num_rows();
466 
467  rows.resize(rows.size() + dims);
468 
469  // Swap the added rows to the front of the vector.
470  for (dimension_type row = old_num_rows; row-- > 0; ) {
471  swap(rows[row], rows[row + dims]);
472  }
473 
474  const dimension_type dim = space_dimension();
475  // Set the space dimension and the diagonal element of each added row.
476  for (dimension_type row = dims; row-- > 0; ) {
477  Linear_Expression expr(representation());
478  expr.set_space_dimension(space_dimension());
479  PPL_ASSERT(dim >= row + 1);
480  expr += Variable(dim - row - 1);
481  // This constructor steals the contents of `expr'.
482  Congruence cg(expr, Coefficient_zero(), Recycle_Input());
483  swap(rows[row], cg);
484  }
485 
486  PPL_ASSERT(OK());
487 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool set_space_dimension(dimension_type new_space_dim)
Sets the number of space dimensions to new_space_dim.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Representation representation() const
Returns the current representation of *this.
bool OK() const
Checks if all the invariants are satisfied.
void swap(Congruence_System &x, Congruence_System &y)
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
dimension_type num_rows() const
Returns the number of rows in the system.
void Parma_Polyhedra_Library::Congruence_System::affine_preimage ( Variable  v,
const Linear_Expression expr,
Coefficient_traits::const_reference  denominator 
)
private

Substitutes a given column of coefficients by a given affine expression.

Parameters
vIndex of the column to which the affine transformation is substituted;
exprThe numerator of the affine transformation: $\sum_{i = 0}^{n - 1} a_i x_i + b$;
denominatorThe denominator of the affine transformation.

We allow affine transformations (see the Section Operations on Rational Grids) to have rational coefficients. Since the coefficients of linear expressions are integers we also provide an integer denominator that will be used as denominator of the affine transformation. The denominator is required to be a positive integer and its default value is 1.

The affine transformation substitutes the matrix of congruences by a new matrix whose elements ${a'}_{ij}$ are built from the old one $a_{ij}$ as follows:

\[ {a'}_{ij} = \begin{cases} a_{ij} * \mathrm{denominator} + a_{iv} * \mathrm{expr}[j] \quad \text{for } j \neq v; \\ \mathrm{expr}[v] * a_{iv} \quad \text{for } j = v. \end{cases} \]

expr is a constant parameter and unaltered by this computation.

Definition at line 329 of file Congruence_System.cc.

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

331  {
332  PPL_ASSERT(v.space_dimension() <= space_dimension());
333  PPL_ASSERT(expr.space_dimension() <= space_dimension());
334  PPL_ASSERT(denominator > 0);
335 
336  for (dimension_type i = num_rows(); i-- > 0; ) {
337  rows[i].affine_preimage(v, expr, denominator);
338  }
339 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
dimension_type num_rows() const
Returns the number of rows in the system.
void Parma_Polyhedra_Library::Congruence_System::ascii_dump ( std::ostream &  s) const

Writes to s an ASCII representation of *this.

Definition at line 342 of file Congruence_System.cc.

References Parma_Polyhedra_Library::ascii_dump(), ascii_dump(), num_rows(), and space_dimension().

342  {
343  const Congruence_System& x = *this;
344  const dimension_type x_num_rows = x.num_rows();
345  const dimension_type x_space_dim = x.space_dimension();
346  s << x_num_rows << " x " << x_space_dim << " ";
348  s << std::endl;
349  for (dimension_type i = 0; i < x_num_rows; ++i) {
350  x[i].ascii_dump(s);
351  }
352 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
Enable_If< Is_Native_Or_Checked< T >::value, void >::type ascii_dump(std::ostream &s, const T &t)
Representation representation() const
Returns the current representation of *this.
Congruence_System(Representation r=default_representation)
Default constructor: builds an empty system of congruences.
void Parma_Polyhedra_Library::Congruence_System::ascii_dump ( ) const

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

Referenced by ascii_dump(), and Parma_Polyhedra_Library::Grid::OK().

bool Parma_Polyhedra_Library::Congruence_System::ascii_load ( std::istream &  s)

Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise.

Definition at line 357 of file Congruence_System.cc.

References Parma_Polyhedra_Library::ascii_load(), Parma_Polyhedra_Library::Congruence::ascii_load(), and c.

357  {
358  std::string str;
360  dimension_type space_dim;
361  if (!(s >> num_rows)) {
362  return false;
363  }
364  if (!(s >> str) || str != "x") {
365  return false;
366  }
367  if (!(s >> space_dim)) {
368  return false;
369  }
370  clear();
371  space_dimension_ = space_dim;
372 
374  return false;
375  }
376 
377  Congruence c;
378  for (dimension_type i = 0; i < num_rows; ++i) {
379  if (!c.ascii_load(s)) {
380  return false;
381  }
382  insert_verbatim(c, Recycle_Input());
383  }
384 
385  // Check invariants.
386  PPL_ASSERT(OK());
387  return true;
388 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
void insert_verbatim(Congruence &cg, Recycle_Input)
Inserts in *this the congruence cg, stealing its contents and increasing the number of space dimensio...
bool OK() const
Checks if all the invariants are satisfied.
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type ascii_load(std::istream &s, T &t)
dimension_type num_rows() const
Returns the number of rows in the system.
Coefficient c
Definition: PIP_Tree.cc:64
void clear()
Removes all the congruences and sets the space dimension to 0.
Congruence_System::const_iterator Parma_Polyhedra_Library::Congruence_System::begin ( ) const
inline

Returns the const_iterator pointing to the first congruence, if this is not empty; otherwise, returns the past-the-end const_iterator.

Definition at line 230 of file Congruence_System_inlines.hh.

References rows, and Parma_Polyhedra_Library::Congruence_System::const_iterator::skip_forward().

Referenced by Parma_Polyhedra_Library::Polyhedron::add_congruences(), Parma_Polyhedra_Library::BD_Shape< T >::add_congruences(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_congruences(), Parma_Polyhedra_Library::Box< ITV >::add_congruences_no_check(), Parma_Polyhedra_Library::Grid::add_recycled_congruences(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::approximate_partition(), Parma_Polyhedra_Library::Partially_Reduced_Product< D1, D2, R >::congruences(), Parma_Polyhedra_Library::Constraint_System::Constraint_System(), Parma_Polyhedra_Library::Grid::difference_assign(), empty(), Parma_Polyhedra_Library::Grid::expand_space_dimension(), Parma_Polyhedra_Library::Partially_Reduced_Product< D1, D2, R >::minimized_congruences(), operator<<(), Parma_Polyhedra_Library::Congruences_Reduction< D1, D2 >::product_reduce(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Polyhedron::refine_with_congruences(), Parma_Polyhedra_Library::BD_Shape< T >::refine_with_congruences(), and Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_with_congruences().

230  {
231  const_iterator i(rows.begin(), *this);
232  i.skip_forward();
233  return i;
234 }
void Parma_Polyhedra_Library::Congruence_System::clear ( )
inline

Removes all the congruences and sets the space dimension to 0.

Definition at line 156 of file Congruence_System_inlines.hh.

References rows, and space_dimension_.

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

156  {
157  rows.clear();
158  space_dimension_ = 0;
159 }
void Parma_Polyhedra_Library::Congruence_System::concatenate ( const Congruence_System y)
private

Concatenates copies of the congruences from y onto *this.

Parameters
yThe congruence system to append to this. The number of rows in y must be strictly positive.

The matrix for the new system of congruences is obtained by leaving the old system in the upper left-hand side and placing the congruences of y in the lower right-hand side, and padding with zeroes.

Definition at line 490 of file Congruence_System.cc.

References num_rows(), rows, Parma_Polyhedra_Library::Congruence::set_representation(), Parma_Polyhedra_Library::Congruence::shift_space_dimensions(), space_dimension(), and Parma_Polyhedra_Library::swap().

490  {
491  // TODO: this implementation is just an executable specification.
492  Congruence_System cgs = y;
493 
494  const dimension_type added_rows = cgs.num_rows();
495  const dimension_type added_columns = cgs.space_dimension();
496 
497  const dimension_type old_num_rows = num_rows();
498  const dimension_type old_space_dim = space_dimension();
499 
500  set_space_dimension(space_dimension() + added_columns);
501 
502  rows.resize(rows.size() + added_rows);
503 
504  // Move the congruences into *this from `cgs', shifting the
505  // coefficients along into the appropriate columns.
506  for (dimension_type i = added_rows; i-- > 0; ) {
507  Congruence& cg_old = cgs.rows[i];
508  Congruence& cg_new = rows[old_num_rows + i];
509  cg_old.set_representation(representation());
510  cg_old.shift_space_dimensions(Variable(0), old_space_dim);
511  swap(cg_old, cg_new);
512  }
513 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool set_space_dimension(dimension_type new_space_dim)
Sets the number of space dimensions to new_space_dim.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Representation representation() const
Returns the current representation of *this.
void swap(Congruence_System &x, Congruence_System &y)
dimension_type num_rows() const
Returns the number of rows in the system.
Congruence_System(Representation r=default_representation)
Default constructor: builds an empty system of congruences.
bool Parma_Polyhedra_Library::Congruence_System::empty ( ) const
inline

Returns true if and only if *this has no congruences.

Definition at line 243 of file Congruence_System_inlines.hh.

References begin(), and end().

243  {
244  return begin() == end();
245 }
const_iterator end() const
Returns the past-the-end const_iterator.
const_iterator begin() const
Returns the const_iterator pointing to the first congruence, if this is not empty; otherwise...
Congruence_System::const_iterator Parma_Polyhedra_Library::Congruence_System::end ( ) const
inline

Returns the past-the-end const_iterator.

Definition at line 237 of file Congruence_System_inlines.hh.

References rows.

Referenced by Parma_Polyhedra_Library::Polyhedron::add_congruences(), Parma_Polyhedra_Library::BD_Shape< T >::add_congruences(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_congruences(), Parma_Polyhedra_Library::Box< ITV >::add_congruences_no_check(), Parma_Polyhedra_Library::Grid::add_recycled_congruences(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::approximate_partition(), Parma_Polyhedra_Library::Partially_Reduced_Product< D1, D2, R >::congruences(), Parma_Polyhedra_Library::Constraint_System::Constraint_System(), Parma_Polyhedra_Library::Grid::difference_assign(), empty(), Parma_Polyhedra_Library::Grid::expand_space_dimension(), Parma_Polyhedra_Library::Partially_Reduced_Product< D1, D2, R >::minimized_congruences(), operator<<(), Parma_Polyhedra_Library::Congruences_Reduction< D1, D2 >::product_reduce(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Polyhedron::refine_with_congruences(), Parma_Polyhedra_Library::BD_Shape< T >::refine_with_congruences(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_with_congruences(), and Parma_Polyhedra_Library::Congruence_System::const_iterator::skip_forward().

237  {
238  const const_iterator i(rows.end(), *this);
239  return i;
240 }
memory_size_type Parma_Polyhedra_Library::Congruence_System::external_memory_in_bytes ( ) const
inline

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

Definition at line 258 of file Congruence_System_inlines.hh.

References rows.

258  {
259  return rows.external_memory_in_bytes();
260 }
void Parma_Polyhedra_Library::Congruence_System::finalize ( )
static

Finalizes the class.

Definition at line 400 of file Congruence_System.cc.

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

400  {
401  PPL_ASSERT(zero_dim_empty_p != 0);
402  delete zero_dim_empty_p;
403  zero_dim_empty_p = 0;
404 }
static const Congruence_System * zero_dim_empty_p
Holds (between class initialization and finalization) a pointer to the singleton system containing on...
bool Parma_Polyhedra_Library::Congruence_System::has_a_free_dimension ( ) const
private

Returns true if and only if any of the dimensions in *this is free of constraint.

Any equality or proper congruence affecting a dimension constrains that dimension.

This method assumes the system is in minimal form.

Definition at line 310 of file Congruence_System.cc.

310  {
311  // Search for a dimension that is free of any congruence or equality
312  // constraint. Assumes a minimized system.
313  std::set<dimension_type> candidates;
314  for (dimension_type i = space_dimension(); i-- > 0; ) {
315  candidates.insert(i + 1);
316  }
317 
318  for (dimension_type i = num_rows(); i-- > 0; ) {
319  rows[i].expression().has_a_free_dimension_helper(candidates);
320  if (candidates.empty()) {
321  return false;
322  }
323  }
324  return !candidates.empty();
325 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
dimension_type num_rows() const
Returns the number of rows in the system.
bool Parma_Polyhedra_Library::Congruence_System::has_linear_equalities ( ) const

Returns true if and only if *this contains one or more linear equalities.

Definition at line 232 of file Congruence_System.cc.

References num_rows().

232  {
233  const Congruence_System& cgs = *this;
234  for (dimension_type i = cgs.num_rows(); i-- > 0; ) {
235  if (cgs[i].modulus() == 0) {
236  return true;
237  }
238  }
239  return false;
240 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
Congruence_System(Representation r=default_representation)
Default constructor: builds an empty system of congruences.
bool Parma_Polyhedra_Library::Congruence_System::has_no_rows ( ) const
inlineprivate

Returns true if num_rows()==0.

Definition at line 42 of file Congruence_System_inlines.hh.

References num_rows().

Referenced by Parma_Polyhedra_Library::Grid::add_recycled_congruences(), and Parma_Polyhedra_Library::Grid::intersection_assign().

42  {
43  return num_rows() == 0;
44 }
dimension_type num_rows() const
Returns the number of rows in the system.
void Parma_Polyhedra_Library::Congruence_System::initialize ( )
static

Initializes the class.

Definition at line 393 of file Congruence_System.cc.

References Parma_Polyhedra_Library::Congruence::zero_dim_false().

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

393  {
394  PPL_ASSERT(zero_dim_empty_p == 0);
397 }
static const Congruence & zero_dim_false()
Returns a reference to the false (zero-dimension space) congruence .
static const Congruence_System * zero_dim_empty_p
Holds (between class initialization and finalization) a pointer to the singleton system containing on...
Congruence_System(Representation r=default_representation)
Default constructor: builds an empty system of congruences.
void Parma_Polyhedra_Library::Congruence_System::insert ( Congruence cg,
Recycle_Input   
)
inline

Inserts in *this the congruence cg, stealing its contents and increasing the number of space dimensions if needed.

cg will be strongly normalized.

Definition at line 59 of file Congruence_System_inlines.hh.

References insert_verbatim(), OK(), Parma_Polyhedra_Library::Congruence::OK(), and Parma_Polyhedra_Library::Congruence::strong_normalize().

59  {
60  PPL_ASSERT(cg.OK());
61  cg.strong_normalize();
62  PPL_ASSERT(cg.OK());
63  insert_verbatim(cg, Recycle_Input());
64  PPL_ASSERT(OK());
65 }
void insert_verbatim(Congruence &cg, Recycle_Input)
Inserts in *this the congruence cg, stealing its contents and increasing the number of space dimensio...
bool OK() const
Checks if all the invariants are satisfied.
void Parma_Polyhedra_Library::Congruence_System::insert ( const Constraint c)

Inserts in *this a copy of the equality constraint c, seen as a modulo 0 congruence, increasing the number of space dimensions if needed.

The modulo 0 congruence will be strongly normalized after being inserted.

Exceptions
std::invalid_argumentThrown if c is a relational constraint.

Definition at line 132 of file Congruence_System.cc.

References Parma_Polyhedra_Library::Constraint::space_dimension(), Parma_Polyhedra_Library::Congruence::strong_normalize(), and Parma_Polyhedra_Library::swap().

132  {
133  if (c.space_dimension() > space_dimension()) {
134  set_space_dimension(c.space_dimension());
135  }
136  Congruence cg(c, space_dimension(), representation());
137  cg.strong_normalize();
138  rows.resize(num_rows() + 1);
139 
140  swap(cg, rows.back());
141 
142  PPL_ASSERT(OK());
143 }
bool set_space_dimension(dimension_type new_space_dim)
Sets the number of space dimensions to new_space_dim.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Representation representation() const
Returns the current representation of *this.
bool OK() const
Checks if all the invariants are satisfied.
void swap(Congruence_System &x, Congruence_System &y)
dimension_type num_rows() const
Returns the number of rows in the system.
Coefficient c
Definition: PIP_Tree.cc:64
void Parma_Polyhedra_Library::Congruence_System::insert ( const Congruence_System y)

Inserts in *this a copy of the congruences in y, increasing the number of space dimensions if needed.

The inserted copies will be strongly normalized.

Definition at line 164 of file Congruence_System.cc.

References num_rows(), rows, space_dimension(), and Parma_Polyhedra_Library::swap().

164  {
165  Congruence_System& x = *this;
166 
167  const dimension_type x_num_rows = x.num_rows();
168  const dimension_type y_num_rows = y.num_rows();
169 
170  // Grow to the required size.
171  if (space_dimension() < y.space_dimension()) {
172  set_space_dimension(y.space_dimension());
173  }
174 
175  rows.resize(rows.size() + y_num_rows);
176 
177  // Copy the rows of `y', with the new space dimension.
178  for (dimension_type i = y_num_rows; i-- > 0; ) {
179  Congruence copy(y[i], space_dimension(), representation());
180  swap(copy, x.rows[x_num_rows+i]);
181  }
182  PPL_ASSERT(OK());
183 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool set_space_dimension(dimension_type new_space_dim)
Sets the number of space dimensions to new_space_dim.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Representation representation() const
Returns the current representation of *this.
bool OK() const
Checks if all the invariants are satisfied.
void swap(Congruence_System &x, Congruence_System &y)
Congruence_System(Representation r=default_representation)
Default constructor: builds an empty system of congruences.
void Parma_Polyhedra_Library::Congruence_System::insert ( Congruence_System cgs,
Recycle_Input   
)

Inserts into *this the congruences in cgs, increasing the number of space dimensions if needed.

Definition at line 146 of file Congruence_System.cc.

References clear(), num_rows(), rows, space_dimension(), and Parma_Polyhedra_Library::swap().

146  {
147  const dimension_type old_num_rows = num_rows();
148  const dimension_type cgs_num_rows = cgs.num_rows();
149  if (space_dimension() < cgs.space_dimension()) {
150  set_space_dimension(cgs.space_dimension());
151  }
152  rows.resize(old_num_rows + cgs_num_rows);
153  for (dimension_type i = cgs_num_rows; i-- > 0; ) {
154  cgs.rows[i].set_space_dimension(space_dimension());
155  cgs.rows[i].set_representation(representation());
156  swap(cgs.rows[i], rows[old_num_rows + i]);
157  }
158  cgs.clear();
159 
160  PPL_ASSERT(OK());
161 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool set_space_dimension(dimension_type new_space_dim)
Sets the number of space dimensions to new_space_dim.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Representation representation() const
Returns the current representation of *this.
bool OK() const
Checks if all the invariants are satisfied.
void swap(Congruence_System &x, Congruence_System &y)
dimension_type num_rows() const
Returns the number of rows in the system.
void Parma_Polyhedra_Library::Congruence_System::insert_verbatim ( Congruence cg,
Recycle_Input   
)
private

Inserts in *this the congruence cg, stealing its contents and increasing the number of space dimensions if needed.

This method inserts cg in the given form, instead of first strong normalizing cg as insert would do.

Definition at line 111 of file Congruence_System.cc.

References Parma_Polyhedra_Library::Congruence::OK(), Parma_Polyhedra_Library::Congruence::set_representation(), Parma_Polyhedra_Library::Congruence::set_space_dimension(), Parma_Polyhedra_Library::Congruence::space_dimension(), and Parma_Polyhedra_Library::swap().

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

111  {
112  // TODO: Remove this.
113  PPL_ASSERT(cg.OK());
114 
115  cg.set_representation(representation());
116 
117  if (cg.space_dimension() >= space_dimension()) {
118  set_space_dimension(cg.space_dimension());
119  }
120  else {
121  cg.set_space_dimension(space_dimension());
122  }
123 
124  rows.resize(num_rows() + 1);
125 
126  swap(cg, rows.back());
127 
128  PPL_ASSERT(OK());
129 }
bool set_space_dimension(dimension_type new_space_dim)
Sets the number of space dimensions to new_space_dim.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Representation representation() const
Returns the current representation of *this.
bool OK() const
Checks if all the invariants are satisfied.
void swap(Congruence_System &x, Congruence_System &y)
dimension_type num_rows() const
Returns the number of rows in the system.
bool Parma_Polyhedra_Library::Congruence_System::is_equal_to ( const Congruence_System y) const

Returns true if and only if *this is exactly equal to y.

Definition at line 227 of file Congruence_System.cc.

227  {
228  return (*this) == cgs;
229 }
void Parma_Polyhedra_Library::Congruence_System::m_swap ( Congruence_System y)
inline

Swaps *this with y.

Definition at line 248 of file Congruence_System_inlines.hh.

References OK(), representation_, rows, space_dimension_, swap(), and Parma_Polyhedra_Library::swap().

Referenced by swap().

248  {
249  using std::swap;
250  swap(rows, y.rows);
251  swap(space_dimension_, y.space_dimension_);
252  swap(representation_, y.representation_);
253  PPL_ASSERT(OK());
254  PPL_ASSERT(y.OK());
255 }
void swap(CO_Tree &x, CO_Tree &y)
bool OK() const
Checks if all the invariants are satisfied.
void swap(Congruence_System &x, Congruence_System &y)
dimension_type Parma_Polyhedra_Library::Congruence_System::max_space_dimension ( )
inlinestatic

Returns the maximum space dimension a Congruence_System can handle.

Definition at line 146 of file Congruence_System_inlines.hh.

References Parma_Polyhedra_Library::Congruence::max_space_dimension().

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

146  {
148 }
static dimension_type max_space_dimension()
Returns the maximum space dimension a Congruence can handle.
void Parma_Polyhedra_Library::Congruence_System::normalize_moduli ( )
private

Adjusts all expressions to have the same moduli.

Definition at line 186 of file Congruence_System.cc.

References Parma_Polyhedra_Library::exact_div_assign(), Parma_Polyhedra_Library::lcm_assign(), num_rows(), and PPL_DIRTY_TEMP_COEFFICIENT.

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

186  {
187  const Congruence_System& cgs = *this;
188  dimension_type row = cgs.num_rows();
189  if (row > 0) {
190  // Calculate the LCM of all the moduli.
192  // Find last proper congruence.
193  while (true) {
194  --row;
195  lcm = cgs[row].modulus();
196  if (lcm > 0) {
197  break;
198  }
199  if (row == 0) {
200  // All rows are equalities.
201  return;
202  }
203  }
204  while (row > 0) {
205  --row;
206  const Coefficient& modulus = cgs[row].modulus();
207  if (modulus > 0) {
208  lcm_assign(lcm, lcm, modulus);
209  }
210  }
211 
212  // Represent every row using the LCM as the modulus.
214  for (row = num_rows(); row-- > 0; ) {
215  const Coefficient& modulus = cgs[row].modulus();
216  if (modulus <= 0 || modulus == lcm) {
217  continue;
218  }
219  exact_div_assign(factor, lcm, modulus);
220  rows[row].scale(factor);
221  }
222  }
223  PPL_ASSERT(OK());
224 }
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 lcm_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
void exact_div_assign(Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, const Checked_Number< T, Policy > &z)
bool OK() const
Checks if all the invariants are satisfied.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
dimension_type num_rows() const
Returns the number of rows in the system.
Congruence_System(Representation r=default_representation)
Default constructor: builds an empty system of congruences.
PPL::dimension_type Parma_Polyhedra_Library::Congruence_System::num_equalities ( ) const

Returns the number of equalities.

Definition at line 251 of file Congruence_System.cc.

Referenced by Parma_Polyhedra_Library::Pointset_Powerset< PSET >::approximate_partition_aux(), Parma_Polyhedra_Library::Grid::congruence_widening_assign(), Parma_Polyhedra_Library::Grid_Certificate::Grid_Certificate(), and Parma_Polyhedra_Library::Grid::quick_equivalence_test().

251  {
252  const Congruence_System& cgs = *this;
253  dimension_type n = 0;
254  for (dimension_type i = num_rows(); i-- > 0 ; ) {
255  if (cgs[i].is_equality()) {
256  ++n;
257  }
258  }
259  return n;
260 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type num_rows() const
Returns the number of rows in the system.
Congruence_System(Representation r=default_representation)
Default constructor: builds an empty system of congruences.
PPL::dimension_type Parma_Polyhedra_Library::Congruence_System::num_proper_congruences ( ) const

Returns the number of proper congruences.

Definition at line 263 of file Congruence_System.cc.

References Parma_Polyhedra_Library::Congruence::is_proper_congruence().

Referenced by Parma_Polyhedra_Library::Pointset_Powerset< PSET >::approximate_partition_aux(), and Parma_Polyhedra_Library::Grid_Certificate::Grid_Certificate().

263  {
264  const Congruence_System& cgs = *this;
265  dimension_type n = 0;
266  for (dimension_type i = num_rows(); i-- > 0 ; ) {
267  const Congruence& cg = cgs[i];
268  if (cg.is_proper_congruence()) {
269  ++n;
270  }
271  }
272  return n;
273 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type num_rows() const
Returns the number of rows in the system.
Congruence_System(Representation r=default_representation)
Default constructor: builds an empty system of congruences.
bool Parma_Polyhedra_Library::Congruence_System::OK ( ) const

Checks if all the invariants are satisfied.

Returns true if and only if all rows have space dimension space_dimension_, each row in the system is a valid Congruence and the space dimension is consistent with the number of congruences.

Definition at line 407 of file Congruence_System.cc.

References Parma_Polyhedra_Library::Congruence::OK(), Parma_Polyhedra_Library::Congruence::representation(), and Parma_Polyhedra_Library::Congruence::space_dimension().

Referenced by Parma_Polyhedra_Library::Grid::construct(), Parma_Polyhedra_Library::Grid::conversion(), insert(), m_swap(), set_representation(), and Parma_Polyhedra_Library::Grid::simplify().

407  {
408  // All rows must have space dimension `space_dimension()'
409  // and representation `representation()'.
410  for (dimension_type i = num_rows(); i-- > 0; ) {
411  const Congruence& cg = rows[i];
412  if (cg.space_dimension() != space_dimension()) {
413  return false;
414  }
415  if (cg.representation() != representation()) {
416  return false;
417  }
418  if (!cg.OK()) {
419  return false;
420  }
421  }
422  // All checks passed.
423  return true;
424 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Representation representation() const
Returns the current representation of *this.
dimension_type num_rows() const
Returns the number of rows in the system.
Congruence_System & Parma_Polyhedra_Library::Congruence_System::operator= ( const Congruence_System y)
inline

Assignment operator.

Definition at line 122 of file Congruence_System_inlines.hh.

References swap().

122  {
123  Congruence_System tmp = y;
124  swap(*this, tmp);
125  return *this;
126 }
void swap(Congruence_System &x, Congruence_System &y)
Congruence_System(Representation r=default_representation)
Default constructor: builds an empty system of congruences.
const Congruence & Parma_Polyhedra_Library::Congruence_System::operator[] ( dimension_type  k) const
inlineprivate

Returns a constant reference to the k- th congruence of the system.

Definition at line 32 of file Congruence_System_inlines.hh.

References rows.

32  {
33  return rows[k];
34 }
void Parma_Polyhedra_Library::Congruence_System::permute_space_dimensions ( const std::vector< Variable > &  cycle)

Permutes the space dimensions of the system.

Parameters
cycleA vector representing a cycle of the permutation according to which the columns must be rearranged.

The cycle vector represents a cycle of a permutation of space dimensions. For example, the permutation $ \{ x_1 \mapsto x_2, x_2 \mapsto x_3, x_3 \mapsto x_1 \}$ can be represented by the vector containing $ x_1, x_2, x_3 $.

Definition at line 56 of file Congruence_System.cc.

References Parma_Polyhedra_Library::Congruence::permute_space_dimensions().

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

56  {
57  for (dimension_type k = rows.size(); k-- > 0; ) {
58  Congruence& rows_k = rows[k];
59  rows_k.permute_space_dimensions(cycle);
60  }
61  PPL_ASSERT(OK());
62 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool OK() const
Checks if all the invariants are satisfied.
void Parma_Polyhedra_Library::Congruence_System::print ( ) const

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

void Parma_Polyhedra_Library::Congruence_System::remove_rows ( dimension_type  first,
dimension_type  last,
bool  keep_sorted 
)
private

Makes the system shrink by removing the rows in [first,last).

If keep_sorted is true, the ordering of the remaining rows will be preserved.

Definition at line 65 of file Congruence_System.cc.

References Parma_Polyhedra_Library::swap().

67  {
68  PPL_ASSERT(first <= last);
69  PPL_ASSERT(last <= num_rows());
70  const dimension_type n = last - first;
71 
72  // Swap the rows in [first, last) with the rows in [size() - n, size())
73  // (note that these intervals may not be disjunct).
74  if (keep_sorted) {
75  for (dimension_type i = last; i < rows.size(); ++i) {
76  swap(rows[i], rows[i - n]);
77  }
78  }
79  else {
80  const dimension_type offset = rows.size() - n - first;
81  for (dimension_type i = first; i < last; ++i) {
82  swap(rows[i], rows[i + offset]);
83  }
84  }
85 
86  rows.resize(rows.size() - n);
87  PPL_ASSERT(OK());
88 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool OK() const
Checks if all the invariants are satisfied.
void swap(Congruence_System &x, Congruence_System &y)
dimension_type num_rows() const
Returns the number of rows in the system.
void Parma_Polyhedra_Library::Congruence_System::remove_trailing_rows ( dimension_type  n)
inlineprivate

Definition at line 47 of file Congruence_System_inlines.hh.

References num_rows(), and rows.

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

47  {
48  PPL_ASSERT(num_rows() >= n);
49  rows.resize(num_rows() - n);
50 }
dimension_type num_rows() const
Returns the number of rows in the system.
Representation Parma_Polyhedra_Library::Congruence_System::representation ( ) const
inline

Returns the current representation of *this.

Definition at line 129 of file Congruence_System_inlines.hh.

References representation_.

Referenced by Congruence_System().

129  {
130  return representation_;
131 }
bool Parma_Polyhedra_Library::Congruence_System::satisfies_all_congruences ( const Grid_Generator g) const
protected

Returns true if g satisfies all the congruences.

Definition at line 277 of file Congruence_System.cc.

References Parma_Polyhedra_Library::Scalar_Products::assign(), Parma_Polyhedra_Library::Grid_Generator::divisor(), Parma_Polyhedra_Library::Congruence::is_equality(), Parma_Polyhedra_Library::Grid_Generator::is_line(), Parma_Polyhedra_Library::Congruence::modulus(), PPL_DIRTY_TEMP_COEFFICIENT, and Parma_Polyhedra_Library::Grid_Generator::space_dimension().

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

277  {
278  PPL_ASSERT(g.space_dimension() <= space_dimension());
279 
280  const Congruence_System& cgs = *this;
282  if (g.is_line()) {
283  for (dimension_type i = cgs.num_rows(); i-- > 0; ) {
284  const Congruence& cg = cgs[i];
285  Scalar_Products::assign(sp, g, cg);
286  if (sp != 0) {
287  return false;
288  }
289  }
290  }
291  else {
292  const Coefficient& divisor = g.divisor();
293  for (dimension_type i = cgs.num_rows(); i-- > 0; ) {
294  const Congruence& cg = cgs[i];
295  Scalar_Products::assign(sp, g, cg);
296  if (cg.is_equality()) {
297  if (sp != 0) {
298  return false;
299  }
300  }
301  else if (sp % (cg.modulus() * divisor) != 0) {
302  return false;
303  }
304  }
305  }
306  return true;
307 }
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...
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
static void assign(Coefficient &z, const Linear_Expression &x, const Linear_Expression &y)
Computes the scalar product of x and y and assigns it to z.
Congruence_System(Representation r=default_representation)
Default constructor: builds an empty system of congruences.
void Parma_Polyhedra_Library::Congruence_System::set_representation ( Representation  r)
inline

Converts *this to the specified representation.

Definition at line 134 of file Congruence_System_inlines.hh.

References num_rows(), OK(), representation_, and rows.

134  {
135  if (representation_ == r) {
136  return;
137  }
138  representation_ = r;
139  for (dimension_type i = 0; i < num_rows(); ++i) {
140  rows[i].set_representation(r);
141  }
142  PPL_ASSERT(OK());
143 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool OK() const
Checks if all the invariants are satisfied.
dimension_type num_rows() const
Returns the number of rows in the system.
bool Parma_Polyhedra_Library::Congruence_System::set_space_dimension ( dimension_type  new_space_dim)

Sets the number of space dimensions to new_space_dim.

If new_space_dim is lower than the current space dimension, the coefficients referring to the removed space dimensions are lost.

Definition at line 92 of file Congruence_System.cc.

Referenced by Parma_Polyhedra_Library::Grid::add_space_dimensions(), Parma_Polyhedra_Library::Grid::construct(), Parma_Polyhedra_Library::Grid::conversion(), Parma_Polyhedra_Library::Grid::Grid(), Parma_Polyhedra_Library::Grid::remove_higher_space_dimensions(), and Parma_Polyhedra_Library::Grid::set_empty().

92  {
93  if (space_dimension() != new_space_dim) {
94  space_dimension_ = new_space_dim;
95  for (dimension_type i = num_rows(); i-- > 0; ) {
96  rows[i].set_space_dimension(new_space_dim);
97  }
98  }
99  PPL_ASSERT(OK());
100  return true;
101 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
bool OK() const
Checks if all the invariants are satisfied.
dimension_type num_rows() const
Returns the number of rows in the system.
dimension_type Parma_Polyhedra_Library::Congruence_System::space_dimension ( ) const
inline

Returns the dimension of the vector space enclosing *this.

Definition at line 151 of file Congruence_System_inlines.hh.

References space_dimension_.

Referenced by Parma_Polyhedra_Library::Box< ITV >::add_congruences(), Parma_Polyhedra_Library::Polyhedron::add_congruences(), Parma_Polyhedra_Library::Grid::add_congruences(), Parma_Polyhedra_Library::Box< ITV >::add_congruences_no_check(), Parma_Polyhedra_Library::Grid::add_recycled_congruences(), Parma_Polyhedra_Library::Grid::add_space_dimensions(), ascii_dump(), Parma_Polyhedra_Library::Box< ITV >::Box(), concatenate(), Parma_Polyhedra_Library::Grid::construct(), Parma_Polyhedra_Library::Grid::conversion(), insert(), Parma_Polyhedra_Library::Grid::limited_congruence_extrapolation_assign(), Parma_Polyhedra_Library::Grid::limited_extrapolation_assign(), Parma_Polyhedra_Library::Grid::limited_generator_extrapolation_assign(), Parma_Polyhedra_Library::Grid::lower_triangular(), Parma_Polyhedra_Library::Octagonal_Shape< T >::Octagonal_Shape(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Box< ITV >::refine_with_congruences(), Parma_Polyhedra_Library::Polyhedron::refine_with_congruences(), Parma_Polyhedra_Library::BD_Shape< T >::refine_with_congruences(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_with_congruences(), Parma_Polyhedra_Library::Grid::select_wider_congruences(), Parma_Polyhedra_Library::Grid::simplify(), Parma_Polyhedra_Library::Box< ITV >::throw_dimension_incompatible(), Parma_Polyhedra_Library::Grid::throw_dimension_incompatible(), and Parma_Polyhedra_Library::Polyhedron::throw_dimension_incompatible().

151  {
152  return space_dimension_;
153 }
void Parma_Polyhedra_Library::Congruence_System::swap_space_dimensions ( Variable  v1,
Variable  v2 
)

Swaps the columns having indexes i and j.

Definition at line 104 of file Congruence_System.cc.

104  {
105  for (dimension_type k = num_rows(); k-- > 0; ) {
106  rows[k].swap_space_dimensions(v1, v2);
107  }
108 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type num_rows() const
Returns the number of rows in the system.
memory_size_type Parma_Polyhedra_Library::Congruence_System::total_memory_in_bytes ( ) const
inline

Returns the total size in bytes of the memory occupied by *this.

Definition at line 263 of file Congruence_System_inlines.hh.

References rows.

263  {
264  return rows.external_memory_in_bytes() + sizeof(*this);
265 }
const Congruence_System & Parma_Polyhedra_Library::Congruence_System::zero_dim_empty ( )
inlinestatic

Returns the system containing only Congruence::zero_dim_false().

Definition at line 162 of file Congruence_System_inlines.hh.

References zero_dim_empty_p.

Referenced by Parma_Polyhedra_Library::Box< ITV >::congruences(), Parma_Polyhedra_Library::BD_Shape< T >::minimized_congruences(), and Parma_Polyhedra_Library::Octagonal_Shape< T >::minimized_congruences().

162  {
163  PPL_ASSERT(zero_dim_empty_p != 0);
164  return *zero_dim_empty_p;
165 }
static const Congruence_System * zero_dim_empty_p
Holds (between class initialization and finalization) a pointer to the singleton system containing on...

Friends And Related Function Documentation

friend class Grid
friend

Definition at line 516 of file Congruence_System_defs.hh.

std::ostream & operator<< ( std::ostream &  s,
const Congruence_System cgs 
)
related

Definition at line 428 of file Congruence_System.cc.

References begin(), end(), and Parma_Polyhedra_Library::Congruence::strong_normalize().

428  {
429  Congruence_System::const_iterator i = cgs.begin();
430  const Congruence_System::const_iterator cgs_end = cgs.end();
431  if (i == cgs_end) {
432  return s << "true";
433  }
434  while (true) {
435  Congruence cg = *i;
436  cg.strong_normalize();
437  s << cg;
438  ++i;
439  if (i == cgs_end) {
440  return s;
441  }
442  s << ", ";
443  }
444 }
std::ostream & operator<< ( std::ostream &  s,
const Congruence_System cgs 
)
related

Output operator.

Writes true if cgs is empty. Otherwise, writes on s the congruences of cgs, all in one row and separated by ", ".

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

Definition at line 448 of file Congruence_System.cc.

References num_rows().

448  {
449  if (x.num_rows() != y.num_rows()) {
450  return false;
451  }
452  for (dimension_type i = x.num_rows(); i-- > 0; ) {
453  // NOTE: this also checks for space dimension.
454  if (x[i] != y[i]) {
455  return false;
456  }
457  }
458  return true;
459 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool operator== ( const Congruence_System x,
const Congruence_System y 
)
friend
void swap ( Congruence_System x,
Congruence_System y 
)
related

Definition at line 269 of file Congruence_System_inlines.hh.

References m_swap().

269  {
270  x.m_swap(y);
271 }
void swap ( Congruence_System x,
Congruence_System y 
)
related

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

Member Data Documentation

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

Definition at line 108 of file Congruence_System_defs.hh.

Representation Parma_Polyhedra_Library::Congruence_System::representation_
private

Definition at line 503 of file Congruence_System_defs.hh.

Referenced by m_swap(), representation(), and set_representation().

dimension_type Parma_Polyhedra_Library::Congruence_System::space_dimension_
private

Definition at line 501 of file Congruence_System_defs.hh.

Referenced by clear(), m_swap(), and space_dimension().

const PPL::Congruence_System * Parma_Polyhedra_Library::Congruence_System::zero_dim_empty_p = 0
staticprivate

Holds (between class initialization and finalization) a pointer to the singleton system containing only Congruence::zero_dim_false().

Definition at line 497 of file Congruence_System_defs.hh.

Referenced by zero_dim_empty().


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