25 #include "ppl-config.h"
28 #include "assertions.hh"
40 "add_space_dimensions_and_embed(m)",
41 "adding m new space dimensions exceeds "
42 "the maximum allowed space dimension");
103 PPL_ASSERT_HEAVY(
OK());
112 "add_space_dimensions_and_project(m)",
113 "adding m new space dimensions exceeds "
114 "the maximum allowed space dimension");
123 if (marked_empty()) {
129 if (space_dim == 0) {
130 PPL_ASSERT(status.test_zero_dim_univ() && gen_sys.has_no_rows());
136 if (!is_necessarily_closed()) {
140 gen_sys.adjust_topology_and_space_dimension(topology(), m);
141 set_generators_minimized();
143 PPL_ASSERT_HEAVY(OK());
154 if (constraints_are_up_to_date()) {
155 if (generators_are_up_to_date()) {
157 if (!sat_g_is_up_to_date()) {
163 add_space_dimensions(gen_sys, con_sys, sat_g, sat_c, m);
167 con_sys.add_universe_rows_and_space_dimensions(m);
172 PPL_ASSERT(generators_are_up_to_date());
173 gen_sys.set_space_dimension(gen_sys.space_dimension() + m);
180 PPL_ASSERT_HEAVY(OK());
186 throw_topology_incompatible(
"concatenate_assign(y)",
"y", y);
195 "concatenate_assign(y)",
196 "concatenation exceeds the maximum "
197 "allowed space dimension");
202 space_dim += added_columns;
208 if (added_columns == 0) {
213 if (space_dim == 0) {
222 if (has_pending_generators()) {
223 process_pending_generators();
225 else if (!constraints_are_up_to_date()) {
226 update_constraints();
237 PPL_ASSERT(added_rows > 0 && added_columns > 0);
239 con_sys.set_space_dimension(con_sys.space_dimension() + added_columns);
241 if (can_have_something_pending()) {
245 cs.
sys.rows[i].shift_space_dimensions(
Variable(0), space_dim);
255 gen_sys.add_universe_rows_and_space_dimensions(added_columns);
260 if (!sat_c_is_up_to_date()) {
261 sat_c.transpose_assign(sat_g);
262 set_sat_c_up_to_date();
264 clear_sat_g_up_to_date();
265 sat_c.resize(sat_c.num_rows() + added_columns, sat_c.num_columns());
272 swap(sat_c[i], sat_c[i+added_columns]);
275 set_constraints_pending();
281 cs.
sys.rows[i].shift_space_dimensions(
Variable(0), space_dim);
287 clear_constraints_minimized();
288 clear_generators_up_to_date();
289 clear_sat_g_up_to_date();
290 clear_sat_c_up_to_date();
293 space_dim += added_columns;
297 PPL_ASSERT_HEAVY(OK());
306 PPL_ASSERT_HEAVY(OK());
312 if (space_dim < min_space_dim) {
313 throw_dimension_incompatible(
"remove_space_dimensions(vs)", min_space_dim);
321 || (has_something_pending() && !remove_pending_to_obtain_generators())
322 || (!generators_are_up_to_date() && !update_generators())) {
328 space_dim = new_space_dim;
329 PPL_ASSERT_HEAVY(OK());
335 if (new_space_dim == 0) {
340 gen_sys.remove_space_dimensions(vars);
343 clear_constraints_up_to_date();
344 clear_generators_minimized();
347 space_dim = new_space_dim;
349 PPL_ASSERT_HEAVY(OK(
true));
355 if (new_dimension > space_dim) {
356 throw_dimension_incompatible(
"remove_higher_space_dimensions(nd)",
363 if (new_dimension == space_dim) {
364 PPL_ASSERT_HEAVY(OK());
371 || (has_something_pending() && !remove_pending_to_obtain_generators())
372 || (!generators_are_up_to_date() && !update_generators())) {
375 space_dim = new_dimension;
377 PPL_ASSERT_HEAVY(OK());
381 if (new_dimension == 0) {
388 gen_sys.set_space_dimension(new_dimension);
391 clear_constraints_up_to_date();
392 clear_generators_minimized();
395 space_dim = new_dimension;
397 PPL_ASSERT_HEAVY(OK(
true));
404 throw_dimension_incompatible(
"expand_space_dimension(v, m)",
"v", var);
411 "expand_dimension(v, m)",
412 "adding m new space dimensions exceeds "
413 "the maximum allowed space dimension");
424 add_space_dimensions_and_embed(m);
429 cs_end = cs.
end(); i != cs_end; ++i) {
432 Coefficient_traits::const_reference coeff = c.
coefficient(var);
443 for (
dimension_type dst_d = old_dim; dst_d < old_dim+m; ++dst_d) {
446 PPL_ASSERT(new_c.
OK());
450 add_recycled_constraints(new_constraints);
451 PPL_ASSERT_HEAVY(OK());
461 throw_dimension_incompatible(
"fold_space_dimensions(vs, v)",
"v", dest);
471 throw_dimension_incompatible(
"fold_space_dimensions(vs, v)",
472 "vs.space_dimension()",
477 if (vars.find(dest.
id()) != vars.end()) {
478 throw_invalid_argument(
"fold_space_dimensions(vs, v)",
479 "v should not occur in vs");
489 if (!marked_empty()) {
490 for (Variables_Set::const_iterator i = vars.begin(),
491 vs_end = vars.end(); i != vs_end; ++i) {
494 poly_hull_assign(copy);
497 remove_space_dimensions(vars);
498 PPL_ASSERT_HEAVY(OK());
void add_space_dimensions_and_embed(dimension_type m)
Adds m new space dimensions and embeds the old polyhedron in the new vector space.
An iterator over a system of constraints.
dimension_type space_dimension() const
Returns the dimension of the smallest vector space enclosing all the variables whose indexes are in t...
bool marked_empty() const
Returns true if the polyhedron is known to be empty.
dimension_type max_space_dimension()
Returns the maximum space dimension this library can handle.
A linear equality or inequality.
void swap(CO_Tree &x, CO_Tree &y)
size_t dimension_type
An unsigned integral type for representing space dimensions.
void set_space_dimension(dimension_type space_dim)
Sets the space dimension of the rows in the system to space_dim .
An std::set of variables' indexes.
Generator_System gen_sys
The system of generators.
void add_universe_rows_and_space_dimensions(dimension_type n)
Adds n rows and space dimensions to the system.
static const Generator & zero_dim_point()
Returns the origin of the zero-dimensional space .
void add_mul_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
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 expr...
bool sat_c_is_up_to_date() const
Returns true if the saturation matrix sat_c is up-to-date.
void add_space_dimensions_and_project(dimension_type m)
Adds m new space dimensions to the polyhedron and does not embed it in the new vector space...
void remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the vector space.
Topology topology() const
Returns the system topology.
void clear()
Removes all the constraints from the constraint system and sets its space dimension to 0...
const Constraint_System & constraints() const
Returns the system of constraints.
void set_coefficient(Variable v, Coefficient_traits::const_reference n)
Sets the coefficient of v in *this to n.
const_iterator begin() const
Returns the const_iterator pointing to the first constraint, if *this is not empty; otherwise...
Coefficient_traits::const_reference coefficient(Variable v) const
Returns the coefficient of v in *this.
bool test_zero_dim_univ() const
dimension_type id() const
Returns the index of the Cartesian axis associated to the variable.
A dimension of the vector space.
The base class for convex polyhedra.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Topology topology() const
Returns the topological kind of the polyhedron.
bool generators_are_up_to_date() const
Returns true if the system of generators is up-to-date.
Constraint_System con_sys
The system of constraints.
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...
static dimension_type check_space_dimension_overflow(dimension_type dim, dimension_type max, const Topology topol, const char *method, const char *reason)
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
bool constraints_are_up_to_date() const
Returns true if the system of constraints is up-to-date.
dimension_type check_space_dimension_overflow(const dimension_type dim, const dimension_type max, const char *domain, const char *method, const char *reason)
Bit_Matrix sat_g
The saturation matrix having generators on its columns.
const_iterator end() const
Returns the past-the-end const_iterator.
static dimension_type max_space_dimension()
Returns the maximum space dimension all kinds of Polyhedron can handle.
Status status
The status flags to keep track of the polyhedron's internal state.
static const Generator & zero_dim_closure_point()
Returns, as a closure point, the origin of the zero-dimensional space .
The universe element, i.e., the whole 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.
dimension_type space_dim
The number of dimensions of the enclosing vector space.
Linear_System< Constraint > sys
void fold_space_dimensions(const Variables_Set &vars, Variable dest)
Folds the space dimensions in vars into dest.
bool OK(bool check_not_empty=false) const
Checks if all the invariants are satisfied.
void expand_space_dimension(Variable var, dimension_type m)
Creates m copies of the space dimension corresponding to var.
bool OK() const
Checks if all the invariants are satisfied.
void concatenate_assign(const Polyhedron &y)
Assigns to *this the concatenation of *this and y, taken in this order.
void update_sat_c() const
Updates sat_c using the updated constraints and generators.
Bit_Matrix sat_c
The saturation matrix having constraints on its columns.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
dimension_type num_rows() const
static void add_space_dimensions(Linear_System1 &sys1, Linear_System2 &sys2, Bit_Matrix &sat1, Bit_Matrix &sat2, dimension_type add_dim)
Adds new space dimensions to the given linear systems.
void m_swap(Polyhedron &y)
Swaps *this with polyhedron y. (*this and y can be dimension-incompatible.)