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);
112 return gaol::interval::left();
117 return gaol::interval::right();
122 double m = gaol::interval::midpoint();
123 gaol::round_upward();
129 return gaol::interval::mag();
134 return gaol::interval::mig();
144 return gaol::interval::smig();
150 return std::numeric_limits<double>::quiet_NaN();
154 double r = a + (((double)std::rand())/(double)RAND_MAX)*(b-a);
157 return std::max<double>(
lb(),std::min<double>(r,
ub()));
163 return std::numeric_limits<double>::quiet_NaN();
171 double t1 = (t-*
this).
ub();
172 double t2 = (*
this-t).
ub();
173 return (t1>t2) ? t1 : t2;
180 return std::numeric_limits<double>::quiet_NaN();
184 double d = gaol::interval::width();
185 gaol::round_upward();
207 return gaol::interval::is_empty();
212 return gaol::interval::set_contains(x);
222 return !gaol::interval::is_finite();
227 return is_empty() || gaol::interval::is_a_double();
232 return gaol::interval::is_an_int();
237 return trunc(
lb()) ==
lb() && trunc(
ub()) ==
ub();
273 (x.
lb() <
lb() && (x.
ub() == oo || x.
ub() >
ub()))
274 || (x.
ub() >
ub() && (x.
lb() == -oo || x.
lb() <
lb()))
299 return lb() < m && m <
ub();
312 return {
Interval(-oo,-std::numeric_limits<double>::max()),
Interval(-std::numeric_limits<double>::max(),
ub()) };
316 return {
Interval(
lb(),std::numeric_limits<double>::max()),
Interval(std::numeric_limits<double>::max(),oo) };
343 std::vector<Interval> l;
346 l.push_back({-oo,
lb()});
349 l.push_back({
ub(),oo});
364 std::vector<Interval> l;
381 return gaol::operator&(x,y);
386 return gaol::operator|(x,
Interval(y));
391 return gaol::operator|(x,y);
401 if(y == -oo || y == oo)
405 return gaol::operator+(x,y);
410 if(x == -oo || x == oo)
414 return gaol::operator+(x,y);
419 return gaol::operator+(x,y);
424 if(y == -oo || y == oo)
428 return gaol::operator-(x, y);
433 if(x == -oo || x == oo)
437 return gaol::operator-(x, y);
442 return gaol::operator-(x, y);
447 if(y == -oo || y == oo)
451 return gaol::operator*(x,y);
456 if(x == -oo || x == oo)
460 return gaol::operator*(x,y);
465 return gaol::operator*(x,y);
470 if(y == -oo || y == oo)
474 return gaol::operator/(x,y);
479 if(x == -oo || x == oo)
483 return gaol::operator/(x,y);
488 return gaol::operator/(x,y);
493 gaol::interval::operator|=(x);
499 gaol::interval::operator&=(x);
505 if(x == -oo || x == oo)
508 gaol::interval::operator+=(x);
514 gaol::interval::operator+=(x);
525 if(x == -oo || x == oo)
528 gaol::interval::operator-=(x);
534 gaol::interval::operator-=(x);
540 if(x == -oo || x == oo)
543 gaol::interval::operator*=(x);
549 gaol::interval::operator*=(x);
555 if(x == -oo || x == oo)
558 gaol::interval::operator/=(x);
564 gaol::interval::operator/=(x);
570 return std::numeric_limits<double>::quiet_NaN();
575 return gaol::interval::zero();
580 return gaol::interval::one();
585 return gaol::interval::half_pi();
590 return gaol::interval::pi();
595 return gaol::interval::two_pi();
600 gaol::interval::precision(os.precision());
601 gaol::operator<<(os,x);
616 return gaol::previous_float(x);
621 return gaol::next_float(x);
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:49
double smig() const
Returns the signed mignitude of this.
Definition codac2_Interval_impl.h:142
bool is_unbounded() const
Tests if one of the bounds of this is infinite.
Definition codac2_Interval_impl.h:220
Interval & operator*=(double x)
Self multiplication of this and a real x.
Definition codac2_Interval_impl.h:538
Interval & operator-=(double x)
Self substraction of this and a real x.
Definition codac2_Interval_impl.h:523
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:205
double mig() const
Returns the mignitude of this.
Definition codac2_Interval_impl.h:132
bool is_bisectable() const
Tests if this can be bisected into two non-degenerated intervals.
Definition codac2_Interval_impl.h:294
Interval & inflate(const double &rad)
Adds [-rad,+rad] to this.
Definition codac2_Interval_impl.h:288
static Interval one()
Provides an interval for .
Definition codac2_Interval_impl.h:578
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:115
bool intersects(const Interval &x) const
Tests if this and x intersect.
Definition codac2_Interval_impl.h:240
double volume() const
Returns the diameter of this.
Definition codac2_Interval_impl.h:190
bool interior_contains(const double &x) const
Tests if the interior of this contains x.
Definition codac2_Interval_impl.h:215
static Interval pi()
Provides an interval for .
Definition codac2_Interval_impl.h:588
double rand() const
Returns a random value inside the interval.
Definition codac2_Interval_impl.h:147
std::pair< Interval, Interval > bisect(float ratio=0.49) const
Bisects this into two subintervals.
Definition codac2_Interval_impl.h:302
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:230
std::vector< Interval > diff(const Interval &y, bool compactness=true) const
Computes the result of .
Definition codac2_Interval_impl.h:354
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:260
bool is_interior_subset(const Interval &x) const
Tests if this is in the interior of x.
Definition codac2_Interval_impl.h:265
bool is_degenerated() const
Tests if this is degenerated, that is, in the form of .
Definition codac2_Interval_impl.h:225
std::vector< Interval > complementary(bool compactness=true) const
Computes the complementary of this.
Definition codac2_Interval_impl.h:338
Interval & operator/=(double x)
Self division of this and a real x.
Definition codac2_Interval_impl.h:553
double diam() const
Returns the diameter of this.
Definition codac2_Interval_impl.h:177
Interval & operator+=(double x)
Self addition of this and a real x.
Definition codac2_Interval_impl.h:503
bool is_disjoint(const Interval &x) const
Tests if this and x do not intersect.
Definition codac2_Interval_impl.h:245
Interval & operator&=(const Interval &x)
Self intersection of this and x.
Definition codac2_Interval_impl.h:497
static Interval zero()
Provides an interval for .
Definition codac2_Interval_impl.h:573
Index size() const
Returns the dimension of this (which is always )
Definition codac2_Interval_impl.h:195
bool is_superset(const Interval &x) const
Tests if this is a superset of x.
Definition codac2_Interval_impl.h:278
double rad() const
Returns the radius of this.
Definition codac2_Interval_impl.h:160
double mag() const
Returns the magnitude of this i.e. max(|lower bound|, |upper bound|).
Definition codac2_Interval_impl.h:127
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:250
void set_empty()
Sets this interval to the empty set.
Definition codac2_Interval_impl.h:200
bool is_subset(const Interval &x) const
Tests if this is a subset of x.
Definition codac2_Interval_impl.h:255
Interval & operator|=(const Interval &x)
Self union of this and x.
Definition codac2_Interval_impl.h:491
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:210
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:110
bool has_integer_bounds() const
Checks whether the interval has integer lower and upper bounds.
Definition codac2_Interval_impl.h:235
static Interval two_pi()
Provides an interval for .
Definition codac2_Interval_impl.h:593
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:270
Interval & init()
Sets the value of this interval to [-oo,oo].
Definition codac2_Interval_impl.h:56
double smag() const
Returns the signed magnitude of this i.e. lower bound if |lower bound|>|upper bound|,...
Definition codac2_Interval_impl.h:137
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:283
double mid() const
Returns the midpoint of this.
Definition codac2_Interval_impl.h:120
static Interval empty()
Provides an empty interval.
Definition codac2_Interval_impl.h:568
Interval operator-() const
Substraction of this.
Definition codac2_Interval_impl.h:518
static Interval half_pi()
Provides an interval for .
Definition codac2_Interval_impl.h:583
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:614
Interval operator*(const Interval &x, double y)
Returns with .
Definition codac2_Interval_impl.h:445
Interval operator/(const Interval &x, double y)
Returns with .
Definition codac2_Interval_impl.h:468
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:64
Interval operator-(const Interval &x, double y)
Returns with .
Definition codac2_Interval_impl.h:422
double next_float(double x)
Returns the next representable double-precision floating-point value after x.
Definition codac2_Interval_impl.h:619
Interval abs(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:264