24 : gaol::interval(-oo,oo)
30 if(a == -oo || a == oo)
73 else if(l.size() == 2)
74 *
this =
Interval(*l.begin(),*std::prev(l.end()));
78 assert_release(
"'Interval' can only be defined by one or two 'double' values.");
86 if(x == -oo || x == oo)
89 gaol::interval::operator=(x);
96 gaol::interval::operator=(x);
107 return !(*
this == x);
114 if(this->
ub() < x.
lb())
115 return BoolInterval::TRUE;
116 if(x.
ub() <= this->lb())
117 return BoolInterval::FALSE;
128 return gaol::interval::left();
133 return gaol::interval::right();
138 double m = gaol::interval::midpoint();
139 gaol::round_upward();
145 return gaol::interval::mag();
150 return gaol::interval::mig();
160 return gaol::interval::smig();
166 return std::numeric_limits<double>::quiet_NaN();
170 double r = a + (((double)std::rand())/(double)RAND_MAX)*(b-a);
173 return std::max<double>(
lb(),std::min<double>(r,
ub()));
179 return std::numeric_limits<double>::quiet_NaN();
187 double t1 = (t-*
this).
ub();
188 double t2 = (*
this-t).
ub();
189 return (t1>t2) ? t1 : t2;
196 return std::numeric_limits<double>::quiet_NaN();
200 double d = gaol::interval::width();
201 gaol::round_upward();
223 return gaol::interval::is_empty();
228 return gaol::interval::set_contains(x);
238 return !gaol::interval::is_finite();
243 return is_empty() || gaol::interval::is_a_double();
248 return gaol::interval::is_an_int();
253 return trunc(
lb()) ==
lb() && trunc(
ub()) ==
ub();
289 (x.
lb() <
lb() && (x.
ub() == oo || x.
ub() >
ub()))
290 || (x.
ub() >
ub() && (x.
lb() == -oo || x.
lb() <
lb()))
315 return lb() < m && m <
ub();
328 return {
Interval(-oo,-std::numeric_limits<double>::max()),
Interval(-std::numeric_limits<double>::max(),
ub()) };
332 return {
Interval(
lb(),std::numeric_limits<double>::max()),
Interval(std::numeric_limits<double>::max(),oo) };
359 std::vector<Interval> l;
362 l.push_back({-oo,
lb()});
365 l.push_back({
ub(),oo});
380 std::vector<Interval> l;
397 return gaol::operator&(x,y);
402 return gaol::operator|(x,
Interval(y));
407 return gaol::operator|(x,y);
417 if(y == -oo || y == oo)
421 return gaol::operator+(x,y);
426 if(x == -oo || x == oo)
430 return gaol::operator+(x,y);
435 return gaol::operator+(x,y);
440 if(y == -oo || y == oo)
444 return gaol::operator-(x, y);
449 if(x == -oo || x == oo)
453 return gaol::operator-(x, y);
458 return gaol::operator-(x, y);
463 if(y == -oo || y == oo)
467 return gaol::operator*(x,y);
472 if(x == -oo || x == oo)
476 return gaol::operator*(x,y);
481 return gaol::operator*(x,y);
486 if(y == -oo || y == oo)
490 return gaol::operator/(x,y);
495 if(x == -oo || x == oo)
499 return gaol::operator/(x,y);
504 return gaol::operator/(x,y);
509 gaol::interval::operator|=(x);
515 gaol::interval::operator&=(x);
521 if(x == -oo || x == oo)
524 gaol::interval::operator+=(x);
530 gaol::interval::operator+=(x);
541 if(x == -oo || x == oo)
544 gaol::interval::operator-=(x);
550 gaol::interval::operator-=(x);
556 if(x == -oo || x == oo)
559 gaol::interval::operator*=(x);
565 gaol::interval::operator*=(x);
571 if(x == -oo || x == oo)
574 gaol::interval::operator/=(x);
580 gaol::interval::operator/=(x);
586 return std::numeric_limits<double>::quiet_NaN();
591 return gaol::interval::zero();
596 return gaol::interval::one();
601 return gaol::interval::half_pi();
606 return gaol::interval::pi();
611 return gaol::interval::two_pi();
616 gaol::interval::precision(os.precision());
617 gaol::operator<<(os,x);
632 return gaol::previous_float(x);
637 return gaol::next_float(x);
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:50
double smig() const
Returns the signed mignitude of this.
Definition codac2_Interval_impl.h:158
bool is_unbounded() const
Tests if one of the bounds of this is infinite.
Definition codac2_Interval_impl.h:236
Interval & operator*=(double x)
Self multiplication of this and a real x.
Definition codac2_Interval_impl.h:554
Interval & operator-=(double x)
Self substraction of this and a real x.
Definition codac2_Interval_impl.h:539
bool operator==(const Interval &x) const
Comparison (equality) between two intervals.
Definition codac2_Interval_impl.h:100
bool is_empty() const
Tests if this is empty.
Definition codac2_Interval_impl.h:221
double mig() const
Returns the mignitude of this.
Definition codac2_Interval_impl.h:148
bool is_bisectable() const
Tests if this can be bisected into two non-degenerated intervals.
Definition codac2_Interval_impl.h:310
Interval & inflate(const double &rad)
Adds [-rad,+rad] to this.
Definition codac2_Interval_impl.h:304
static Interval one()
Provides an interval for .
Definition codac2_Interval_impl.h:594
Interval & init_from_list(const std::list< double > &l)
Sets the bounds as the hull of a list of values.
Definition codac2_Interval_impl.h:68
double ub() const
Returns the upper bound of this.
Definition codac2_Interval_impl.h:131
bool intersects(const Interval &x) const
Tests if this and x intersect.
Definition codac2_Interval_impl.h:256
double volume() const
Returns the diameter of this.
Definition codac2_Interval_impl.h:206
bool interior_contains(const double &x) const
Tests if the interior of this contains x.
Definition codac2_Interval_impl.h:231
static Interval pi()
Provides an interval for .
Definition codac2_Interval_impl.h:604
double rand() const
Returns a random value inside the interval.
Definition codac2_Interval_impl.h:163
std::pair< Interval, Interval > bisect(float ratio=0.49) const
Bisects this into two subintervals.
Definition codac2_Interval_impl.h:318
bool is_integer() const
Tests if this is an integer, that is, in the form of where n is an integer.
Definition codac2_Interval_impl.h:246
std::vector< Interval > diff(const Interval &y, bool compactness=true) const
Computes the result of .
Definition codac2_Interval_impl.h:370
bool is_strict_subset(const Interval &x) const
Tests if this is a subset of x and not x itself.
Definition codac2_Interval_impl.h:276
bool is_interior_subset(const Interval &x) const
Tests if this is in the interior of x.
Definition codac2_Interval_impl.h:281
bool is_degenerated() const
Tests if this is degenerated, that is, in the form of .
Definition codac2_Interval_impl.h:241
std::vector< Interval > complementary(bool compactness=true) const
Computes the complementary of this.
Definition codac2_Interval_impl.h:354
Interval & operator/=(double x)
Self division of this and a real x.
Definition codac2_Interval_impl.h:569
double diam() const
Returns the diameter of this.
Definition codac2_Interval_impl.h:193
BoolInterval operator<(const Interval &x) const
Comparison (strict less-than) between this and x.
Definition codac2_Interval_impl.h:110
Interval & operator+=(double x)
Self addition of this and a real x.
Definition codac2_Interval_impl.h:519
bool is_disjoint(const Interval &x) const
Tests if this and x do not intersect.
Definition codac2_Interval_impl.h:261
Interval & operator&=(const Interval &x)
Self intersection of this and x.
Definition codac2_Interval_impl.h:513
static Interval zero()
Provides an interval for .
Definition codac2_Interval_impl.h:589
Index size() const
Returns the dimension of this (which is always ).
Definition codac2_Interval_impl.h:211
bool is_superset(const Interval &x) const
Tests if this is a superset of x.
Definition codac2_Interval_impl.h:294
double rad() const
Returns the radius of this.
Definition codac2_Interval_impl.h:176
double mag() const
Returns the magnitude of this i.e. max(|lower bound|, |upper bound|).
Definition codac2_Interval_impl.h:143
bool overlaps(const Interval &x) const
Tests if this and x intersect and their intersection has a non-null volume.
Definition codac2_Interval_impl.h:266
void set_empty()
Sets this interval to the empty set.
Definition codac2_Interval_impl.h:216
bool is_subset(const Interval &x) const
Tests if this is a subset of x.
Definition codac2_Interval_impl.h:271
Interval & operator|=(const Interval &x)
Self union of this and x.
Definition codac2_Interval_impl.h:507
Interval & operator=(double x)
Sets this to x.
Definition codac2_Interval_impl.h:84
Interval()
Creates an interval .
Definition codac2_Interval_impl.h:23
bool contains(const double &x) const
Tests if this contains x.
Definition codac2_Interval_impl.h:226
bool operator!=(const Interval &x) const
Comparison (non equality) between two intervals.
Definition codac2_Interval_impl.h:105
double lb() const
Returns the lower bound of this.
Definition codac2_Interval_impl.h:126
bool has_integer_bounds() const
Checks whether the interval has integer lower and upper bounds.
Definition codac2_Interval_impl.h:251
static Interval two_pi()
Provides an interval for .
Definition codac2_Interval_impl.h:609
bool is_strict_interior_subset(const Interval &x) const
Tests if this is in the interior of x and different from x.
Definition codac2_Interval_impl.h:286
Interval & init()
Sets the value of this interval to [-oo,oo].
Definition codac2_Interval_impl.h:56
BoolInterval operator>(const Interval &x) const
Comparison (strict greater-than) between this and x.
Definition codac2_Interval_impl.h:121
double smag() const
Returns the signed magnitude of this i.e. lower bound if |lower bound|>|upper bound|,...
Definition codac2_Interval_impl.h:153
bool is_strict_superset(const Interval &x) const
Tests if this is a superset of x and different from x.
Definition codac2_Interval_impl.h:299
double mid() const
Returns the midpoint of this.
Definition codac2_Interval_impl.h:136
static Interval empty()
Provides an empty interval.
Definition codac2_Interval_impl.h:584
Interval operator-() const
Substraction of this.
Definition codac2_Interval_impl.h:534
static Interval half_pi()
Provides an interval for .
Definition codac2_Interval_impl.h:599
Definition codac2_OctaSym.h:21
double prev_float(double x)
Returns the previous representable double-precision floating-point value before x.
Definition codac2_Interval_impl.h:630
Interval operator*(const Interval &x, double y)
Returns with .
Definition codac2_Interval_impl.h:461
Interval operator/(const Interval &x, double y)
Returns with .
Definition codac2_Interval_impl.h:484
Ellipsoid operator+(const Ellipsoid &e1, const Ellipsoid &e2)
Compute the Minkowski sum of two ellipsoids.
std::ostream & operator<<(std::ostream &os, const BoolInterval &x)
Streams out a BoolInterval.
Definition codac2_BoolInterval.h:131
CtcInterType< typenameC1::ContractedTypes >::Ctc operator&(const C1 &c1, const C2 &c2)
Builds an intersection contractor from two contractors.
Definition codac2_CtcInter.h:229
Interval operator-(const Interval &x, double y)
Returns with .
Definition codac2_Interval_impl.h:438
BoolInterval
Enumeration representing a boolean interval.
Definition codac2_BoolInterval.h:26
@ UNKNOWN
Definition codac2_BoolInterval.h:32
@ EMPTY
Definition codac2_BoolInterval.h:30
double next_float(double x)
Returns the next representable double-precision floating-point value after x.
Definition codac2_Interval_impl.h:635
Interval abs(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:264