PPL  1.2
Affine_Space_defs.hh
Go to the documentation of this file.
1 /* Affine_Space 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_Affine_Space_defs_hh
25 #define PPL_Affine_Space_defs_hh 1
26 
27 #include "Affine_Space_types.hh"
28 #include "Variable_defs.hh"
29 #include "Variables_Set_types.hh"
31 #include "Constraint_types.hh"
38 #include "Box_types.hh"
39 #include "Polyhedron_types.hh"
40 #include "BD_Shape_types.hh"
41 #include "Octagonal_Shape_types.hh"
42 #include "Grid_defs.hh"
43 #include <iosfwd>
44 
45 namespace Parma_Polyhedra_Library {
46 
47 namespace IO_Operators {
48 
50 
58 std::ostream&
59 operator<<(std::ostream& s, const Affine_Space& gr);
60 
61 } // namespace IO_Operators
62 
64 
65 void swap(Affine_Space& x, Affine_Space& y);
66 
75 bool operator==(const Affine_Space& x, const Affine_Space& y);
76 
85 bool operator!=(const Affine_Space& x, const Affine_Space& y);
86 
87 } // namespace Parma_Polyhedra_Library
88 
89 
91 
358 public:
361 
364 
369  static bool can_recycle_constraint_systems();
370 
375  static bool can_recycle_congruence_systems();
376 
378 
389  explicit Affine_Space(dimension_type num_dimensions = 0,
391 
393 
406  explicit Affine_Space(const Constraint_System& cs);
407 
409 
428 
430 
444  explicit Affine_Space(const Generator_System& gs);
445 
447 
466 
468 
484  template <typename Interval>
485  explicit Affine_Space(const Box<Interval>& box,
486  Complexity_Class complexity = ANY_COMPLEXITY);
487 
489 
505  template <typename U>
506  explicit Affine_Space(const BD_Shape<U>& bd,
507  Complexity_Class complexity = ANY_COMPLEXITY);
508 
510 
526  template <typename U>
527  explicit Affine_Space(const Octagonal_Shape<U>& os,
528  Complexity_Class complexity = ANY_COMPLEXITY);
529 
548  explicit Affine_Space(const Polyhedron& ph,
549  Complexity_Class complexity = ANY_COMPLEXITY);
550 
552 
555  Affine_Space(const Affine_Space& y,
556  Complexity_Class complexity = ANY_COMPLEXITY);
557 
563 
565 
566 
569 
576 
582 
588 
590  const Congruence_System& congruences() const;
591 
598 
601 
604 
606  /*
607  \exception std::invalid_argument
608  Thrown if \p *this and congruence \p cg are dimension-incompatible.
609  */
610  Poly_Con_Relation relation_with(const Congruence& cg) const;
611 
613  /*
614  \exception std::invalid_argument
615  Thrown if \p *this and generator \p g are dimension-incompatible.
616  */
618  relation_with(const Generator& g) const;
619 
621  /*
622  \exception std::invalid_argument
623  Thrown if \p *this and constraint \p c are dimension-incompatible.
624  */
626 
628  bool is_empty() const;
629 
631  bool is_universe() const;
632 
639  bool is_topologically_closed() const;
640 
648  bool is_disjoint_from(const Affine_Space& y) const;
649 
651 
656  bool is_discrete() const;
657 
659  bool is_bounded() const;
660 
665  bool contains_integer_point() const;
666 
674  bool constrains(Variable var) const;
675 
677 
683  bool bounds_from_above(const Linear_Expression& expr) const;
684 
686 
692  bool bounds_from_below(const Linear_Expression& expr) const;
693 
694  // FIXME: revise all the comment blocks below this one.
695 
723  bool maximize(const Linear_Expression& expr,
724  Coefficient& sup_n, Coefficient& sup_d, bool& maximum) const;
725 
757  bool maximize(const Linear_Expression& expr,
758  Coefficient& sup_n, Coefficient& sup_d, bool& maximum,
759  Generator& point) const;
760 
788  bool minimize(const Linear_Expression& expr,
789  Coefficient& inf_n, Coefficient& inf_d, bool& minimum) const;
790 
822  bool minimize(const Linear_Expression& expr,
823  Coefficient& inf_n, Coefficient& inf_d, bool& minimum,
824  Generator& point) const;
825 
855  bool frequency(const Linear_Expression& expr,
856  Coefficient& freq_n, Coefficient& freq_d,
857  Coefficient& val_n, Coefficient& val_d) const;
858 
860 
864  bool contains(const Affine_Space& y) const;
865 
873  bool strictly_contains(const Affine_Space& y) const;
874 
876 
892  bool OK(bool check_not_empty = false) const;
893 
895 
897 
898 
900 
905  void add_congruence(const Congruence& cg);
906 
915  void add_generator(const Generator& g);
916 
918 
926  void add_congruences(const Congruence_System& cgs);
927 
929 
942 
953  void add_constraint(const Constraint& c);
954 
966  void add_constraints(const Constraint_System& cs);
967 
984 
986 
993  void refine_with_congruence(const Congruence& cg);
994 
996 
1003  void refine_with_congruences(const Congruence_System& cgs);
1004 
1006 
1014  void refine_with_constraint(const Constraint& c);
1015 
1017 
1025 
1039  void add_generators(const Generator_System& gs);
1040 
1057 
1068  void unconstrain(Variable var);
1069 
1082  void unconstrain(const Variables_Set& vars);
1083 
1090  void intersection_assign(const Affine_Space& y);
1091 
1098  void upper_bound_assign(const Affine_Space& y);
1099 
1109 
1117  void difference_assign(const Affine_Space& y);
1118 
1129 
1191  void affine_image(Variable var,
1192  const Linear_Expression& expr,
1193  Coefficient_traits::const_reference denominator
1194  = Coefficient_one());
1195 
1216  void affine_preimage(Variable var,
1217  const Linear_Expression& expr,
1218  Coefficient_traits::const_reference denominator
1219  = Coefficient_one());
1220 
1246  void
1248  Relation_Symbol relsym,
1249  const Linear_Expression& expr,
1250  Coefficient_traits::const_reference denominator
1251  = Coefficient_one());
1252 
1278  void
1280  Relation_Symbol relsym,
1281  const Linear_Expression& expr,
1282  Coefficient_traits::const_reference denominator
1283  = Coefficient_one());
1284 
1304  void
1306  Relation_Symbol relsym,
1307  const Linear_Expression& rhs);
1308 
1328  void
1330  Relation_Symbol relsym,
1331  const Linear_Expression& rhs);
1332 
1359  void bounded_affine_image(Variable var,
1360  const Linear_Expression& lb_expr,
1361  const Linear_Expression& ub_expr,
1362  Coefficient_traits::const_reference denominator
1363  = Coefficient_one());
1364 
1392  const Linear_Expression& lb_expr,
1393  const Linear_Expression& ub_expr,
1394  Coefficient_traits::const_reference denominator
1395  = Coefficient_one());
1396 
1404  void time_elapse_assign(const Affine_Space& y);
1405 
1408 
1421  void widening_assign(const Affine_Space& y, unsigned* tp = NULL);
1422 
1439  const Constraint_System& cs,
1440  unsigned* tp = NULL);
1441 
1443 
1445 
1446 
1473 
1500 
1509  void concatenate_assign(const Affine_Space& y);
1510 
1512 
1521  void remove_space_dimensions(const Variables_Set& vars);
1522 
1531  void remove_higher_space_dimensions(dimension_type new_dimension);
1532 
1581  template <typename Partial_Function>
1582  void map_space_dimensions(const Partial_Function& pfunc);
1583 
1585 
1607 
1609 
1632  void fold_space_dimensions(const Variables_Set& to_be_folded, Variable var);
1633 
1635 
1636  friend bool operator==(const Affine_Space& x, const Affine_Space& y);
1637 
1639 
1640 
1642  ~Affine_Space();
1643 
1648  void m_swap(Affine_Space& y);
1649 
1651 
1657  bool ascii_load(std::istream& s);
1658 
1661 
1664 
1671  int32_t hash_code() const;
1672 
1674 
1675 private:
1678 
1679 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
1680 
1682 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
1683 protected:
1684 #if 0
1685  void throw_invalid_argument(const char* method, const char* reason) const;
1686 #endif
1687  void throw_dimension_incompatible(const char* method,
1688  const char* other_name,
1689  dimension_type other_dim) const;
1690  void throw_dimension_incompatible(const char* method,
1691  const char* as_name,
1692  const Affine_Space& as) const;
1693 
1694  // Note: it has to be a static method, because it can be called inside
1695  // constructors (before actually constructing the grid object).
1696  static void throw_space_dimension_overflow(const char* method,
1697  const char* reason);
1698 
1699  void throw_invalid_constraint(const char* method,
1700  const char* c_name) const;
1701  void throw_invalid_constraints(const char* method,
1702  const char* cs_name) const;
1703  void throw_invalid_generator(const char* method,
1704  const char* g_name) const;
1705  void throw_invalid_generators(const char* method,
1706  const char* gs_name) const;
1707 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
1708 
1709 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
1710 
1711 };
1712 
1713 #include "Affine_Space_inlines.hh"
1714 
1715 #endif // !defined(PPL_Affine_Space_defs_hh)
Coefficient coefficient_type
The numeric type of coefficients.
void unconstrain(Variable var)
Computes the cylindrification of *this with respect to space dimension var, assigning the result to *...
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
Definition: Box_inlines.hh:264
void add_constraints(const Constraint_System &cs)
Adds to *this congruences equivalent to the constraints in cs.
void add_recycled_generators(Generator_System &gs)
Adds the generators in gs to the system of generators of this.
void generalized_affine_preimage(Variable var, Relation_Symbol relsym, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one())
Assigns to *this the preimage of *this with respect to the generalized affine relation ...
A linear equality or inequality.
void swap(CO_Tree &x, CO_Tree &y)
void add_constraint(const Constraint &c)
Adds to *this a congruence equivalent to constraint c.
bool OK(bool check_not_empty=false) const
Checks if all the invariants are satisfied.
Generator_System minimized_generators() const
Returns a minimized system of generators defining *this.
bool upper_bound_assign_if_exact(const Affine_Space &y)
If the upper bound of *this and y is exact it is assigned to this and true is returned, otherwise false is returned.
void refine_with_constraint(const Constraint &c)
Uses a copy of the constraint c to refine *this.
size_t dimension_type
An unsigned integral type for representing space dimensions.
void refine_with_congruences(const Congruence_System &cgs)
Uses a copy of the congruences in cgs to refine *this.
void add_recycled_congruences(Congruence_System &cgs)
Adds the congruences in cgs to *this.
An std::set of variables' indexes.
A line, ray, point or closure point.
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
bool is_discrete() const
Returns true if and only if *this is discrete.
std::ostream & operator<<(std::ostream &s, const Ask_Tell< D > &x)
bool contains(const Affine_Space &y) const
Returns true if and only if *this contains y.
bool is_topologically_closed() const
Returns true if and only if *this is a topologically closed subset of the vector space.
static bool can_recycle_congruence_systems()
Returns true indicating that this domain has methods that can recycle congruences.
bool is_universe() const
Returns true if and only if *this is a universe affine space.
bool is_bounded() const
Returns true if and only if *this is bounded.
void throw_invalid_constraint(const char *method, const char *c_name) const
Poly_Con_Relation relation_with(const Congruence &cg) const
Returns the relations holding between *this and cg.
const Congruence_System & minimized_congruences() const
Returns the system of equality congruences satisfied by *this, with no redundant congruences and havi...
Definition: Affine_Space.cc:95
void affine_preimage(Variable var, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one())
Assigns to *this the affine preimage of *this under the function mapping variable var to the affine e...
void difference_assign(const Affine_Space &y)
Assigns to *this the poly-difference of *this and y.
A dimension of the vector space.
void concatenate_assign(const Affine_Space &y)
Assigns to *this the concatenation of *this and y, taken in this order.
Complexity_Class
Complexity pseudo-classes.
The base class for convex polyhedra.
void throw_dimension_incompatible(const char *method, const char *other_name, dimension_type other_dim) const
bool strictly_contains(const Affine_Space &y) const
Returns true if and only if *this strictly contains y.
bool bounds_from_below(const Linear_Expression &expr) const
Returns true if and only if expr is bounded in *this.
void throw_invalid_generator(const char *method, const char *g_name) const
#define PPL_OUTPUT_DECLARATIONS
void intersection_assign(const Affine_Space &y)
Assigns to *this the intersection of *this and y.
friend bool operator==(const Affine_Space &x, const Affine_Space &y)
Relation_Symbol
Relation symbols.
Degenerate_Element
Kinds of degenerate abstract elements.
bool maximize(const Linear_Expression &expr, Coefficient &sup_n, Coefficient &sup_d, bool &maximum) const
Returns true if and only if *this is not empty and expr is bounded from above in *this, in which case the supremum value is computed.
bool is_empty() const
Returns true if and only if *this is an empty affine space.
void fold_space_dimensions(const Variables_Set &to_be_folded, Variable var)
Folds the space dimensions in to_be_folded into var.
void map_space_dimensions(const Partial_Function &pfunc)
Remaps the dimensions of the vector space according to a partial function.
bool contains_integer_point() const
Returns true if and only if *this contains at least one integer point.
Grid gr
The rational grid implementing *this.
void topological_closure_assign()
Assigns to *this its topological closure.
bool bounds_from_above(const Linear_Expression &expr) const
Returns true if and only if expr is bounded in *this.
A not necessarily closed, iso-oriented hyperrectangle.
Definition: Box_defs.hh:299
void bounded_affine_preimage(Variable var, const Linear_Expression &lb_expr, const Linear_Expression &ub_expr, Coefficient_traits::const_reference denominator=Coefficient_one())
Assigns to *this the preimage of *this with respect to the bounded affine relation ...
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
void add_space_dimensions_and_embed(dimension_type m)
Adds m new space dimensions and embeds the old affine space in the new vector space.
bool simplify_using_context_assign(const Affine_Space &y)
Assigns to *this a meet-preserving simplification of *this with respect to y. If false is returned...
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
void upper_bound_assign(const Affine_Space &y)
Assigns to *this the least upper bound of *this and y.
void refine_with_congruence(const Congruence &cg)
Uses a copy of the congruence cg to refine *this.
void generalized_affine_image(Variable var, Relation_Symbol relsym, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one())
Assigns to *this the image of *this with respect to the generalized affine relation ...
int32_t hash_code() const
Returns a 32-bit hash code for *this.
dimension_type affine_dimension() const
Returns , if *this is empty; otherwise, returns affine dimension of *this.
Definition: Affine_Space.cc:85
Affine_Space(dimension_type num_dimensions=0, Degenerate_Element kind=UNIVERSE)
Builds an affine space having the specified properties.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
The universe element, i.e., the whole vector space.
void limited_extrapolation_assign(const Affine_Space &y, const Constraint_System &cs, unsigned *tp=NULL)
Does nothing, as the domain of affine spaces has finite height.
void throw_invalid_constraints(const char *method, const char *cs_name) const
void m_swap(Affine_Space &y)
Swaps *this with affine space y. (*this and y can be dimension-incompatible.)
bool frequency(const Linear_Expression &expr, Coefficient &freq_n, Coefficient &freq_d, Coefficient &val_n, Coefficient &val_d) const
Returns true if and only if *this is not empty and expr is discrete in *this, in which case the maxim...
The entire library is confined to this namespace.
Definition: version.hh:61
bool is_disjoint_from(const Affine_Space &y) const
Returns true if and only if *this and y are disjoint.
Affine_Space & operator=(const Affine_Space &y)
The assignment operator. (*this and y can be dimension-incompatible.)
Definition: Affine_Space.cc:79
static dimension_type max_space_dimension()
Returns the maximum space dimension all kinds of Affine_Space can handle.
bool constrains(Variable var) const
Returns true if and only if var is constrained in *this.
void widening_assign(const Affine_Space &y, unsigned *tp=NULL)
Does nothing, as the domain of affine spaces has finite height.
void bounded_affine_image(Variable var, const Linear_Expression &lb_expr, const Linear_Expression &ub_expr, Coefficient_traits::const_reference denominator=Coefficient_one())
Assigns to *this the image of *this with respect to the bounded affine relation . ...
A bounded difference shape.
void time_elapse_assign(const Affine_Space &y)
Assigns to *this the result of computing the time-elapse between *this and y.
Constraint_System minimized_constraints() const
Returns a minimal system of equality constraints satisfied by *this with the same affine dimension as...
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...
void add_generator(const Generator &g)
Adds a copy of affine space generator g to the system of generators of *this.
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
static void throw_space_dimension_overflow(const char *method, const char *reason)
void remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the vector space.
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
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...
void refine_with_constraints(const Constraint_System &cs)
Uses a copy of the constraints in cs to refine *this.
void expand_space_dimension(Variable var, dimension_type m)
Creates m copies of the space dimension corresponding to var.
Coefficient c
Definition: PIP_Tree.cc:64
void add_space_dimensions_and_project(dimension_type m)
Adds m new space dimensions to the affine space and does not embed it in the new vector space...
void add_generators(const Generator_System &gs)
Adds a copy of the generators in gs to the system of generators of *this.
void add_congruence(const Congruence &cg)
Adds a copy of congruence cg to *this.
bool minimize(const Linear_Expression &expr, Coefficient &inf_n, Coefficient &inf_d, bool &minimum) const
Returns true if and only if *this is not empty and expr is bounded from below in *this, in which case the infimum value is computed.
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
void add_congruences(const Congruence_System &cgs)
Adds a copy of each congruence in cgs to *this.
Generator_System generators() const
Returns a system of generators defining *this.
Constraint_System constraints() const
Returns a system of equality constraints satisfied by *this with the same affine dimension as *this...
void add_recycled_constraints(Constraint_System &cs)
Adds to *this congruences equivalent to the constraints in cs.
void throw_invalid_generators(const char *method, const char *gs_name) const
const Congruence_System & congruences() const
Returns the system of equality congruences satisfied by *this.
Definition: Affine_Space.cc:90
The relation between a polyhedron and a generator.
static bool can_recycle_constraint_systems()
Returns true indicating that this domain has methods that can recycle constraints.
The relation between a polyhedron and a constraint.