00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef PPL_Interval_inlines_hh
00024 #define PPL_Interval_inlines_hh 1
00025
00026 #include <cassert>
00027 #include "Checked_Number.defs.hh"
00028 #include "checked_mpz.inlines.hh"
00029
00030 namespace Parma_Polyhedra_Library {
00031
00032 inline
00033 Boundary::Boundary(const ERational& v, Flag f)
00034 : value(v), flag(f) {
00035 }
00036
00037 inline bool
00038 Boundary::is_closed() const {
00039 return flag == ZERO;
00040 }
00041
00042 inline const ERational&
00043 Boundary::bound() const {
00044 return value;
00045 }
00046
00047 inline ERational&
00048 Boundary::bound() {
00049 return value;
00050 }
00051
00052 inline
00053 LBoundary::LBoundary(const ERational& v, Open_Closed f)
00054 : Boundary(v, f == CLOSED ? ZERO : POS) {
00055 }
00056
00057 inline
00058 UBoundary::UBoundary(const ERational& v, Open_Closed f)
00059 : Boundary(v, f == CLOSED ? ZERO : NEG) {
00060 }
00061
00063 inline bool
00064 operator<(const Boundary& x, const Boundary& y) {
00065 return x.value < y.value ||
00066 (x.value == y.value && x.flag < y.flag);
00067 }
00068
00070 inline bool
00071 operator>(const Boundary& x, const Boundary& y) {
00072 return y < x;
00073 }
00074
00075 inline
00076 Interval::Interval()
00077 : lower(ERational(MINUS_INFINITY), LBoundary::OPEN),
00078 upper(ERational(PLUS_INFINITY), UBoundary::OPEN) {
00079 }
00080
00081 inline bool
00082 Interval::is_empty() const {
00083 return lower > upper;
00084 }
00085
00086 inline const LBoundary&
00087 Interval::lower_bound() const {
00088 return lower;
00089 }
00090
00091 inline LBoundary&
00092 Interval::lower_bound() {
00093 return lower;
00094 }
00095
00096 inline const UBoundary&
00097 Interval::upper_bound() const {
00098 return upper;
00099 }
00100
00101 inline UBoundary&
00102 Interval::upper_bound() {
00103 return upper;
00104 }
00105
00106 inline void
00107 Interval::raise_lower_bound(LBoundary new_lower) {
00108 if (new_lower > lower)
00109 lower = new_lower;
00110 }
00111
00112 inline void
00113 Interval::lower_upper_bound(UBoundary new_upper) {
00114 if (new_upper < upper)
00115 upper = new_upper;
00116 }
00117
00118 inline void
00119 Interval::set_empty() {
00120 lower = LBoundary(ERational(PLUS_INFINITY), LBoundary::OPEN);
00121 upper = UBoundary(ERational(MINUS_INFINITY), UBoundary::OPEN);
00122 assert(is_empty());
00123 }
00124
00125 }
00126
00127 #endif // !defined(PPL_Interval_inlines_hh)