24 #ifndef PPL_Box_inlines_hh
25 #define PPL_Box_inlines_hh 1
36 template <
typename ITV>
39 return status.test_empty_up_to_date() && status.test_empty();
42 template <
typename ITV>
46 status.set_empty_up_to_date();
49 template <
typename ITV>
53 status.set_empty_up_to_date();
56 template <
typename ITV>
59 status.set_empty_up_to_date();
62 template <
typename ITV>
65 return status.reset_empty_up_to_date();
68 template <
typename ITV>
71 : seq(y.seq), status(y.status) {
74 template <
typename ITV>
82 template <
typename ITV>
91 template <
typename ITV>
99 template <
typename ITV>
107 template <
typename ITV>
115 template <
typename ITV>
121 template <
typename ITV>
127 template <
typename ITV>
135 template <
typename ITV>
141 template <
typename ITV>
144 PPL_ASSERT(k < seq.size());
148 template <
typename ITV>
152 throw_dimension_incompatible(
"get_interval(v)",
"v", var);
155 static ITV empty_interval(
EMPTY);
156 return empty_interval;
159 return seq[var.
id()];
162 template <
typename ITV>
167 throw_dimension_incompatible(
"set_interval(v, i)",
"v", var);
170 if (is_empty() && space_dim >= 2) {
176 reset_empty_up_to_date();
181 template <
typename ITV>
184 return marked_empty() || check_empty();
187 template <
typename ITV>
190 return bounds(expr,
true);
193 template <
typename ITV>
196 return bounds(expr,
false);
199 template <
typename ITV>
203 bool& maximum)
const {
204 return max_min(expr,
true, sup_n, sup_d, maximum);
207 template <
typename ITV>
212 return max_min(expr,
true, sup_n, sup_d, maximum, g);
215 template <
typename ITV>
219 bool& minimum)
const {
220 return max_min(expr,
false, inf_n, inf_d, minimum);
223 template <
typename ITV>
228 return max_min(expr,
false, inf_n, inf_d, minimum, g);
231 template <
typename ITV>
234 const Box& x = *
this;
238 template <
typename ITV>
245 throw_dimension_incompatible(
"expand_space_dimension(v, m)",
"v", var);
251 throw_invalid_argument(
"expand_dimension(v, m)",
252 "adding m new space dimensions exceeds "
253 "the maximum allowed space dimension");
258 seq.insert(seq.end(), m, seq[var.
id()]);
262 template <
typename ITV>
268 template <
typename ITV>
274 PPL_ASSERT(!marked_empty());
276 PPL_ASSERT(k < seq.size());
277 const ITV& seq_k = seq[k];
279 if (seq_k.lower_is_boundary_infinity()) {
282 closed = !seq_k.lower_is_open();
292 template <
typename ITV>
298 PPL_ASSERT(!marked_empty());
300 PPL_ASSERT(k < seq.size());
301 const ITV& seq_k = seq[k];
303 if (seq_k.upper_is_boundary_infinity()) {
307 closed = !seq_k.upper_is_open();
317 template <
typename ITV>
322 if (c_space_dim > space_dimension()) {
323 throw_dimension_incompatible(
"add_constraint(c)", c);
326 add_constraint_no_check(c);
329 template <
typename ITV>
334 throw_dimension_incompatible(
"add_constraints(cs)", cs);
337 add_constraints_no_check(cs);
340 template <
typename T>
346 template <
typename ITV>
351 if (cg_space_dim > space_dimension()) {
352 throw_dimension_incompatible(
"add_congruence(cg)", cg);
355 add_congruence_no_check(cg);
358 template <
typename ITV>
362 throw_dimension_incompatible(
"add_congruences(cgs)", cgs);
364 add_congruences_no_check(cgs);
367 template <
typename T>
370 add_congruences(cgs);
373 template <
typename T>
379 template <
typename T>
385 template <
typename T>
388 CC76_widening_assign(y, tp);
391 template <
typename ITV>
395 return congruences();
398 template <
typename ITV>
403 Coefficient_traits::const_reference numer,
404 Coefficient_traits::const_reference denom) {
405 PPL_ASSERT(denom != 0);
435 PPL_ASSERT(itv.OK());
439 template <
typename ITV>
444 Coefficient_traits::const_reference numer,
445 Coefficient_traits::const_reference denom) {
446 PPL_ASSERT(!marked_empty());
447 PPL_ASSERT(var_id < space_dimension());
448 PPL_ASSERT(denom != 0);
449 refine_interval_no_check(seq[var_id], type, numer, denom);
453 reset_empty_up_to_date();
457 template <
typename ITV>
462 if (c_space_dim > space_dimension()) {
463 throw_dimension_incompatible(
"refine_with_constraint(c)", c);
467 if (marked_empty()) {
474 template <
typename ITV>
479 throw_dimension_incompatible(
"refine_with_constraints(cs)", cs);
483 if (marked_empty()) {
489 template <
typename ITV>
494 if (cg_space_dim > space_dimension()) {
495 throw_dimension_incompatible(
"refine_with_congruence(cg)", cg);
498 if (marked_empty()) {
504 template <
typename ITV>
509 throw_dimension_incompatible(
"refine_with_congruences(cgs)", cgs);
513 if (marked_empty()) {
517 refine_no_check(cgs);
520 template <
typename ITV>
525 if (c_space_dim > space_dimension()) {
526 throw_dimension_incompatible(
"propagate_constraint(c)", c);
530 if (marked_empty()) {
533 propagate_constraint_no_check(c);
536 template <
typename ITV>
542 throw_dimension_incompatible(
"propagate_constraints(cs)", cs);
546 if (marked_empty()) {
550 propagate_constraints_no_check(cs, max_iterations);
553 template <
typename ITV>
558 if (space_dimension() < var_id + 1) {
559 throw_dimension_incompatible(
"unconstrain(var)", var_id + 1);
563 if (marked_empty()) {
569 ITV& seq_var = seq[var_id];
570 if (seq_var.is_empty()) {
581 template <
typename Temp,
typename To,
typename ITV>
590 return l_m_distance_assign<Rectilinear_Distance_Specialization<Temp> >
591 (r, x, y, dir, tmp0, tmp1, tmp2);
595 template <
typename Temp,
typename To,
typename ITV>
605 return rectilinear_distance_assign(r, x, y, dir, tmp0, tmp1, tmp2);
609 template <
typename To,
typename ITV>
617 return Parma_Polyhedra_Library
618 ::rectilinear_distance_assign<To, To, ITV>(r, x, y, dir);
622 template <
typename Temp,
typename To,
typename ITV>
631 return l_m_distance_assign<Euclidean_Distance_Specialization<Temp> >
632 (r, x, y, dir, tmp0, tmp1, tmp2);
636 template <
typename Temp,
typename To,
typename ITV>
646 return euclidean_distance_assign(r, x, y, dir, tmp0, tmp1, tmp2);
650 template <
typename To,
typename ITV>
658 return Parma_Polyhedra_Library
659 ::euclidean_distance_assign<To, To, ITV>(r, x, y, dir);
663 template <
typename Temp,
typename To,
typename ITV>
672 return l_m_distance_assign<L_Infinity_Distance_Specialization<Temp> >
673 (r, x, y, dir, tmp0, tmp1, tmp2);
677 template <
typename Temp,
typename To,
typename ITV>
687 return l_infinity_distance_assign(r, x, y, dir, tmp0, tmp1, tmp2);
691 template <
typename To,
typename ITV>
699 return Parma_Polyhedra_Library
700 ::l_infinity_distance_assign<To, To, ITV>(r, x, y, dir);
704 template <
typename ITV>
712 #endif // !defined(PPL_Box_inlines_hh)
Congruence_System minimized_congruences() const
Returns a minimized system of congruences approximating *this.
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type assign_r(To &to, const From &, Rounding_Dir dir)
void m_swap(Box &y)
Swaps *this with y (*this and y can be dimension-incompatible).
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
I_Constraint< T > i_constraint(I_Constraint_Rel rel, const T &v)
The empty element, i.e., the empty set.
dimension_type max_space_dimension()
Returns the maximum space dimension this library can handle.
A linear equality or inequality.
std::vector< ITV > Sequence
The type of sequence used to implement the box.
void propagate_constraints(const Constraint_System &cs, dimension_type max_iterations=0)
Use the constraints in cs for constraint propagation on *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void swap(CO_Tree &x, CO_Tree &y)
I_Result
The result of an operation on intervals.
bool l_infinity_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const Box< ITV > &x, const Box< ITV > &y, const Rounding_Dir dir)
size_t dimension_type
An unsigned integral type for representing space dimensions.
Box(dimension_type num_dimensions=0, Degenerate_Element kind=UNIVERSE)
Builds a universe or empty box of the specified space dimension.
Status status
The status flags to keep track of the internal state.
bool euclidean_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const Box< ITV > &x, const Box< ITV > &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
void refine_with_constraint(const Constraint &c)
Use the constraint c to refine *this.
A line, ray, point or closure point.
Rounding_Dir
Rounding directions for arithmetic computations.
Result may be empty or not empty.
bool is_empty() const
Returns true if and only if *this is an empty box.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Box & operator=(const Box &y)
The assignment operator (*this and y can be dimension-incompatible).
void unconstrain(Variable var)
Computes the cylindrification of *this with respect to space dimension var, assigning the result to *...
void add_constraints(const Constraint_System &cs)
Adds the constraints in cs to the system of constraints defining *this.
bool rectilinear_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const Box< ITV > &x, const Box< ITV > &y, const Rounding_Dir dir)
void refine_with_constraints(const Constraint_System &cs)
Use the constraints in cs to refine *this.
dimension_type id() const
Returns the index of the Cartesian axis associated to the variable.
A dimension of the vector space.
const ITV & operator[](dimension_type k) const
Returns a reference the interval that bounds the box on the k-th space dimension. ...
void widening_assign(const Box &y, unsigned *tp=0)
Same as CC76_widening_assign(y, tp).
Complexity_Class
Complexity pseudo-classes.
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
void expand_space_dimension(Variable var, dimension_type m)
Creates m copies of the space dimension corresponding to var.
void propagate_constraint(const Constraint &c)
Use the constraint c for constraint propagation on *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
A wrapper for numeric types implementing a given policy.
bool rectilinear_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const Box< ITV > &x, const Box< ITV > &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 swap(Box< ITV > &x, Box< ITV > &y)
bool l_infinity_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const Box< ITV > &x, const Box< ITV > &y, const Rounding_Dir dir)
void add_recycled_constraints(Constraint_System &cs)
Adds the constraints in cs to the system of constraints defining *this.
bool rectilinear_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const Box< ITV > &x, const Box< ITV > &y, const Rounding_Dir dir)
Relation_Symbol
Relation symbols.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void add_recycled_congruences(Congruence_System &cgs)
Adds to *this constraints equivalent to the congruences in cgs.
Greater than or equal to.
void reset_empty_up_to_date()
Invalidates empty flag of *this.
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...
void set_nonempty()
Marks *this as definitely not empty.
bool has_upper_bound(Variable var, Coefficient &n, Coefficient &d, bool &closed) const
If the space dimension of var is unbounded above, return false. Otherwise return true and set n...
Sequence seq
A sequence of intervals, one for each dimension of the vector space.
static dimension_type max_space_dimension()
Returns the maximum space dimension that a Box can handle.
A not necessarily closed, iso-oriented hyperrectangle.
static I_Result refine_interval_no_check(ITV &itv, Constraint::Type type, Coefficient_traits::const_reference numer, Coefficient_traits::const_reference denom)
WRITE ME.
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.
int32_t hash_code() const
Returns a 32-bit hash code for *this.
static bool can_recycle_constraint_systems()
Returns false indicating that this domain does not recycle constraints.
bool bounds_from_above(const Linear_Expression &expr) const
Returns true if and only if expr is bounded from above in *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
#define PPL_DIRTY_TEMP(T, id)
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.
The universe element, i.e., the whole 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.
bool has_lower_bound(Variable var, Coefficient &n, Coefficient &d, bool &closed) const
If the space dimension of var is unbounded below, return false. Otherwise return true and set n...
The entire library is confined to this namespace.
const ITV & get_interval(Variable var) const
Returns a reference the interval that bounds var.
void add_congruence(const Congruence &cg)
Adds to *this a constraint equivalent to the congruence cg.
bool l_infinity_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const Box< ITV > &x, const Box< ITV > &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
void set_empty_up_to_date()
Asserts the validity of the empty flag of *this.
void refine_with_congruences(const Congruence_System &cgs)
Use the congruences in cgs to refine *this.
static bool can_recycle_congruence_systems()
Returns false indicating that this domain does not recycle congruences.
bool bounds_from_below(const Linear_Expression &expr) const
Returns true if and only if expr is bounded from below in *this.
bool strictly_contains(const Box &y) const
Returns true if and only if *this strictly contains y.
bool euclidean_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const Box< ITV > &x, const Box< ITV > &y, const Rounding_Dir dir)
bool euclidean_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const Box< ITV > &x, const Box< ITV > &y, const Rounding_Dir dir)
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
bool contains(const Box &y) const
Returns true if and only if *this contains y.
void add_constraint(const Constraint &c)
Adds a copy of constraint c to the system of constraints defining *this.
void add_congruences(const Congruence_System &cgs)
Adds to *this constraints equivalent to the congruences in cgs.
void add_interval_constraint_no_check(dimension_type var_id, Constraint::Type type, Coefficient_traits::const_reference numer, Coefficient_traits::const_reference denom)
WRITE ME.
void set_interval(Variable var, const ITV &i)
Sets to i the interval that bounds var.
bool marked_empty() const
Returns true if and only if the box is known to be empty.
void refine_with_congruence(const Congruence &cg)
Use the congruence cg to refine *this.
void set_empty()
Causes the box to become empty, i.e., to represent the empty set.