PPL  1.2
Grid_Generator_inlines.hh
Go to the documentation of this file.
1 /* Grid Generator class implementation: 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 #ifndef PPL_Grid_Generator_inlines_hh
25 #define PPL_Grid_Generator_inlines_hh 1
26 
27 namespace Parma_Polyhedra_Library {
28 
29 inline bool
31  return true;
32 }
33 
34 inline bool
36  return false;
37 }
38 
39 inline bool
41  return (kind_ == LINE_OR_EQUALITY);
42 }
43 
44 inline bool
47 }
48 
49 inline Topology
51  return NECESSARILY_CLOSED;
52 }
53 
54 inline void
57 }
58 
59 inline void
62 }
63 
64 inline void
66  PPL_USED(x);
67  PPL_ASSERT(x == NECESSARILY_CLOSED);
68 }
69 
70 inline void
73 }
74 
75 inline void
78 }
79 
80 inline
82  swap(expr, e);
83  if (type == LINE) {
85  }
86  else {
88  }
89  PPL_ASSERT(OK());
90 }
91 
92 inline
94  : expr(Coefficient_one(), r),
95  kind_(RAY_OR_POINT_OR_INEQUALITY) {
97  PPL_ASSERT(OK());
98 }
99 
100 inline
102  : expr(g.expr),
103  kind_(g.kind_) {
104 }
105 
106 inline
108  : expr(g.expr, r),
109  kind_(g.kind_) {
110 }
111 
112 inline
114  Topology topology, Representation r)
115  : expr(r),
116  kind_(kind) {
117  PPL_USED(topology);
118  PPL_ASSERT(topology == NECESSARILY_CLOSED);
119  expr.set_space_dimension(space_dim + 1);
120  PPL_ASSERT(space_dimension() == space_dim);
121 }
122 
123 inline
125  dimension_type space_dim)
126  : expr(g.expr, space_dim + 1),
127  kind_(g.kind_) {
128  PPL_ASSERT(OK());
129  PPL_ASSERT(space_dimension() == space_dim);
130 }
131 
132 inline
134  dimension_type space_dim, Representation r)
135  : expr(g.expr, space_dim + 1, r),
136  kind_(g.kind_) {
137  PPL_ASSERT(OK());
138  PPL_ASSERT(space_dimension() == space_dim);
139 }
140 
141 inline
143 }
144 
147  return expr_type(expr, true);
148 }
149 
150 inline Representation
152  return expr.representation();
153 }
154 
155 inline void
158 }
159 
160 inline dimension_type
163 }
164 
165 inline dimension_type
167  return expression().space_dimension();
168 }
169 
170 inline void
172  const dimension_type old_space_dim = space_dimension();
173  if (space_dim > old_space_dim) {
174  expr.set_space_dimension(space_dim + 1);
175  expr.swap_space_dimensions(Variable(space_dim), Variable(old_space_dim));
176  }
177  else {
178  expr.swap_space_dimensions(Variable(space_dim), Variable(old_space_dim));
179  expr.set_space_dimension(space_dim + 1);
180  }
181  PPL_ASSERT(space_dimension() == space_dim);
182 }
183 
184 inline void
186  set_space_dimension(space_dim);
187 }
188 
189 inline void
192 }
193 
196  if (is_line()) {
197  return LINE;
198  }
199  return is_point() ? POINT : PARAMETER;
200 }
201 
202 inline bool
204  return is_line_or_equality();
205 }
206 
207 inline bool
210 }
211 
212 inline bool
214  return expr.inhomogeneous_term() == 0;
215 }
216 
217 inline bool
219  return !is_line_or_parameter();
220 }
221 
222 inline bool
225 }
226 
227 inline void
228 Grid_Generator::set_divisor(Coefficient_traits::const_reference d) {
229  PPL_ASSERT(!is_line());
230  if (is_line_or_parameter()) {
232  }
233  else {
235  }
236 }
237 
238 inline Coefficient_traits::const_reference
240  if (is_line()) {
241  throw_invalid_argument("divisor()", "*this is a line");
242  }
243  if (is_line_or_parameter()) {
245  }
246  else {
247  return expr.inhomogeneous_term();
248  }
249 }
250 
251 inline bool
253  const Grid_Generator& y) const {
254  const Grid_Generator& x = *this;
255  return x.expr.get(dim) * y.divisor() == y.expr.get(dim) * x.divisor();
256 }
257 
258 inline void
261 }
262 
263 inline void
266 }
267 
268 inline Grid_Generator&
270  Grid_Generator tmp = g;
271  swap(*this, tmp);
272 
273  return *this;
274 }
275 
276 inline Coefficient_traits::const_reference
278  if (v.space_dimension() > space_dimension()) {
279  throw_dimension_incompatible("coefficient(v)", "v", v);
280  }
281  return expr.coefficient(v);
282 }
283 
284 inline memory_size_type
286  return sizeof(*this) + external_memory_in_bytes();
287 }
288 
289 inline memory_size_type
292 }
293 
294 inline const Grid_Generator&
296  PPL_ASSERT(zero_dim_point_p != 0);
297  return *zero_dim_point_p;
298 }
299 
300 inline void
302  PPL_ASSERT(!is_parameter());
303  expr.normalize();
304  sign_normalize();
305 }
306 
307 inline void
309  using std::swap;
310  swap(expr, y.expr);
311  swap(kind_, y.kind_);
312 }
313 
315 inline bool
317  return x.is_equivalent_to(y);
318 }
319 
321 inline bool
323  return !(x == y);
324 }
325 
327 inline Grid_Generator
329  return Grid_Generator::grid_line(e, r);
330 }
331 
333 inline Grid_Generator
335  Coefficient_traits::const_reference d, Representation r) {
336  return Grid_Generator::parameter(e, d, r);
337 }
338 
340 inline Grid_Generator
342  return Grid_Generator::parameter(r);
343 }
344 
346 inline Grid_Generator
348  return Grid_Generator::parameter(e, r);
349 }
350 
352 inline Grid_Generator
354  Coefficient_traits::const_reference d, Representation r) {
355  return Grid_Generator::grid_point(e, d, r);
356 }
357 
359 inline Grid_Generator
361  return Grid_Generator::grid_point(r);
362 }
363 
365 inline Grid_Generator
367  return Grid_Generator::grid_point(e, r);
368 }
369 
371 inline void
373  x.m_swap(y);
374 }
375 
376 } // namespace Parma_Polyhedra_Library
377 
378 #endif // !defined(PPL_Grid_Generator_inlines_hh)
bool is_parameter_or_point() const
Returns true if and only if *this row represents a parameter or a point.
Grid_Generator & operator=(const Grid_Generator &g)
Assignment operator.
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 .
void set_is_parameter_or_point()
Sets the Grid_Generator kind to RAY_OR_POINT_OR_INEQUALITY.
size_t dimension_type
An unsigned integral type for representing space dimensions.
void set_not_necessarily_closed()
Sets to NOT_NECESSARILY_CLOSED the topological kind of *this row.
void set_necessarily_closed()
Sets to NECESSARILY_CLOSED the topological kind of *this row.
bool is_line() const
Returns true if and only if *this is a line.
Coefficient_traits::const_reference get(dimension_type i) const
Returns the i-th coefficient.
void m_swap(Grid_Generator &y)
Swaps *this with y.
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
bool is_equal_at_dimension(dimension_type dim, const Grid_Generator &gg) const
Returns true if *this is equal to gg in dimension dim.
bool is_not_necessarily_closed() const
Returns true if and only if the topology of *this row is not necessarily closed.
static const Grid_Generator & zero_dim_point()
Returns the origin of the zero-dimensional space .
void set_space_dimension_no_ok(dimension_type space_dim)
Grid_Generator grid_point(Representation r)
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void set_coefficient(Variable v, Coefficient_traits::const_reference n)
Sets the coefficient of v in *this to n.
Grid_Generator grid_line(const Linear_Expression &e, Representation r)
void set_inhomogeneous_term(Coefficient_traits::const_reference n)
Sets the inhomogeneous term of *this to n.
expr_type expression() const
Partial read access to the (adapted) internal expression.
Grid_Generator parameter(const Linear_Expression &e, Coefficient_traits::const_reference d, Representation r)
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
Coefficient_traits::const_reference coefficient(Variable v) const
Returns the coefficient of v in *this.
Representation representation() const
Returns the current representation of *this.
A dimension of the vector space.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
static dimension_type max_space_dimension()
Returns the maximum space dimension a Linear_Expression can handle.
void set_is_ray_or_point_or_inequality()
Sets to RAY_OR_POINT_OR_INEQUALITY the kind of *this row.
void set_space_dimension(dimension_type space_dim)
Expression_Hide_Last< Expression_Hide_Inhomo< Linear_Expression > > expr_type
The type of the (adapted) internal expression.
static dimension_type max_space_dimension()
Returns the maximum space dimension a Grid_Generator can handle.
static Grid_Generator parameter(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
Coefficient_traits::const_reference divisor() const
Returns the divisor of *this.
Topology topology() const
Returns the topological kind of *this.
void set_representation(Representation r)
Converts *this to the specified representation.
Grid_Generator grid_point(const Linear_Expression &e, Representation r)
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
void swap(Grid_Generator &x, Grid_Generator &y)
Swaps x with y.
void set_divisor(Coefficient_traits::const_reference d)
Sets the divisor of *this to d.
bool is_line_or_parameter() const
Returns true if and only if *this is a line or a parameter.
bool is_point() const
Returns true if and only if *this is a point.
Type type() const
Returns the generator type of *this.
void shift_space_dimensions(Variable v, dimension_type n)
void swap_space_dimensions(Variable v1, Variable v2)
Swaps the coefficients of the variables v1 and v2 .
static const Grid_Generator * zero_dim_point_p
Holds (between class initialization and finalization) a pointer to the origin of the zero-dimensional...
Kind
The possible kinds of Grid_Generator objects.
Grid_Generator parameter(const Linear_Expression &e, Representation r)
bool is_equivalent_to(const Grid_Generator &y) const
Returns true if and only if *this and y are equivalent generators.
void set_topology(Topology x)
Sets to x the topological kind of *this row.
void sign_normalize()
Normalizes the sign of the coefficients so that the first non-zero (homogeneous) coefficient of a lin...
void throw_dimension_incompatible(const char *method, const char *name_var, const Variable v) const
Throw a std::invalid_argument exception containing the appropriate error message. ...
bool is_line_or_equality() const
Returns true if and only if *this row represents a line or an equality.
static Grid_Generator grid_point(const Linear_Expression &e=Linear_Expression::zero(), Coefficient_traits::const_reference d=Coefficient_one(), Representation r=default_representation)
Returns the point at e / d.
The entire library is confined to this namespace.
Definition: version.hh:61
Representation representation() const
Returns the current representation of *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
static Grid_Generator grid_line(const Linear_Expression &e, Representation r=default_representation)
Returns the line of direction e.
bool is_ray_or_point_or_inequality() const
Returns true if and only if *this row represents a ray, a point or an inequality. ...
memory_size_type total_memory_in_bytes() const
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
bool operator==(const Grid_Generator &x, const Grid_Generator &y)
#define PPL_USED(v)
No-op macro that allows to avoid unused variable warnings from the compiler.
Definition: compiler.hh:39
void strong_normalize()
Strong normalization: ensures that different Grid_Generator objects represent different hyperplanes o...
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void throw_invalid_argument(const char *method, const char *reason) const
Throw a std::invalid_argument exception containing the appropriate error message. ...
Coefficient_traits::const_reference coefficient(Variable v) const
Returns the coefficient of v in *this.
bool is_parameter() const
Returns true if and only if *this is a parameter.
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
void set_is_line_or_equality()
Sets to LINE_OR_EQUALITY the kind of *this row.
bool operator!=(const Grid_Generator &x, const Grid_Generator &y)
void set_is_line()
Sets the Grid_Generator kind to LINE_OR_EQUALITY.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
Grid_Generator grid_point(const Linear_Expression &e, Coefficient_traits::const_reference d, Representation r)
Grid_Generator parameter(Representation r)
Grid_Generator(Representation r=default_representation)
Returns the origin of the zero-dimensional space .
bool OK() const
Checks if all the invariants are satisfied.
An adapter for Linear_Expression that maybe hides the last coefficient.
A grid line, parameter or grid point.
Topology
Kinds of polyhedra domains.
void set_representation(Representation r)
Converts *this to the specified representation.
void shift_space_dimensions(Variable v, dimension_type n)