24 #ifndef PPL_Grid_defs_hh
25 #define PPL_Grid_defs_hh 1
52 namespace IO_Operators {
70 void swap(Grid& x, Grid& y);
518 template <
typename Interval>
538 template <
typename U>
558 template <
typename U>
934 bool OK(
bool check_not_empty =
false)
const;
1238 Coefficient_traits::const_reference denominator
1302 Coefficient_traits::const_reference denominator
1339 Coefficient_traits::const_reference denominator
1341 Coefficient_traits::const_reference modulus
1378 Coefficient_traits::const_reference denominator
1380 Coefficient_traits::const_reference modulus
1411 Coefficient_traits::const_reference modulus
1442 Coefficient_traits::const_reference modulus
1474 Coefficient_traits::const_reference denominator
1506 Coefficient_traits::const_reference denominator
1568 unsigned complexity_threshold = 16,
1569 bool wrap_individually =
true);
1678 unsigned* tp = NULL);
1702 unsigned* tp = NULL);
1725 unsigned* tp = NULL);
1868 template <
typename Partial_Function>
1975 #define PPL_IN_Grid_CLASS
1976 #include "Grid_Status_idefs.hh"
1977 #undef PPL_IN_Grid_CLASS
2207 const char* method_call,
2410 Dimension_Kinds& dim_kinds);
2418 Dimension_Kinds& dim_kinds);
2426 Dimension_Kinds& dim_kinds);
2433 Dimension_Kinds& dim_kinds);
2469 template <
typename R>
2539 template <
typename M>
2548 const Dimension_Kinds& sys_dim_kinds,
2549 bool generators =
true);
2576 const Dimension_Kinds& dim_kinds);
2583 const Dimension_Kinds& dim_kinds);
2595 template <
typename M,
typename R>
2604 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
2607 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
2610 const char* other_name,
2613 const char* gr_name,
2614 const Grid& gr)
const;
2616 const char* le_name,
2619 const char* cg_name,
2631 const char* cgs_name,
2634 const char* cs_name,
2637 const char* gs_name,
2640 const char* var_name,
2646 const char* reason);
2648 const char* c_name);
2650 const char* cs_name);
2652 const char* g_name);
2654 const char* gs_name);
2655 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
2657 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
2665 #endif // !defined(PPL_Grid_defs_hh)
Grid_Generator_System gen_sys
The system of generators.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
void add_space_dimensions(Congruence_System &cgs, Grid_Generator_System &gs, dimension_type dims)
Adds new space dimensions to the given systems.
void add_space_dimensions_and_embed(dimension_type m)
Adds m new space dimensions and embeds the old grid in the new vector space.
void drop_some_non_integer_points(Complexity_Class complexity=ANY_COMPLEXITY)
Possibly tightens *this by dropping all points with non-integer coordinates.
void congruence_widening_assign(const Grid &y, unsigned *tp=NULL)
Assigns to *this the result of computing the Grid widening between *this and y using congruence syste...
void expand_space_dimension(Variable var, dimension_type m)
Creates m copies of the space dimension corresponding to var.
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
void limited_extrapolation_assign(const Grid &y, const Congruence_System &cgs, unsigned *tp=NULL)
Improves the result of the Grid widening computation by also enforcing those congruences in cgs that ...
bool constrains(Variable var) const
Returns true if and only if var is constrained in *this.
Status status
The status flags to keep track of the grid's internal state.
static void reduce_pc_with_pc(R &row, R &pivot, dimension_type column, dimension_type start, dimension_type end)
Reduces row using pivot.
void clear_congruences_minimized()
Sets status to express that congruences are no longer minimized.
A linear equality or inequality.
void generalized_affine_image(Variable var, Relation_Symbol relsym, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one(), Coefficient_traits::const_reference modulus=Coefficient_zero())
Assigns to *this the image of *this with respect to the generalized affine relation ...
void swap(CO_Tree &x, CO_Tree &y)
bool is_universe() const
Returns true if and only if *this is a universe grid.
void clear_generators_up_to_date()
Sets status to express that generators are out of date.
bool is_included_in(const Grid &y) const
Returns true if and only if *this is included in y.
friend bool operator==(const Grid &x, const Grid &y)
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
The convergence certificate for the Grid widening operator.
void difference_assign(const Grid &y)
Assigns to *this the grid-difference of *this and y.
void limited_generator_extrapolation_assign(const Grid &y, const Congruence_System &cgs, unsigned *tp=NULL)
Improves the result of the generator variant of the Grid widening computation by also enforcing those...
void generator_widening_assign(const Grid &y, unsigned *tp=NULL)
Assigns to *this the result of computing the Grid widening between *this and y using generator system...
void set_empty()
Sets status to express that the grid is empty, clearing all corresponding matrices.
Grid(dimension_type num_dimensions=0, Degenerate_Element kind=UNIVERSE)
Builds a grid having the specified properties.
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_constraints(const Constraint_System &cs)
Adds to *this congruences equivalent to the constraints in cs.
size_t dimension_type
An unsigned integral type for representing space dimensions.
static void throw_invalid_generator(const char *method, const char *g_name)
An std::set of variables' indexes.
Congruence_System con_sys
The system of congruences.
const Congruence_System & congruences() const
Returns the system of congruences.
A line, ray, point or closure point.
void clear_generators_minimized()
Sets status to express that generators are no longer minimized.
const Grid_Generator_System & minimized_grid_generators() const
Returns the minimized system of generators.
void add_congruence_no_check(const Congruence &cg)
Adds the congruence cg to *this.
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
Constraint_System minimized_constraints() const
Returns a minimal system of equality constraints satisfied by *this with the same affine dimension as...
static void conversion(Congruence_System &source, Grid_Generator_System &dest, Dimension_Kinds &dim_kinds)
Converts generator system dest to be equivalent to congruence system source.
bool bounds_from_above(const Linear_Expression &expr) const
Returns true if and only if expr is bounded in *this.
static bool can_recycle_constraint_systems()
Returns true indicating that this domain has methods that can recycle constraints.
int32_t hash_code() const
Returns a 32-bit hash code for *this.
A conjunctive assertion about a grid.
bool is_disjoint_from(const Grid &y) const
Returns true if and only if *this and y are disjoint.
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 . ...
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
std::ostream & operator<<(std::ostream &s, const Ask_Tell< D > &x)
void add_constraint_no_check(const Constraint &c)
Uses the constraint c to refine *this.
bool is_discrete() const
Returns true if and only if *this is discrete.
void widening_assign(const Grid &y, unsigned *tp=NULL)
Assigns to *this the result of computing the Grid widening between *this and y.
void add_congruences(const Congruence_System &cgs)
Adds a copy of each congruence in cgs to *this.
Poly_Con_Relation relation_with(const Congruence &cg) const
Returns the relations holding between *this and cg.
bool contains_integer_point() const
Returns true if and only if *this contains at least one integer point.
Coefficient coefficient_type
The numeric type of coefficients.
void refine_with_constraints(const Constraint_System &cs)
Uses a copy of the constraints in cs to refine *this.
static bool simplify(Congruence_System &cgs, Dimension_Kinds &dim_kinds)
Converts cgs to upper triangular (i.e. minimized) form.
bool congruences_are_up_to_date() const
Returns true if the system of congruences is up-to-date.
bool strictly_contains(const Grid &y) const
Returns true if and only if *this strictly contains y.
void clear_congruences_up_to_date()
Sets status to express that congruences are out of date.
static void normalize_divisors(Grid_Generator_System &sys, Coefficient &divisor, const Grid_Generator *first_point=NULL)
Normalizes the divisors in sys.
void refine_with_congruence(const Congruence &cg)
Uses a copy of the congruence cg to refine *this.
void time_elapse_assign(const Grid &y)
Assigns to *this the result of computing the time-elapse between *this and y.
void set_generators_minimized()
Sets status to express that generators are minimized.
void throw_dimension_incompatible(const char *method, const char *other_name, dimension_type other_dim) const
A dimension of the vector space.
Bounded_Integer_Type_Overflow
bool simplify_using_context_assign(const Grid &y)
Assigns to *this a meet-preserving simplification of *this with respect to y. If false is returned...
Complexity_Class
Complexity pseudo-classes.
void add_recycled_grid_generators(Grid_Generator_System &gs)
Adds the generators in gs to the system of generators of this.
The base class for convex polyhedra.
Three_Valued_Boolean quick_equivalence_test(const Grid &y) const
Polynomial but incomplete equivalence test between grids.
bool upper_bound_assign_if_exact(const Grid &y)
If the upper bound of *this and y is exact it is assigned to this and true is returned, otherwise false is returned.
#define PPL_OUTPUT_DECLARATIONS
bool max_min(const Linear_Expression &expr, const char *method_call, Coefficient &ext_n, Coefficient &ext_d, bool &included, Generator *point=NULL) const
Maximizes or minimizes expr subject to *this.
bool OK(bool check_not_empty=false) const
Checks if all the invariants are satisfied.
void intersection_assign(const Grid &y)
Assigns to *this the intersection of *this and y.
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 remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the vector space.
static void reduce_reduced(Swapping_Vector< typename M::row_type > &sys, dimension_type dim, dimension_type pivot_index, dimension_type start, dimension_type end, const Dimension_Kinds &sys_dim_kinds, bool generators=true)
Reduce column dim in rows preceding pivot_index in sys.
Relation_Symbol
Relation symbols.
bool bounds(const Linear_Expression &expr, const char *method_call) const
Checks if and how expr is bounded in *this.
Degenerate_Element
Kinds of degenerate abstract elements.
static bool can_recycle_congruence_systems()
Returns true indicating that this domain has methods that can recycle congruences.
std::vector< Dimension_Kind > Dimension_Kinds
Bounded_Integer_Type_Width
const Congruence_System & minimized_congruences() const
Returns the system of congruences in minimal form.
bool is_topologically_closed() const
Returns true if and only if *this is a topologically closed subset of the vector space.
void limited_congruence_extrapolation_assign(const Grid &y, const Congruence_System &cgs, unsigned *tp=NULL)
Improves the result of the congruence variant of Grid widening computation by also enforcing those co...
void set_generators_up_to_date()
Sets status to express that generators are up-to-date.
void add_grid_generator(const Grid_Generator &g)
Adds a copy of grid generator g to the system of generators of *this.
void refine_with_congruences(const Congruence_System &cgs)
Uses a copy of the congruences in cgs to refine *this.
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 ...
void refine_no_check(const Constraint &c)
Uses the constraint c to refine *this.
A not necessarily closed, iso-oriented hyperrectangle.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
const Grid_Generator_System & grid_generators() const
Returns the system of generators.
bool contains(const Grid &y) const
Returns true if and only if *this contains y.
bool frequency_no_check(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 frequency for *this with respect to expr is define...
void wrap_assign(const Variables_Set &vars, Bounded_Integer_Type_Width w, Bounded_Integer_Type_Representation r, Bounded_Integer_Type_Overflow o, const Constraint_System *cs_p=0, unsigned complexity_threshold=16, bool wrap_individually=true)
Wraps the specified dimensions of the vector space.
void unconstrain(Variable var)
Computes the cylindrification of *this with respect to space dimension var, assigning the result to *...
void select_wider_generators(const Grid &y, Grid_Generator_System &widened_ggs) const
Copies widened generators from y to widened_ggs.
bool generators_are_up_to_date() const
Returns true if the system of generators is up-to-date.
void set_zero_dim_univ()
Sets status to express that the grid is the universe 0-dimension vector space, clearing all correspon...
The universe element, i.e., the whole vector space.
dimension_type space_dim
The number of dimensions of the enclosing vector space.
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
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.
void refine_with_constraint(const Constraint &c)
Uses a copy of the constraint c to refine *this.
dimension_type affine_dimension() const
Returns , if *this is empty; otherwise, returns the affine dimension of *this.
void fold_space_dimensions(const Variables_Set &vars, Variable dest)
Folds the space dimensions in vars into dest.
static void throw_invalid_generators(const char *method, const char *gs_name)
bool marked_empty() const
Returns true if the grid is known to be empty.
static bool rows_are_zero(M &system, dimension_type first, dimension_type last, dimension_type row_size)
Checks that trailing rows contain only zero terms.
static bool upper_triangular(const Grid_Generator_System &sys, const Dimension_Kinds &dim_kinds)
If sys is upper triangular return true, else return false.
bool congruences_are_minimized() const
Returns true if the system of congruences is minimized.
A bounded difference shape.
void add_congruence(const Congruence &cg)
Adds a copy of congruence cg to *this.
static void throw_invalid_constraints(const char *method, const char *cs_name)
void clear_empty()
Clears the status flag indicating that the grid is empty.
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 frequency for *this with respect to expr is define...
void add_constraint(const Constraint &c)
Adds to *this a congruence equivalent to constraint c.
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.
static void throw_invalid_argument(const char *method, const char *reason)
Dimension_Kinds dim_kinds
void add_recycled_constraints(Constraint_System &cs)
Adds to *this congruences equivalent to the constraints in cs.
static void reduce_equality_with_equality(Congruence &row, const Congruence &pivot, dimension_type column)
Reduces the equality row using the equality pivot.
static dimension_type max_space_dimension()
Returns the maximum space dimension all kinds of Grid can handle.
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
bool is_bounded() const
Returns true if and only if *this is bounded.
void map_space_dimensions(const Partial_Function &pfunc)
Remaps the dimensions of the vector space according to a partial function.
void update_congruences() const
Updates and minimizes the congruences from the generators.
static bool lower_triangular(const Congruence_System &sys, const Dimension_Kinds &dim_kinds)
If sys is lower triangular return true, else return false.
static void reduce_congruence_with_equality(Congruence &row, const Congruence &pivot, dimension_type column, Swapping_Vector< Congruence > &sys)
Reduce row using pivot.
bool bounds_from_below(const Linear_Expression &expr) const
Returns true if and only if expr is bounded in *this.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void add_grid_generators(const Grid_Generator_System &gs)
Adds a copy of the generators in gs to the system of generators of *this.
void add_space_dimensions_and_project(dimension_type m)
Adds m new space dimensions to the grid and does not embed it in the new vector space.
void generalized_affine_preimage(Variable var, Relation_Symbol relsym, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one(), Coefficient_traits::const_reference modulus=Coefficient_zero())
Assigns to *this the preimage of *this with respect to the generalized affine relation ...
static void reduce_parameter_with_line(Grid_Generator &row, const Grid_Generator &pivot, dimension_type column, Swapping_Vector< Grid_Generator > &sys, dimension_type num_columns)
Reduce row using pivot.
void set_congruences_up_to_date()
Sets status to express that congruences are up-to-date.
static void multiply_grid(const Coefficient &multiplier, Congruence &cg, Swapping_Vector< Congruence > &dest, dimension_type num_rows)
Multiply the elements of dest by multiplier.
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
void m_swap(Grid &y)
Swaps *this with grid y. (*this and y can be dimension-incompatible.)
bool generators_are_minimized() const
Returns true if the system of generators is minimized.
Grid & operator=(const Grid &y)
The assignment operator. (*this and y can be dimension-incompatible.)
void select_wider_congruences(const Grid &y, Congruence_System &selected_cgs) const
Copies a widened selection of congruences from y to selected_cgs.
bool bounds_no_check(const Linear_Expression &expr) const
Checks if and how expr is bounded in *this.
void concatenate_assign(const Grid &y)
Assigns to *this the concatenation of *this and y, taken in this order.
void add_recycled_congruences(Congruence_System &cgs)
Adds the congruences in cgs to *this.
static void throw_invalid_constraint(const char *method, const char *c_name)
void construct(dimension_type num_dimensions, Degenerate_Element kind)
Builds a grid universe or empty grid.
void upper_bound_assign(const Grid &y)
Assigns to *this the least upper bound of *this and y.
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 expre...
bool le(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
The relation between a polyhedron and a generator.
bool update_generators() const
Updates and minimizes the generators from the congruences.
Bounded_Integer_Type_Representation
A grid line, parameter or grid point.
void set_congruences_minimized()
Sets status to express that congruences are minimized.
bool is_empty() const
Returns true if and only if *this is an empty grid.
void topological_closure_assign()
Assigns to *this its topological closure.
A system of grid generators.
The relation between a polyhedron and a constraint.
static void reduce_line_with_line(Grid_Generator &row, Grid_Generator &pivot, dimension_type column)
Reduces the line row using the line pivot.
bool minimize() const
Minimizes both the congruences and the generators.