1 /* NNC_Polyhedron class declaration.
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 #ifndef PPL_NNC_Polyhedron_defs_hh
25 #define PPL_NNC_Polyhedron_defs_hh 1
26 
27 #include "NNC_Polyhedron_types.hh"
28 #include "C_Polyhedron_types.hh"
29 #include "Polyhedron_defs.hh"
30 #include "Grid_types.hh"
31 
32 //! A not necessarily closed convex polyhedron.
33 /*! \ingroup PPL_CXX_interface
34     An object of the class NNC_Polyhedron represents a
35     <EM>not necessarily closed</EM> (NNC) convex polyhedron
36     in the vector space \f$\Rset^n\f$.
37 
38     \note
39     Since NNC polyhedra are a generalization of closed polyhedra,
40     any object of the class C_Polyhedron can be (explicitly) converted
41     into an object of the class NNC_Polyhedron.
42     The reason for defining two different classes is that objects of
43     the class C_Polyhedron are characterized by a more efficient
44     implementation, requiring less time and memory resources.
45 */
46 class Parma_Polyhedra_Library::NNC_Polyhedron : public Polyhedron {
47 public:
48   //! Builds either the universe or the empty NNC polyhedron.
49   /*!
50     \param num_dimensions
51     The number of dimensions of the vector space enclosing the NNC polyhedron;
52 
53     \param kind
54     Specifies whether a universe or an empty NNC polyhedron should be built.
55 
56     \exception std::length_error
57     Thrown if \p num_dimensions exceeds the maximum allowed space dimension.
58 
59     Both parameters are optional:
60     by default, a 0-dimension space universe NNC polyhedron is built.
61   */
62   explicit NNC_Polyhedron(dimension_type num_dimensions = 0,
63                           Degenerate_Element kind = UNIVERSE);
64 
65   //! Builds an NNC polyhedron from a system of constraints.
66   /*!
67     The polyhedron inherits the space dimension of the constraint system.
68 
69     \param cs
70     The system of constraints defining the polyhedron.
71   */
72   explicit NNC_Polyhedron(const Constraint_System& cs);
73 
74   //! Builds an NNC polyhedron recycling a system of constraints.
75   /*!
76     The polyhedron inherits the space dimension of the constraint system.
77 
78     \param cs
79     The system of constraints defining the polyhedron.  It is not
80     declared <CODE>const</CODE> because its data-structures may be
81     recycled to build the polyhedron.
82 
83     \param dummy
84     A dummy tag to syntactically differentiate this one
85     from the other constructors.
86   */
87   NNC_Polyhedron(Constraint_System& cs, Recycle_Input dummy);
88 
89   //! Builds an NNC polyhedron from a system of generators.
90   /*!
91     The polyhedron inherits the space dimension of the generator system.
92 
93     \param gs
94     The system of generators defining the polyhedron.
95 
96     \exception std::invalid_argument
97     Thrown if the system of generators is not empty but has no points.
98   */
99   explicit NNC_Polyhedron(const Generator_System& gs);
100 
101   //! Builds an NNC polyhedron recycling a system of generators.
102   /*!
103     The polyhedron inherits the space dimension of the generator system.
104 
105     \param gs
106     The system of generators defining the polyhedron.  It is not
107     declared <CODE>const</CODE> because its data-structures may be
108     recycled to build the polyhedron.
109 
110     \param dummy
111     A dummy tag to syntactically differentiate this one
112     from the other constructors.
113 
114     \exception std::invalid_argument
115     Thrown if the system of generators is not empty but has no points.
116   */
117   NNC_Polyhedron(Generator_System& gs, Recycle_Input dummy);
118 
119   //! Builds an NNC polyhedron from a system of congruences.
120   /*!
121     The polyhedron inherits the space dimension of the congruence system.
122 
123     \param cgs
124     The system of congruences defining the polyhedron.  It is not
125     declared <CODE>const</CODE> because its data-structures may be
126     recycled to build the polyhedron.
127   */
128   explicit NNC_Polyhedron(const Congruence_System& cgs);
129 
130   //! Builds an NNC polyhedron recycling a system of congruences.
131   /*!
132     The polyhedron inherits the space dimension of the congruence
133     system.
134 
135     \param cgs
136     The system of congruences defining the polyhedron.  It is not
137     declared <CODE>const</CODE> because its data-structures may be
138     recycled to build the polyhedron.
139 
140     \param dummy
141     A dummy tag to syntactically differentiate this one
142     from the other constructors.
143   */
144   NNC_Polyhedron(Congruence_System& cgs, Recycle_Input dummy);
145 
146   //! Builds an NNC polyhedron from the C polyhedron \p y.
147   /*!
148     \param y
149     The C polyhedron to be used;
150 
151     \param complexity
152     This argument is ignored.
153   */
154   explicit NNC_Polyhedron(const C_Polyhedron& y,
155                           Complexity_Class complexity = ANY_COMPLEXITY);
156 
157   //! Builds an NNC polyhedron out of a box.
158   /*!
159     The polyhedron inherits the space dimension of the box
160     and is the most precise that includes the box.
161 
162     \param box
163     The box representing the polyhedron to be built;
164 
165     \param complexity
166     This argument is ignored as the algorithm used has
167     polynomial complexity.
168 
169     \exception std::length_error
170     Thrown if the space dimension of \p box exceeds the maximum allowed
171     space dimension.
172   */
173   template <typename Interval>
174   explicit NNC_Polyhedron(const Box<Interval>& box,
175                           Complexity_Class complexity = ANY_COMPLEXITY);
176 
177   //! Builds an NNC polyhedron out of a grid.
178   /*!
179     The polyhedron inherits the space dimension of the grid
180     and is the most precise that includes the grid.
181 
182     \param grid
183     The grid used to build the polyhedron.
184 
185     \param complexity
186     This argument is ignored as the algorithm used has
187     polynomial complexity.
188   */
189   explicit NNC_Polyhedron(const Grid& grid,
190                           Complexity_Class complexity = ANY_COMPLEXITY);
191 
192   //! Builds a NNC polyhedron out of a BD shape.
193   /*!
194     The polyhedron inherits the space dimension of the BD shape
195     and is the most precise that includes the BD shape.
196 
197     \param bd
198     The BD shape used to build the polyhedron.
199 
200     \param complexity
201     This argument is ignored as the algorithm used has
202     polynomial complexity.
203   */
204   template <typename U>
205   explicit NNC_Polyhedron(const BD_Shape<U>& bd,
206                           Complexity_Class complexity = ANY_COMPLEXITY);
207 
208   //! Builds a NNC polyhedron out of an octagonal shape.
209   /*!
210     The polyhedron inherits the space dimension of the octagonal shape
211     and is the most precise that includes the octagonal shape.
212 
213     \param os
214     The octagonal shape used to build the polyhedron.
215 
216     \param complexity
217     This argument is ignored as the algorithm used has
218     polynomial complexity.
219   */
220   template <typename U>
221   explicit NNC_Polyhedron(const Octagonal_Shape<U>& os,
222                           Complexity_Class complexity = ANY_COMPLEXITY);
223 
224   //! Ordinary copy constructor.
225   NNC_Polyhedron(const NNC_Polyhedron& y,
226                  Complexity_Class complexity = ANY_COMPLEXITY);
227 
228   /*! \brief
229     The assignment operator.
230     (\p *this and \p y can be dimension-incompatible.)
231   */
232   NNC_Polyhedron& operator=(const NNC_Polyhedron& y);
233 
234   //! Assigns to \p *this the C polyhedron \p y.
235   NNC_Polyhedron& operator=(const C_Polyhedron& y);
236 
237   //! Destructor.
238   ~NNC_Polyhedron();
239 
240   /*! \brief
241     If the poly-hull of \p *this and \p y is exact it is assigned
242     to \p *this and <CODE>true</CODE> is returned,
243     otherwise <CODE>false</CODE> is returned.
244 
245     \exception std::invalid_argument
246     Thrown if \p *this and \p y are dimension-incompatible.
247   */
248   bool poly_hull_assign_if_exact(const NNC_Polyhedron& y);
249 
250   //! Same as poly_hull_assign_if_exact(y).
251   bool upper_bound_assign_if_exact(const NNC_Polyhedron& y);
252 
253   /*! \brief
254     Assigns to \p *this (the best approximation of) the result of
255     computing the
256     \ref Positive_Time_Elapse_Operator "positive time-elapse"
257     between \p *this and \p y.
258 
259     \exception std::invalid_argument
260     Thrown if \p *this and \p y are dimension-incompatible.
261   */
262   void positive_time_elapse_assign(const Polyhedron& y);
263 };
264 
265 #include "NNC_Polyhedron_inlines.hh"
266 
267 #endif // !defined(PPL_NNC_Polyhedron_defs_hh)
268