24 #ifndef PPL_BD_Shape_inlines_hh
25 #define PPL_BD_Shape_inlines_hh 1
37 #include "assertions.hh"
56 return status.test_zero_dim_univ();
62 return status.test_empty();
68 return status.test_shortest_path_closed();
74 return status.test_shortest_path_reduced();
80 status.set_zero_dim_univ();
92 status.set_shortest_path_closed();
98 status.set_shortest_path_reduced();
101 template <
typename T>
104 status.reset_shortest_path_closed();
107 template <
typename T>
110 status.reset_shortest_path_reduced();
113 template <
typename T>
117 : dbm(num_dimensions + 1), status(), redundancy_dbm() {
122 if (num_dimensions > 0) {
130 template <
typename T>
133 : dbm(y.dbm), status(y.status), redundancy_dbm() {
139 template <
typename T>
140 template <
typename U>
145 : dbm((y.shortest_path_closure_assign(), y.dbm)),
157 template <
typename T>
160 return minimized_congruences();
163 template <
typename T>
167 cs_end = cs.
end(); i != cs_end; ++i) {
172 template <
typename T>
178 template <
typename T>
182 cgs_end = cgs.
end(); i != cgs_end; ++i) {
187 template <
typename T>
190 add_congruences(cgs);
193 template <
typename T>
198 if (c_space_dim > space_dimension()) {
199 throw_dimension_incompatible(
"refine_with_constraint(c)", c);
202 if (!marked_empty()) {
207 template <
typename T>
212 throw_invalid_argument(
"refine_with_constraints(cs)",
213 "cs and *this are space-dimension incompatible");
217 cs_end = cs.
end(); !marked_empty() && i != cs_end; ++i) {
222 template <
typename T>
227 if (cg_space_dim > space_dimension()) {
228 throw_dimension_incompatible(
"refine_with_congruence(cg)", cg);
231 if (!marked_empty()) {
236 template <
typename T>
241 throw_invalid_argument(
"refine_with_congruences(cgs)",
242 "cgs and *this are space-dimension incompatible");
246 cgs_end = cgs.
end(); !marked_empty() && i != cgs_end; ++i) {
251 template <
typename T>
254 PPL_ASSERT(!marked_empty());
270 template <
typename T>
277 template <
typename T>
283 template <
typename T>
286 : dbm(cs.space_dimension() + 1), status(), redundancy_dbm() {
294 template <
typename T>
295 template <
typename Interval>
299 : dbm(box.space_dimension() + 1), status(), redundancy_dbm() {
311 template <
typename T>
315 : dbm(grid.space_dimension() + 1), status(), redundancy_dbm() {
324 template <
typename T>
325 template <
typename U>
329 : dbm(os.space_dimension() + 1), status(), redundancy_dbm() {
344 template <
typename T>
355 template <
typename T>
360 template <
typename T>
369 template <
typename T>
372 return dbm.num_rows() - 1;
375 template <
typename T>
378 shortest_path_closure_assign();
379 return marked_empty();
382 template <
typename T>
385 return bounds(expr,
true);
388 template <
typename T>
391 return bounds(expr,
false);
394 template <
typename T>
398 bool& maximum)
const {
399 return max_min(expr,
true, sup_n, sup_d, maximum);
402 template <
typename T>
407 return max_min(expr,
true, sup_n, sup_d, maximum, g);
410 template <
typename T>
414 bool& minimum)
const {
415 return max_min(expr,
false, inf_n, inf_d, minimum);
418 template <
typename T>
423 return max_min(expr,
false, inf_n, inf_d, minimum, g);
426 template <
typename T>
432 template <
typename T>
435 return affine_dimension() == 0;
438 template <
typename T>
444 template <
typename T>
454 if (x_space_dim == 0) {
481 template <
typename T>
488 template <
typename Temp,
typename To,
typename T>
504 if (x_space_dim == 0) {
530 return rectilinear_distance_assign(r, x.
dbm, y.
dbm, dir, tmp0, tmp1, tmp2);
534 template <
typename Temp,
typename To,
typename T>
544 return rectilinear_distance_assign(r, x, y, dir, tmp0, tmp1, tmp2);
548 template <
typename To,
typename T>
554 return rectilinear_distance_assign<To, To, T>(r, x, y, dir);
558 template <
typename Temp,
typename To,
typename T>
574 if (x_space_dim == 0) {
600 return euclidean_distance_assign(r, x.
dbm, y.
dbm, dir, tmp0, tmp1, tmp2);
604 template <
typename Temp,
typename To,
typename T>
614 return euclidean_distance_assign(r, x, y, dir, tmp0, tmp1, tmp2);
618 template <
typename To,
typename T>
624 return euclidean_distance_assign<To, To, T>(r, x, y, dir);
628 template <
typename Temp,
typename To,
typename T>
643 if (x_space_dim == 0) {
669 return l_infinity_distance_assign(r, x.
dbm, y.
dbm, dir, tmp0, tmp1, tmp2);
673 template <
typename Temp,
typename To,
typename T>
683 return l_infinity_distance_assign(r, x, y, dir, tmp0, tmp1, tmp2);
687 template <
typename To,
typename T>
693 return l_infinity_distance_assign<To, To, T>(r, x, y, dir);
696 template <
typename T>
702 PPL_ASSERT(i <= space_dimension() && j <= space_dimension() && i != j);
703 N& dbm_ij = dbm[i][j];
706 if (marked_shortest_path_closed()) {
707 reset_shortest_path_closed();
712 template <
typename T>
716 Coefficient_traits::const_reference numer,
717 Coefficient_traits::const_reference denom) {
719 PPL_ASSERT(i <= space_dimension() && j <= space_dimension() && i != j);
720 PPL_ASSERT(denom != 0);
723 add_dbm_constraint(i, j, k);
726 template <
typename T>
731 throw_dimension_incompatible(
"time_elapse_assign(y)", y);
743 template <
typename T>
750 template <
typename T>
754 throw_dimension_incompatible(
"upper_bound_assign_if_exact(y)", y);
757 return BFT00_upper_bound_assign_if_exact(y);
759 const bool integer_upper_bound =
false;
760 return BHZ09_upper_bound_assign_if_exact<integer_upper_bound>(y);
764 template <
typename T>
768 "BD_Shape<T>::integer_upper_bound_assign_if_exact(y):"
769 " T in not an integer datatype.");
771 throw_dimension_incompatible(
"integer_upper_bound_assign_if_exact(y)", y);
773 const bool integer_upper_bound =
true;
774 return BHZ09_upper_bound_assign_if_exact<integer_upper_bound>(y);
777 template <
typename T>
784 if (new_dimension > space_dim) {
785 throw_dimension_incompatible(
"remove_higher_space_dimensions(nd)",
792 if (new_dimension == space_dim) {
798 shortest_path_closure_assign();
799 dbm.resize_no_copy(new_dimension + 1);
803 if (marked_shortest_path_reduced()) {
804 reset_shortest_path_reduced();
809 if (new_dimension == 0 && !marked_empty()) {
815 template <
typename T>
822 unsigned complexity_threshold,
823 bool wrap_individually) {
826 complexity_threshold, wrap_individually,
830 template <
typename T>
833 static N stop_points[] = {
840 CC76_extrapolation_assign(y,
843 +
sizeof(stop_points)/
sizeof(stop_points[0]),
847 template <
typename T>
860 template <
typename T>
863 H79_widening_assign(y, tp);
866 template <
typename T>
881 template <
typename T>
887 template <
typename T>
893 template <
typename T>
894 template <
typename Interval_Info>
903 refine_with_linear_form_inequality(left, right);
904 refine_with_linear_form_inequality(right, left);
908 refine_with_linear_form_inequality(left, right);
912 refine_with_linear_form_inequality(right, left);
921 template <
typename T>
922 template <
typename Interval_Info>
930 "BD_Shape<T>::refine_fp_interval_abstract_store:"
931 " T not a floating point type.");
937 template <
typename T>
943 PPL_ASSERT(r ==
V_EQ);
944 reset_shortest_path_closed();
949 template <
typename T>
957 #endif // !defined(PPL_BD_Shape_inlines_hh)
bool marked_empty() const
Returns true if the BDS is known to be empty.
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type assign_r(To &to, const From &, Rounding_Dir dir)
An iterator over a system of constraints.
static bool can_recycle_congruence_systems()
Returns false indicating that this domain cannot recycle congruences.
The empty element, i.e., the empty set.
The computed result is exact.
A linear equality or inequality.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void swap(CO_Tree &x, CO_Tree &y)
bool l_infinity_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const BD_Shape< T > &x, const BD_Shape< T > &y, const Rounding_Dir dir)
bool rectilinear_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const BD_Shape< T > &x, const BD_Shape< T > &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void refine_with_constraint(const Constraint &c)
Uses a copy of constraint c to refine the system of bounded differences defining *this.
size_t dimension_type
An unsigned integral type for representing space dimensions.
An std::set of variables' indexes.
void widening_assign(const BD_Shape &y, unsigned *tp=0)
Same as H79_widening_assign(y, tp).
A line, ray, point or closure point.
Rounding_Dir
Rounding directions for arithmetic computations.
BD_Shape(dimension_type num_dimensions=0, Degenerate_Element kind=UNIVERSE)
Builds a universe or empty BDS of the specified space dimension.
bool euclidean_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const BD_Shape< T > &x, const BD_Shape< T > &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
void refine_with_constraints(const Constraint_System &cs)
Uses a copy of the constraints in cs to refine the system of bounded differences defining *this...
bool is_inconsistent() const
Returns true if and only if *this is inconsistent (i.e., an always false congruence).
void m_swap(BD_Shape &y)
Swaps *this with y (*this and y can be dimension-incompatible).
bool l_infinity_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const BD_Shape< T > &x, const BD_Shape< T > &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
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.
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_integer(const T &x)
bool is_empty() const
Returns true if and only if *this is an empty box.
void CC76_extrapolation_assign(const BD_Shape &y, unsigned *tp=0)
Assigns to *this the result of computing the CC76-extrapolation between *this and y...
Result
Possible outcomes of a checked arithmetic computation.
const_iterator end() const
Returns the past-the-end const_iterator.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
BD_Shape & operator=(const BD_Shape &y)
The assignment operator (*this and y can be dimension-incompatible).
void H79_widening_assign(const Polyhedron &y, unsigned *tp=0)
Assigns to *this the result of computing the H79_widening between *this and y.
Constraint_System constraints() const
Returns the system of constraints defining *this.
bool strictly_contains(const BD_Shape &y) const
Returns true if and only if *this strictly contains y.
const_iterator begin() const
Returns the const_iterator pointing to the first constraint, if *this is not empty; otherwise...
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
bool marked_shortest_path_closed() const
Returns true if the system of bounded differences is known to be shortest-path closed.
void set_zero_dim_univ()
Turns *this into an zero-dimensional universe BDS.
bool marked_shortest_path_reduced() const
Returns true if the system of bounded differences is known to be shortest-path reduced.
Enable_If< Is_Native_Or_Checked< T >::value, void >::type div_round_up(T &to, Coefficient_traits::const_reference x, Coefficient_traits::const_reference y)
Divides x by y into to, rounding the result towards plus infinity.
bool rectilinear_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const BD_Shape< T > &x, const BD_Shape< T > &y, const Rounding_Dir dir)
bool is_proper_congruence() const
Returns true if the modulus is greater than zero.
bool is_empty() const
Returns true if and only if *this is an empty BDS.
void refine_no_check(const Constraint &c)
Uses the constraint c to refine *this.
Bounded_Integer_Type_Overflow
void shortest_path_closure_assign() const
Assigns to this->dbm its shortest-path closure.
bool upper_bound_assign_if_exact(const BD_Shape &y)
If the upper bound of *this and y is exact, it is assigned to *this and true is returned, otherwise false is returned.
Complexity_Class
Complexity pseudo-classes.
void refine_with_congruence(const Congruence &cg)
Uses a copy of congruence cg to refine the system of bounded differences of *this.
void limited_H79_extrapolation_assign(const Polyhedron &y, const Constraint_System &cs, unsigned *tp=0)
Assigns to *this the result of computing the limited extrapolation between *this and y using the H79-...
static dimension_type max_space_dimension()
Returns the maximum space dimension that a BDS can handle.
A wrapper for numeric types implementing a given policy.
bool operator!=(const BD_Shape< T > &x, const BD_Shape< T > &y)
void time_elapse_assign(const BD_Shape &y)
Assigns to *this the result of computing the time-elapse between *this and y.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
#define PPL_COMPILE_TIME_CHECK(e, msg)
Produces a compilation error if the compile-time constant e does not evaluate to true ...
bool bounds_from_above(const Linear_Expression &expr) const
Returns true if and only if expr is bounded from above in *this.
void reset_shortest_path_closed()
Marks *this as possibly not shortest-path closed.
int32_t hash_code() const
Returns a 32-bit hash code for *this.
Relation_Symbol
Relation symbols.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
bool is_equality() const
Returns true if *this is an equality.
Degenerate_Element
Kinds of degenerate abstract elements.
void add_dbm_constraint(dimension_type i, dimension_type j, const N &k)
Adds the constraint dbm[i][j] <= k.
void swap(BD_Shape< T > &x, BD_Shape< T > &y)
static bool can_recycle_constraint_systems()
Returns false indicating that this domain cannot recycle constraints.
void add_recycled_constraints(Constraint_System &cs)
Adds the constraints in cs to the system of constraints of *this.
Greater than or equal to.
bool bounds_from_below(const Linear_Expression &expr) const
Returns true if and only if expr is bounded from below in *this.
Bounded_Integer_Type_Width
Enable_If< Is_Native< T >::value, memory_size_type >::type external_memory_in_bytes(const T &)
For native types, returns the size in bytes of the memory managed by the type of the (unused) paramet...
const_iterator end() const
Returns the past-the-end const_iterator.
const Congruence_System & minimized_congruences() const
Returns the system of congruences in minimal form.
bool euclidean_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const BD_Shape< T > &x, const BD_Shape< T > &y, const Rounding_Dir dir)
Constraint_System constraints() const
Returns a system of constraints defining *this.
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
A not necessarily closed, iso-oriented hyperrectangle.
A closed convex polyhedron.
const_iterator begin() const
Returns the const_iterator pointing to the first congruence, if this is not empty; otherwise...
bool marked_zero_dim_univ() const
Returns true if the BDS is the zero-dimensional universe.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
int32_t hash_code_from_dimension(dimension_type dim)
Returns the hash code for space dimension dim.
bool operator==(const BD_Shape< T > &x, const BD_Shape< T > &y)
void wrap_assign(PSET &pointset, const Variables_Set &vars, const Bounded_Integer_Type_Width w, const Bounded_Integer_Type_Representation r, const Bounded_Integer_Type_Overflow o, const Constraint_System *cs_p, const unsigned complexity_threshold, const bool wrap_individually, const char *class_name)
bool euclidean_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const BD_Shape< T > &x, const BD_Shape< T > &y, const Rounding_Dir dir)
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
#define PPL_DIRTY_TEMP(T, id)
A generic, not necessarily closed, possibly restricted interval.
void add_recycled_congruences(Congruence_System &cgs)
Adds to *this constraints equivalent to the congruences in cgs.
bool OK() const
Returns true if and only if *this satisfies all its invariants.
void set_shortest_path_closed()
Marks *this as shortest-path closed.
void refine_with_congruences(const Congruence_System &cgs)
Uses a copy of the congruences in cgs to refine the system of bounded differences defining *this...
Plus_Infinity PLUS_INFINITY
The entire library is confined to this namespace.
An iterator over a system of congruences.
bool contains(const BD_Shape &y) const
Returns true if and only if *this contains y.
void add_constraints(const Constraint_System &cs)
Adds the constraints in cs to the system of bounded differences defining *this.
bool integer_upper_bound_assign_if_exact(const BD_Shape &y)
If the integer upper bound of *this and y is exact, it is assigned to *this and true is returned; oth...
bool rectilinear_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const BD_Shape< T > &x, const BD_Shape< T > &y, const Rounding_Dir dir)
Constraint_System constraints() const
Returns a system of constraints defining *this.
A bounded difference shape.
bool is_discrete() const
Returns true if and only if *this is discrete.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
#define PPL_USED(v)
No-op macro that allows to avoid unused variable warnings from the compiler.
Bit_Matrix redundancy_dbm
A matrix indicating which constraints are redundant.
void refine_fp_interval_abstract_store(Box< Interval< T, Interval_Info > > &store) const
Refines store with the constraints defining *this.
void drop_some_non_integer_points_helper(N &elem)
Congruence_System congruences() const
Returns a system of (equality) congruences satisfied by *this.
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.
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.
void limited_H79_extrapolation_assign(const BD_Shape &y, const Constraint_System &cs, unsigned *tp=0)
Improves the result of the H79-widening computation by also enforcing those constraints in cs that ar...
void remove_higher_space_dimensions(dimension_type new_dimension)
Removes the higher dimensions so that the resulting space will have dimension new_dimension.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void generalized_refine_with_linear_form_inequality(const Linear_Form< Interval< T, Interval_Info > > &left, const Linear_Form< Interval< T, Interval_Info > > &right, Relation_Symbol relsym)
Refines the system of BD_Shape constraints defining *this using the constraint expressed by left rig...
void time_elapse_assign(const Polyhedron &y)
Assigns to *this the result of computing the time-elapse between *this and y.
bool l_infinity_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const BD_Shape< T > &x, const BD_Shape< T > &y, const Rounding_Dir dir)
bool is_empty() const
Returns true if and only if *this is an empty OS.
void reset_shortest_path_reduced()
Marks *this as possibly not shortest-path reduced.
void topological_closure_assign()
Assigns to *this its topological closure.
Status status
The status flags to keep track of the internal state.
void set_empty()
Turns *this into an empty BDS.
The base class for the square matrices.
void add_congruences(const Congruence_System &cgs)
Adds to *this constraints equivalent to the congruences in cgs.
void H79_widening_assign(const BD_Shape &y, unsigned *tp=0)
Assigns to *this the result of computing the H79-widening between *this and y.
Bounded_Integer_Type_Representation
DB_Matrix< N > dbm
The matrix representing the system of bounded differences.
void set_shortest_path_reduced()
Marks *this as shortest-path closed.
bool is_topologically_closed() const
Returns true if and only if *this is a topologically closed subset of the vector space.