PPL  1.2
C_Polyhedron.cc
Go to the documentation of this file.
1 /* C_Polyhedron class implementation (non-inline functions).
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #include "ppl-config.h"
25 #include "C_Polyhedron_defs.hh"
26 #include "NNC_Polyhedron_defs.hh"
27 #include "Grid_defs.hh"
28 #include "algorithms.hh"
29 
30 namespace PPL = Parma_Polyhedra_Library;
31 
33  : Polyhedron(NECESSARILY_CLOSED, y.space_dimension(), UNIVERSE) {
34  const Constraint_System& cs = y.constraints();
36  cs_end = cs.end(); i != cs_end; ++i) {
37  const Constraint& c = *i;
38  if (c.is_strict_inequality()) {
39  const Linear_Expression expr(c.expression());
40  add_constraint(expr >= 0);
41  }
42  else {
43  add_constraint(c);
44  }
45  }
46  PPL_ASSERT_HEAVY(OK());
47 }
48 
51  check_space_dimension_overflow(cgs.space_dimension(),
53  "C_Polyhedron(cgs)",
54  "the space dimension of cgs "
55  "exceeds the maximum allowed "
56  "space dimension"),
57  UNIVERSE) {
58  add_congruences(cgs);
59 }
60 
63  check_space_dimension_overflow(cgs.space_dimension(),
65  "C_Polyhedron(cgs, recycle)",
66  "the space dimension of cgs "
67  "exceeds the maximum allowed "
68  "space dimension"),
69  UNIVERSE) {
70  add_congruences(cgs);
71 }
72 
75  check_space_dimension_overflow(grid.space_dimension(),
77  "C_Polyhedron(grid)",
78  "the space dimension of grid "
79  "exceeds the maximum allowed "
80  "space dimension"),
81  UNIVERSE) {
83 }
84 
85 bool
87  // Dimension-compatibility check.
88  if (space_dimension() != y.space_dimension()) {
89  throw_dimension_incompatible("poly_hull_assign_if_exact(y)", "y", y);
90  }
91 #define USE_BHZ09 0
92 #define USE_BFT00 1
93 #if USE_BHZ09 // [BagnaraHZ09]
94  return BHZ09_poly_hull_assign_if_exact(y);
95 #elif USE_BFT00 // [BemporadFT00TR].
96  return BFT00_poly_hull_assign_if_exact(y);
97 #else // Old implementation.
98  return PPL::poly_hull_assign_if_exact(*this, y);
99 #endif
100 #undef USE_BHZ09
101 #undef USE_BFT00
102 }
103 
104 
105 void
107  NNC_Polyhedron nnc_this(*this);
108  nnc_this.positive_time_elapse_assign(y);
109  *this = nnc_this;
110 }
111 
A linear equality or inequality.
C_Polyhedron(dimension_type num_dimensions=0, Degenerate_Element kind=UNIVERSE)
Builds either the universe or the empty C polyhedron.
void add_congruences(const Congruence_System &cgs)
Adds a copy of the congruences in cgs to *this, if all the congruences can be exactly represented by ...
void add_constraint(const Constraint &c)
Adds a copy of constraint c to the system of constraints of *this (without minimizing the result)...
const Constraint_System & constraints() const
Returns the system of constraints.
const_iterator begin() const
Returns the const_iterator pointing to the first constraint, if *this is not empty; otherwise...
void positive_time_elapse_assign(const Polyhedron &y)
Assigns to *this (the best approximation of) the result of computing the positive time-elapse between...
bool is_strict_inequality() const
Returns true if and only if *this is a strict inequality constraint.
Complexity_Class
Complexity pseudo-classes.
The base class for convex polyhedra.
dimension_type check_space_dimension_overflow(const dimension_type dim, const dimension_type max, const char *domain, const char *method, const char *reason)
Definition: globals.cc:48
const_iterator end() const
Returns the past-the-end const_iterator.
A not necessarily closed convex polyhedron.
A closed convex polyhedron.
void positive_time_elapse_assign(const Polyhedron &y)
Assigns to *this the smallest C polyhedron containing the result of computing the positive time-elaps...
The universe element, i.e., the whole vector space.
void add_constraints(const Constraint_System &cs)
Adds a copy of the constraints in cs to the system of constraints of *this (without minimizing the re...
Constraint_System constraints() const
Returns a system of equality constraints satisfied by *this with the same affine dimension as *this...
The entire library is confined to this namespace.
Definition: version.hh:61
bool OK(bool check_not_empty=false) const
Checks if all the invariants are satisfied.
Coefficient c
Definition: PIP_Tree.cc:64
bool poly_hull_assign_if_exact(const C_Polyhedron &y)
If the poly-hull of *this and y is exact it is assigned to *this and true is returned, otherwise false is returned.
Definition: C_Polyhedron.cc:86
expr_type expression() const
Partial read access to the (adapted) internal expression.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.