PPL  1.2
Grid_Generator_defs.hh
Go to the documentation of this file.
1 /* Grid_Generator 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_Grid_Generator_defs_hh
25 #define PPL_Grid_Generator_defs_hh 1
26 
27 #include "Grid_Generator_types.hh"
28 #include "Grid_types.hh"
29 
30 #include "Variables_Set_types.hh"
32 #include "Linear_System_types.hh"
33 
34 #include "Coefficient_defs.hh"
36 #include "Topology_types.hh"
39 
40 #include "Grid_types.hh"
41 #include <iosfwd>
42 
43 namespace Parma_Polyhedra_Library {
44 
45 // Put these in the namespace here to declare them friend later.
46 
47 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
48 
83 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
84 int compare(const Grid_Generator& x, const Grid_Generator& y);
85 
86 namespace IO_Operators {
87 
89 
90 std::ostream& operator<<(std::ostream& s, const Grid_Generator& g);
91 
92 } // namespace IO_Operators
93 
95 
96 void swap(Grid_Generator& x, Grid_Generator& y);
97 
98 } // namespace Parma_Polyhedra_Library
99 
101 
272 public:
273 
275  enum Kind {
278  };
279 
281 
287 
289 
295  Representation r = default_representation);
296 
299 
308  Coefficient_traits::const_reference d
309  = Coefficient_one(),
310  Representation r = default_representation);
311 
312  // TODO: Improve the documentation of this method.
315 
318  Representation r);
319 
321 
330  Coefficient_traits::const_reference d
331  = Coefficient_one(),
332  Representation r = default_representation);
333 
336 
339  Representation r);
340 
342  explicit Grid_Generator(Representation r = default_representation);
343 
346  Grid_Generator(const Grid_Generator& g);
347 
350 
353  Grid_Generator(const Grid_Generator& g, dimension_type space_dim);
354 
356  Grid_Generator(const Grid_Generator& g, dimension_type space_dim,
357  Representation r);
358 
360  ~Grid_Generator();
361 
364 
367 
370 
373 
376 
379  void set_space_dimension(dimension_type space_dim);
380 
383 
385 
393  bool remove_space_dimensions(const Variables_Set& vars);
394 
396  /*
397  \param cycle
398  A vector representing a cycle of the permutation according to which the
399  space dimensions must be rearranged.
400 
401  The \p cycle vector represents a cycle of a permutation of space
402  dimensions.
403  For example, the permutation
404  \f$ \{ x_1 \mapsto x_2, x_2 \mapsto x_3, x_3 \mapsto x_1 \}\f$ can be
405  represented by the vector containing \f$ x_1, x_2, x_3 \f$.
406  */
407  void permute_space_dimensions(const std::vector<Variable>& cycle);
408 
412 
414  enum Type {
421  };
422 
424  Type type() const;
425 
427  bool is_line() const;
428 
430  bool is_parameter() const;
431 
436  bool is_line_or_parameter() const;
437 
439  bool is_point() const;
440 
445  bool is_parameter_or_point() const;
446 
448 
453  Coefficient_traits::const_reference coefficient(Variable v) const;
454 
456 
460  Coefficient_traits::const_reference divisor() const;
461 
463  static void initialize();
464 
466  static void finalize();
467 
469  static const Grid_Generator& zero_dim_point();
470 
476 
479 
486  bool is_equivalent_to(const Grid_Generator& y) const;
487 
489 
493  bool is_equal_to(const Grid_Generator& y) const;
494 
499  bool all_homogeneous_terms_are_zero() const;
500 
502  bool OK() const;
503 
505 
511  bool ascii_load(std::istream& s);
512 
514  void m_swap(Grid_Generator& y);
515 
524  void scale_to_divisor(Coefficient_traits::const_reference d);
525 
527 
531  void set_divisor(Coefficient_traits::const_reference d);
532 
537  expr_type expression() const;
538 
539 private:
541 
543 
549 
553  Representation r = default_representation);
554 
555  // TODO: Avoid reducing the space dimension.
566 
570 
575 
581  const Grid_Generator& gg) const;
582 
588  void fancy_print(std::ostream& s) const;
589 
591  void set_is_parameter();
592 
594  void set_is_line();
595 
598 
600 
601  Topology topology() const;
603 
608  bool is_not_necessarily_closed() const;
609 
614  bool is_necessarily_closed() const;
615 
620  bool is_line_or_equality() const;
621 
626  bool is_ray_or_point_or_inequality() const;
628 
630 
631 
633  void set_topology(Topology x);
634 
636  void set_necessarily_closed();
637 
640 
643 
647 
652  void sign_normalize();
653 
660  void strong_normalize();
661 
666  bool check_strong_normalized() const;
667 
669 
680  void linear_combine(const Grid_Generator& y, dimension_type i);
681 
686  void
687  throw_dimension_incompatible(const char* method,
688  const char* name_var,
689  const Variable v) const;
690 
695  void
696  throw_invalid_argument(const char* method, const char* reason) const;
697 
698  friend std::ostream&
699  IO_Operators::operator<<(std::ostream& s, const Grid_Generator& g);
700 
701  friend int
702  compare(const Grid_Generator& x, const Grid_Generator& y);
703 
705  friend class Grid_Generator_System;
706  friend class Grid;
708  friend class Scalar_Products;
710 };
711 
712 
713 namespace Parma_Polyhedra_Library {
714 
722 grid_line(const Linear_Expression& e,
724 
732 parameter(const Linear_Expression& e = Linear_Expression::zero(),
733  Coefficient_traits::const_reference d = Coefficient_one(),
735 
737 
739 parameter(Representation r);
740 
748 parameter(const Linear_Expression& e, Representation r);
749 
757 grid_point(const Linear_Expression& e = Linear_Expression::zero(),
758  Coefficient_traits::const_reference d = Coefficient_one(),
760 
762 
764 grid_point(Representation r);
765 
773 grid_point(const Linear_Expression& e, Representation r);
774 
776 
777 bool operator==(const Grid_Generator& x, const Grid_Generator& y);
778 
780 
781 bool operator!=(const Grid_Generator& x, const Grid_Generator& y);
782 
783 
784 namespace IO_Operators {
785 
787 
788 std::ostream& operator<<(std::ostream& s, const Grid_Generator::Type& t);
789 
790 } // namespace IO_Operators
791 
792 } // namespace Parma_Polyhedra_Library
793 
794 #include "Grid_Generator_inlines.hh"
795 
796 #endif // !defined(PPL_Grid_Generator_defs_hh)
bool is_parameter_or_point() const
Returns true if and only if *this row represents a parameter or a point.
Scalar product sign function object depending on topology.
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
Definition: Box_inlines.hh:264
Grid_Generator & operator=(const Grid_Generator &g)
Assignment operator.
void swap(CO_Tree &x, CO_Tree &y)
The base class for systems of constraints and generators.
void set_is_parameter_or_point()
Sets the Grid_Generator kind to RAY_OR_POINT_OR_INEQUALITY.
bool is_equal_to(const Grid_Generator &y) const
Returns true if *this is identical to y.
size_t dimension_type
An unsigned integral type for representing space dimensions.
void permute_space_dimensions(const std::vector< Variable > &cycle)
Permutes the space dimensions of the grid generator.
void set_not_necessarily_closed()
Sets to NOT_NECESSARILY_CLOSED the topological kind of *this row.
An std::set of variables' indexes.
An adapter for Linear_Expression objects.
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.
void m_swap(Grid_Generator &y)
Swaps *this with y.
bool remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the grid generator.
bool is_equal_at_dimension(dimension_type dim, const Grid_Generator &gg) const
Returns true if *this is equal to gg in dimension dim.
std::ostream & operator<<(std::ostream &s, const Ask_Tell< D > &x)
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)
bool check_strong_normalized() const
Returns true if and only if the coefficients are strongly normalized.
void fancy_print(std::ostream &s) const
A print function, with fancy, more human-friendly output.
expr_type expression() const
Partial read access to the (adapted) internal expression.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
Representation representation() const
Returns the current representation of *this.
A dimension of the vector space.
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.
#define PPL_OUTPUT_DECLARATIONS
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)
static void finalize()
Finalizes the class.
Coefficient_traits::const_reference divisor() const
Returns the divisor of *this.
Topology topology() const
Returns the topological kind of *this.
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
friend int compare(const Grid_Generator &x, const Grid_Generator &y)
void swap_space_dimensions(Variable v1, Variable v2)
Swaps the coefficients of the variables v1 and v2 .
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)
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.
int compare(const Linear_Expression &x, const Linear_Expression &y)
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 linear_combine(const Grid_Generator &y, dimension_type i)
Linearly combines *this with y so that i-th coefficient is 0.
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 ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
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
bool all_homogeneous_terms_are_zero() const
Returns true if and only if all the homogeneous terms of *this are .
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. ...
Sparse representation: only the nonzero coefficient are stored. If there are many nonzero coefficient...
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
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. ...
static const Linear_Expression & zero()
Returns the (zero-dimension space) constant 0.
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.
static const Representation default_representation
The representation used for new Grid_Generators.
void set_is_line()
Sets the Grid_Generator kind to LINE_OR_EQUALITY.
void scale_to_divisor(Coefficient_traits::const_reference d)
Scales *this to be represented with a divisor of d (if \*this is a parameter or point). Does nothing at all on lines.
Grid_Generator(Representation r=default_representation)
Returns the origin of the zero-dimensional space .
bool OK() const
Checks if all the invariants are satisfied.
static void initialize()
Initializes the class.
An adapter for Linear_Expression that maybe hides the last coefficient.
A grid line, parameter or grid point.
Topology
Kinds of polyhedra domains.
A class implementing various scalar product functions.
void set_representation(Representation r)
Converts *this to the specified representation.
void set_is_parameter()
Converts the Grid_Generator into a parameter.