24 #ifndef PPL_Interval_defs_hh
25 #define PPL_Interval_defs_hh 1
42 =
static_cast<unsigned>(l) | (static_cast<unsigned>(u) << 6);
49 using namespace Boundary_NS;
50 using namespace Interval_NS;
52 template <
typename T,
typename Enable =
void>
80 template <
typename Boundary,
typename Info>
84 || !std::numeric_limits<Boundary>::has_infinity,
85 "store_special is meaningless"
86 " when boundary type may contains infinity");
104 template <
typename T>
110 template <
typename T>
116 template <
typename T>
122 template <
typename T>
157 PPL_ASSERT(!is_empty());
165 PPL_ASSERT(!is_empty());
174 return lt(
UPPER, upper(), info(),
LOWER, lower(), info());
183 return eq(
LOWER, lower(), info(),
UPPER, upper(), info());
218 return !lower_is_boundary_infinity() && !upper_is_boundary_infinity();
223 return lower_is_domain_inf() && upper_is_domain_sup();
227 info().clear_boundary_properties(
LOWER);
232 template <
typename C>
234 lower_extend(
const C&
c);
237 info().clear_boundary_properties(
UPPER);
242 template <
typename C>
244 upper_extend(
const C&
c);
250 template <
typename C>
269 return refine_existential(rs, c.value());
273 template <
typename C1,
typename C2>
296 const I_Result r = add_constraint(c2);
300 template <
typename C>
305 return intersect_assign(x);
331 template <
typename From>
337 switch (From::vclass) {
365 return !Info::store_open;
370 return is_always_topologically_closed()
372 || ((lower_is_boundary_infinity() || !lower_is_open())
373 && (upper_is_boundary_infinity() || !upper_is_open()));
378 if (!Info::store_open || is_empty()) {
381 if (lower_is_open() && !lower_is_boundary_infinity()) {
382 info().set_boundary_property(
LOWER,
OPEN,
false);
384 if (upper_is_open() && !upper_is_boundary_infinity()) {
385 info().set_boundary_property(
UPPER,
OPEN,
false);
390 PPL_ASSERT(!is_empty());
391 if (!Info::store_open) {
394 info().set_boundary_property(
LOWER,
OPEN,
true);
398 PPL_ASSERT(!is_empty());
399 if (!Info::store_open) {
402 info().set_boundary_property(
UPPER,
OPEN,
true);
427 if (lower_is_open()) {
428 add_assign_r(l, lower(), Boundary(1),
ROUND_DOWN);
435 if (upper_is_open()) {
436 sub_assign_r(u, upper(), Boundary(1),
ROUND_UP);
440 floor_assign_r(u, upper(),
ROUND_UP);
449 if (lower_is_open() && !lower_is_boundary_infinity()) {
450 add_assign_r(lower(), lower(), Boundary(1),
ROUND_DOWN);
452 info().set_boundary_property(
LOWER,
OPEN,
false);
457 if (upper_is_open() && !upper_is_boundary_infinity()) {
458 sub_assign_r(upper(), upper(), Boundary(1),
ROUND_UP);
459 ceil_assign_r(upper(), upper(),
ROUND_UP);
460 info().set_boundary_property(
UPPER,
OPEN,
false);
463 floor_assign_r(upper(), upper(),
ROUND_UP);
467 template <
typename From>
471 const From& refinement) {
475 if (lower_is_boundary_infinity() || upper_is_boundary_infinity()) {
476 return assign(refinement);
481 return assign(refinement);
487 LOWER, lower(), info(), w);
489 UPPER, upper(), info(), w);
493 LOWER, lower(), info(), w);
495 UPPER, upper(), info(), w);
501 if (
le(
LOWER, lower(), info(),
UPPER, upper(), info())) {
502 return intersect_assign(refinement);
507 LOWER, lower(), info());
509 tmp.intersect_assign(refinement);
511 intersect_assign(refinement);
512 return join_assign(tmp);
525 if (!Info::may_be_empty && is_empty()) {
527 std::cerr <<
"The interval is unexpectedly empty.\n";
535 std::cerr <<
"The lower boundary is +inf open.\n";
539 else if (!Info::may_contain_infinity
543 std::cerr <<
"The lower boundary is unexpectedly infinity.\n";
550 std::cerr <<
"The lower boundary is not a number.\n";
559 std::cerr <<
"The upper boundary is -inf open.\n";
563 else if (!Info::may_contain_infinity
567 std::cerr <<
"The upper boundary is unexpectedly infinity."
575 std::cerr <<
"The upper boundary is not a number.\n";
588 template <
typename T>
599 template <
typename T>
602 contains(
const T& y)
const;
604 template <
typename T>
607 strictly_contains(
const T& y)
const;
609 template <
typename T>
612 is_disjoint_from(
const T& y)
const;
615 template <
typename From>
620 template <
typename Type>
623 can_be_exactly_joined_to(
const Type& x)
const;
625 template <
typename From>
628 join_assign(
const From& x);
630 template <
typename From1,
typename From2>
637 template <
typename From>
640 intersect_assign(
const From& x);
642 template <
typename From1,
typename From2>
647 intersect_assign(
const From1& x,
const From2& y);
653 template <
typename From>
656 difference_assign(
const From& x);
662 template <
typename From1,
typename From2>
667 difference_assign(
const From1& x,
const From2& y);
673 template <
typename From>
676 lower_approximation_difference_assign(
const From& x);
685 template <
typename From>
687 simplify_using_context_assign(
const From& y);
693 template <
typename From>
695 empty_intersection_assign(
const From& y);
712 template <
typename From>
732 template <
typename From>
737 template <
typename From>
742 template <
typename From1,
typename From2>
747 template <
typename From1,
typename From2>
752 template <
typename From1,
typename From2>
757 template <
typename From1,
typename From2>
762 template <
typename From,
typename Iterator>
764 CC76_widening_assign(
const From& y, Iterator first, Iterator last);
773 template <
typename Boundary,
typename Info>
781 #endif // !defined(PPL_Interval_defs_hh)
int result_overflow(Result r)
I_Constraint< T > i_constraint(I_Constraint_Rel rel, const T &v)
The empty element, i.e., the empty set.
The computed result is exact.
const Info & info() const
void swap(CO_Tree &x, CO_Tree &y)
I_Result
The result of an operation on intervals.
Result set_minus_infinity(Boundary_Type type, T &x, Info &info, bool open=false)
Result set_plus_infinity(Boundary_Type type, T &x, Info &info, bool open=false)
Enable_If< Is_Same_Or_Derived< I_Constraint_Base, C >::value, I_Result >::type build(const C &c)
A positive integer overflow occurred (rounding up).
Enable_If< Is_Native_Or_Checked< T >::value, void >::type ascii_dump(std::ostream &s, const T &t)
bool lt(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
Result may be empty or not empty.
int infinity_sign() const
I_Constraint< boundary_type > upper_constraint() const
Result
Possible outcomes of a checked arithmetic computation.
const Boundary & upper() const
bool upper_is_domain_sup() const
Negative infinity result class.
Enable_If< Is_Same_Or_Derived< I_Constraint_Base, C >::value, I_Result >::type add_constraint(const C &c)
bool is_reverse_infinity(Boundary_Type type, const T &x, const Info &info)
bool is_domain_inf(Boundary_Type type, const T &x, const Info &info)
bool is_minus_infinity(Boundary_Type type, const T &x, const Info &info)
static const Property OPEN(Property::OPEN_)
bool lower_is_open() const
Result may be the domain universe.
The computed result is inexact and rounded down.
static const Property SPECIAL(Property::SPECIAL_)
Enable_If< Is_Singleton< T >::value||Is_Interval< T >::value, Interval & >::type operator/=(const T &x)
Result assign(Boundary_Type to_type, To &to, To_Info &to_info, Boundary_Type type, const T &x, const Info &info, bool should_shrink=false)
Result neg_assign(Boundary_Type to_type, To &to, To_Info &to_info, Boundary_Type type, const T &x, const Info &info)
I_Result assign(Degenerate_Element e)
Enable_If< Is_Singleton< T >::value||Is_Interval< T >::value, Interval & >::type operator*=(const T &x)
Positive infinity result class.
bool lower_is_domain_inf() const
#define PPL_COMPILE_TIME_CHECK(e, msg)
Produces a compilation error if the compile-time constant e does not evaluate to true ...
bool is_open(Boundary_Type type, const T &x, const Info &info)
A class holding a constant called value that evaluates to true if and only if Base is the same type a...
Result div_assign(Boundary_Type to_type, To &to, To_Info &to_info, Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
bool contains_integer_point() const
bool lower_is_boundary_infinity() const
Relation_Symbol
Relation symbols.
void topological_closure_assign()
Assigns to *this its topological closure.
Degenerate_Element
Kinds of degenerate abstract elements.
bool is_topologically_closed() const
Greater than or equal to.
Enable_If< Is_Singleton< From >::value||Is_Interval< From >::value, I_Result >::type wrap_assign(Bounded_Integer_Type_Width w, Bounded_Integer_Type_Representation r, const From &refinement)
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...
I_Constraint< boundary_type > lower_constraint() const
bool is_plus_infinity(Boundary_Type type, const T &x, const Info &info)
bool eq(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
bool check_empty(I_Result r) const
The computed result is inexact.
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_not_a_number(const T &x)
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type ascii_load(std::istream &s, T &t)
Result sub_assign(Boundary_Type to_type, To &to, To_Info &to_info, Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
Result is definitely exact.
Interval_NS::Property Property
Result set_unbounded(Boundary_Type type, T &x, Info &info)
The computed result may be inexact and rounded up.
#define PPL_DIRTY_TEMP(T, id)
Result umod_2exp_assign(Boundary_Type to_type, To &to, To_Info &to_info, Boundary_Type type, const T &x, const Info &info, unsigned int exp)
The universe element, i.e., the whole vector space.
bool is_singleton() const
const Boundary & lower() const
A generic, not necessarily closed, possibly restricted interval.
From bool Type Type Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir From1
static bool is_always_topologically_closed()
Result mul_assign(Boundary_Type to_type, To &to, To_Info &to_info, Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
The entire library is confined to this namespace.
Signed binary where negative values are represented by the two's complement of the absolute value...
Operation has definitely changed the set.
Result add_assign(Boundary_Type to_type, To &to, To_Info &to_info, Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
The computed result may be inexact and rounded down.
From bool Type Type Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir Rounding_Dir From2
I_Result combine(Result l, Result u)
From bool Type Type Rounding_Dir From
Result smod_2exp_assign(Boundary_Type to_type, To &to, To_Info &to_info, Boundary_Type type, const T &x, const Info &info, unsigned int exp)
void drop_some_non_integer_points()
Enable_If< Is_Singleton< T >::value||Is_Interval< T >::value, Interval & >::type operator+=(const T &x)
bool upper_is_boundary_infinity() const
Enable_If< Is_Singleton< T >::value||Is_Interval< T >::value, Interval & >::type operator-=(const T &x)
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
A negative integer overflow occurred (rounding down).
Enable_If< Is_Singleton< T >::value||Is_Interval< T >::value, Interval & >::type operator=(const T &x)
The computed result is inexact and rounded up.
A class that provides a type member called type equivalent to T if and only if b is true...
Enable_If< Is_Native< T >::value, memory_size_type >::type total_memory_in_bytes(const T &)
For native types, returns the total size in bytes of the memory occupied by the type of the (unused) ...
Operation has left the set definitely unchanged.
Enable_If< Is_Special< From >::value, I_Result >::type assign(const From &)
The computed result may be inexact.
bool upper_is_open() const
Enable_If< Is_Same_Or_Derived< I_Constraint_Base, C1 >::value &&Is_Same_Or_Derived< I_Constraint_Base, C2 >::value, I_Result >::type build(const C1 &c1, const C2 &c2)
bool le(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
Bounded_Integer_Type_Representation
I_Result set_infinities()
bool is_domain_sup(Boundary_Type type, const T &x, const Info &info)
bool is_boundary_infinity(Boundary_Type type, const T &x, const Info &info)