24 #include "ppl-config.h"
33 #include "assertions.hh"
44 space_dimension_(cs.space_dimension()),
47 cs_end = cs.
end(); i != cs_end; ++i) {
48 if (i->is_equality()) {
68 PPL_ASSERT(first <= last);
69 PPL_ASSERT(last <= num_rows());
76 swap(rows[i], rows[i - n]);
82 swap(rows[i], rows[i + offset]);
86 rows.resize(rows.size() - n);
93 if (space_dimension() != new_space_dim) {
94 space_dimension_ = new_space_dim;
96 rows[i].set_space_dimension(new_space_dim);
106 rows[k].swap_space_dimensions(v1, v2);
124 rows.resize(num_rows() + 1);
126 swap(cg, rows.back());
136 Congruence cg(c, space_dimension(), representation());
138 rows.resize(num_rows() + 1);
140 swap(cg, rows.back());
152 rows.resize(old_num_rows + cgs_num_rows);
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]);
175 rows.resize(rows.size() + y_num_rows);
179 Congruence copy(y[i], space_dimension(), representation());
195 lcm = cgs[row].modulus();
214 for (row = num_rows(); row-- > 0; ) {
216 if (modulus <= 0 || modulus == lcm) {
220 rows[row].scale(factor);
228 return (*
this) == cgs;
235 if (cgs[i].modulus() == 0) {
243 PPL::Congruence_System::const_iterator::skip_forward() {
245 while (i != csp_end && (*this)->is_tautological()) {
255 if (cgs[i].is_equality()) {
301 else if (sp % (cg.
modulus() * divisor) != 0) {
313 std::set<dimension_type> candidates;
315 candidates.insert(i + 1);
319 rows[i].expression().has_a_free_dimension_helper(candidates);
320 if (candidates.empty()) {
324 return !candidates.empty();
331 Coefficient_traits::const_reference denominator) {
334 PPL_ASSERT(denominator > 0);
337 rows[i].affine_preimage(v, expr, denominator);
346 s << x_num_rows <<
" x " << x_space_dim <<
" ";
361 if (!(s >> num_rows)) {
364 if (!(s >> str) || str !=
"x") {
367 if (!(s >> space_dim)) {
371 space_dimension_ = space_dim;
394 PPL_ASSERT(zero_dim_empty_p == 0);
401 PPL_ASSERT(zero_dim_empty_p != 0);
402 delete zero_dim_empty_p;
403 zero_dim_empty_p = 0;
465 set_space_dimension(space_dimension() + dims);
467 rows.resize(rows.size() + dims);
471 swap(rows[row], rows[row + dims]);
479 PPL_ASSERT(dim >= row + 1);
500 set_space_dimension(space_dimension() + added_columns);
502 rows.resize(rows.size() + added_rows);
511 swap(cg_old, cg_new);
An iterator over a system of constraints.
void swap_space_dimensions(Variable v1, Variable v2)
Swaps the columns having indexes i and j.
Coefficient_traits::const_reference modulus() const
Returns a const reference to the modulus of *this.
A linear equality or inequality.
void swap(CO_Tree &x, CO_Tree &y)
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
size_t dimension_type
An unsigned integral type for representing space dimensions.
void insert(const Congruence &cg)
Inserts in *this a copy of the congruence cg, increasing the number of space dimensions if needed...
bool is_line() const
Returns true if and only if *this is a line.
#define PPL_DIRTY_TEMP_COEFFICIENT(id)
Declare a local variable named id, of type Coefficient, and containing an unknown initial value...
Enable_If< Is_Native_Or_Checked< T >::value, void >::type ascii_dump(std::ostream &s, const T &t)
void strong_normalize()
Calls normalize, then divides out common factors.
void concatenate(const Congruence_System &y)
Concatenates copies of the congruences from y onto *this.
bool set_space_dimension(dimension_type new_space_dim)
Sets the number of space dimensions to new_space_dim.
std::ostream & operator<<(std::ostream &s, const Ask_Tell< D > &x)
const_iterator end() const
Returns the past-the-end const_iterator.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
The standard C++ namespace.
void lcm_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
dimension_type num_equalities() const
Returns the number of equalities.
void insert_verbatim(Congruence &cg, Recycle_Input)
Inserts in *this the congruence cg, stealing its contents and increasing the number of space dimensio...
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
const_iterator begin() const
Returns the const_iterator pointing to the first constraint, if *this is not empty; otherwise...
void exact_div_assign(Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, const Checked_Number< T, Policy > &z)
void normalize_moduli()
Adjusts all expressions to have the same moduli.
bool is_proper_congruence() const
Returns true if the modulus is greater than zero.
void set_representation(Representation r)
Converts *this to the specified representation.
static const Congruence & zero_dim_false()
Returns a reference to the false (zero-dimension space) congruence .
A dimension of the vector space.
void ascii_dump() const
Writes to std::cerr an ASCII representation of *this.
bool satisfies_all_congruences(const Grid_Generator &g) const
Returns true if g satisfies all the congruences.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
bool OK() const
Checks if all the invariants are satisfied.
Swapping_Vector< Congruence > rows
static void initialize()
Initializes the class.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Coefficient_traits::const_reference divisor() const
Returns the divisor of *this.
bool is_equality() const
Returns true if *this is an equality.
const_iterator end() const
Returns the past-the-end const_iterator.
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_proper_congruences() const
Returns the number of proper congruences.
const_iterator begin() const
Returns the const_iterator pointing to the first congruence, if this is not empty; otherwise...
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
bool has_linear_equalities() const
Returns true if and only if *this contains one or more linear equalities.
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.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void permute_space_dimensions(const std::vector< Variable > &cycles)
void permute_space_dimensions(const std::vector< Variable > &cycle)
Permutes the space dimensions of the system.
static const Congruence_System * zero_dim_empty_p
Holds (between class initialization and finalization) a pointer to the singleton system containing on...
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
#define PPL_OUTPUT_DEFINITIONS(class_name)
The entire library is confined to this namespace.
An iterator over a system of congruences.
dimension_type num_rows() const
Returns the number of rows in the system.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
bool has_a_free_dimension() const
Returns true if and only if any of the dimensions in *this is free of constraint. ...
std::vector< T >::const_iterator const_iterator
bool is_equal_to(const Congruence_System &y) const
Returns true if and only if *this is exactly equal to y.
Representation representation() const
Returns the current representation of *this.
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
bool ascii_load(std::istream &s)
Loads from s an ASCII representation of the internal representation of *this.
void shift_space_dimensions(Variable v, dimension_type n)
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 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 co...
void remove_rows(dimension_type first, dimension_type last, bool keep_sorted)
Makes the system shrink by removing the rows in [first,last).
void set_space_dimension(dimension_type n)
A grid line, parameter or grid point.
void clear()
Removes all the congruences and sets the space dimension to 0.
static void finalize()
Finalizes the class.