25 #include "ppl-config.h"
28 #include "assertions.hh"
63 normalize_divisors(gs);
86 "add_space_dimensions_and_embed(m)",
87 "adding m new space dimensions exceeds "
88 "the maximum allowed space dimension");
100 if (space_dim == 0) {
102 PPL_ASSERT(status.test_zero_dim_univ());
116 if (congruences_are_up_to_date()) {
117 if (generators_are_up_to_date()) {
119 add_space_dimensions(con_sys, gen_sys, m);
123 con_sys.set_space_dimension(con_sys.space_dimension() + m);
124 if (congruences_are_minimized()) {
125 dim_kinds.resize(con_sys.space_dimension() + 1, CON_VIRTUAL);
131 PPL_ASSERT(generators_are_up_to_date());
132 gen_sys.add_universe_rows_and_columns(m);
133 if (generators_are_minimized()) {
134 dim_kinds.resize(gen_sys.space_dimension() + 1, LINE);
163 "add_space_dimensions_and_project(m)",
164 "adding m new space dimensions exceeds "
165 "the maximum allowed space dimension");
169 if (marked_empty()) {
175 if (space_dim == 0) {
176 PPL_ASSERT(status.test_zero_dim_univ());
190 if (congruences_are_up_to_date()) {
191 if (generators_are_up_to_date()) {
193 add_space_dimensions(gen_sys, con_sys, m);
197 con_sys.add_unit_rows_and_space_dimensions(m);
198 if (congruences_are_minimized()) {
199 dim_kinds.resize(con_sys.space_dimension() + 1, EQUALITY);
205 PPL_ASSERT(generators_are_up_to_date());
208 gen_sys.set_space_dimension(space_dim + m);
210 normalize_divisors(gen_sys);
212 if (generators_are_minimized()) {
213 dim_kinds.resize(gen_sys.space_dimension() + 1, EQUALITY);
231 "concatenate_assign(y)",
232 "concatenation exceeds the maximum "
233 "allowed space dimension");
240 space_dim += added_columns;
246 if (added_columns == 0) {
251 if (space_dim == 0) {
256 if (!congruences_are_up_to_date()) {
257 update_congruences();
262 space_dim += added_columns;
264 clear_congruences_minimized();
265 clear_generators_up_to_date();
284 if (space_dim < min_space_dim) {
285 throw_dimension_incompatible(
"remove_space_dimensions(vs)", min_space_dim);
291 || (!generators_are_up_to_date() && !update_generators())) {
293 space_dim = new_space_dim;
301 if (new_space_dim == 0) {
306 gen_sys.remove_space_dimensions(vars);
308 clear_congruences_up_to_date();
309 clear_generators_minimized();
312 space_dim = new_space_dim;
314 PPL_ASSERT(OK(
true));
320 if (new_dimension > space_dim) {
321 throw_dimension_incompatible(
"remove_higher_space_dimensions(nd)",
327 if (new_dimension == space_dim) {
335 space_dim = new_dimension;
341 if (new_dimension == 0) {
349 if (generators_are_up_to_date()) {
350 gen_sys.set_space_dimension(new_dimension);
351 if (generators_are_minimized()) {
356 if (dim_kinds[row] != GEN_VIRTUAL) {
360 if (num_redundant > 0) {
362 gen_sys.remove_trailing_rows(num_redundant);
363 gen_sys.unset_pending_rows();
365 dim_kinds.resize(new_dimension + 1);
369 clear_congruences_up_to_date();
378 PPL_ASSERT(congruences_are_minimized());
379 con_sys.set_space_dimension(new_dimension);
382 for (
dimension_type row = space_dim; row > new_dimension; --row) {
383 if (dim_kinds[row] != CON_VIRTUAL) {
388 con_sys.remove_rows(0, num_redundant,
true);
389 dim_kinds.erase(dim_kinds.begin() + (new_dimension + 1),
392 clear_generators_up_to_date();
400 space_dim = new_dimension;
402 PPL_ASSERT(OK(
true));
409 throw_dimension_incompatible(
"expand_space_dimension(v, m)",
"v", var);
420 "expand_space_dimension(v, m)",
421 "adding m new space dimensions exceeds "
422 "the maximum allowed space dimension");
428 add_space_dimensions_and_embed(m);
433 cgs_end = cgs.
end(); i != cgs_end; ++i) {
436 Coefficient_traits::const_reference coeff = cg.
coefficient(var);
447 for (
dimension_type dst_d = old_dim; dst_d < old_dim+m; ++dst_d) {
453 add_recycled_congruences(new_congruences);
463 throw_dimension_incompatible(
"fold_space_dimensions(vs, v)",
"v", dest);
473 throw_dimension_incompatible(
"fold_space_dimensions(vs, v)",
474 "vs.space_dimension()",
479 if (vars.find(dest.
id()) != vars.end()) {
480 throw_invalid_argument(
"fold_space_dimensions(vs, v)",
481 "v should not occur in vs");
487 (void) grid_generators();
490 if (!marked_empty()) {
491 for (Variables_Set::const_iterator i = vars.begin(),
492 vs_end = vars.end(); i != vs_end; ++i) {
498 remove_space_dimensions(vars);
void add_space_dimensions(Congruence_System &cgs, Grid_Generator_System &gs, dimension_type dims)
Adds new space dimensions to the given systems.
void add_space_dimensions_and_embed(dimension_type m)
Adds m new space dimensions and embeds the old grid in the new vector space.
dimension_type space_dimension() const
Returns the dimension of the smallest vector space enclosing all the variables whose indexes are in t...
void expand_space_dimension(Variable var, dimension_type m)
Creates m copies of the space dimension corresponding to var.
dimension_type max_space_dimension()
Returns the maximum space dimension this library can handle.
void swap(CO_Tree &x, CO_Tree &y)
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void remove_higher_space_dimensions(dimension_type new_dimension)
Removes the higher dimensions of the vector space so that the resulting space will have dimension new...
size_t dimension_type
An unsigned integral type for representing space dimensions.
An std::set of variables' indexes.
const Congruence_System & congruences() const
Returns the system of congruences.
bool set_space_dimension(dimension_type new_space_dim)
Sets the number of space dimensions to new_space_dim.
void add_mul_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
const_iterator end() const
Returns the past-the-end const_iterator.
void add_universe_rows_and_columns(dimension_type dims)
Adds dims rows and dims columns of zeroes to the matrix, initializing the added rows as in the univer...
void insert_verbatim(Congruence &cg, Recycle_Input)
Inserts in *this the congruence cg, stealing its contents and increasing the number of space dimensio...
void set_coefficient(Variable v, Coefficient_traits::const_reference n)
Sets the coefficient of v in *this to n.
void set_space_dimension(dimension_type space_dim)
Resizes the system to the specified space dimension.
dimension_type id() const
Returns the index of the Cartesian axis associated to the variable.
static const Congruence & zero_dim_false()
Returns a reference to the false (zero-dimension space) congruence .
A dimension of the vector space.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the vector space.
dimension_type check_space_dimension_overflow(const dimension_type dim, const dimension_type max, const char *domain, const char *method, const char *reason)
const_iterator begin() const
Returns the const_iterator pointing to the first congruence, if this is not empty; otherwise...
The universe element, i.e., the whole vector space.
dimension_type space_dim
The number of dimensions of the enclosing vector space.
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
The entire library is confined to this namespace.
An iterator over a system of congruences.
void fold_space_dimensions(const Variables_Set &vars, Variable dest)
Folds the space dimensions in vars into dest.
bool marked_empty() const
Returns true if the grid is known to be empty.
bool congruences_are_minimized() const
Returns true if the system of congruences is minimized.
Dimension_Kinds dim_kinds
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void add_space_dimensions_and_project(dimension_type m)
Adds m new space dimensions to the grid and does not embed it in the new vector space.
void upper_bound_assign(std::map< dimension_type, Linear_Form< FP_Interval_Type > > &ls1, const std::map< dimension_type, Linear_Form< FP_Interval_Type > > &ls2)
Coefficient_traits::const_reference coefficient(Variable v) const
Returns the coefficient of v in *this.
bool generators_are_minimized() const
Returns true if the system of generators is minimized.
void concatenate_assign(const Grid &y)
Assigns to *this the concatenation of *this and y, taken in this order.
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 affine_image(Variable var, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one())
Assigns to *this the affine image of this under the function mapping variable var to the affine expre...
A system of grid generators.