codac 2.0.0
Loading...
Searching...
No Matches
codac2::Interval Class Reference

Interval class, for representing closed and connected subsets of \(\mathbb{R}\). More...

#include <codac2_Interval.h>

Public Member Functions

 Interval ()
 Creates an interval \([-\infty,\infty]\).
 
 Interval (double a)
 Creates a degenerate interval \([a,a]\), \(a\in\mathbb{R}\).
 
 Interval (double a, double b)
 Creates an interval \([a,b]\), \(a\in\mathbb{R}, b\in\mathbb{R}\).
 
 Interval (const Interval &x)
 Creates an interval from another one.
 
 Interval (const std::array< double, 1 > &array)
 Create an interval \([a,a]\) from a fixed-sized array of size 1.
 
 Interval (const std::array< double, 2 > &array)
 Create an interval \([a,b]\) from a fixed-sized array of size 2.
 
 Interval (std::initializer_list< double > l)
 Create an interval as the hull of a list of values.
 
Intervalinit ()
 Sets the value of this interval to [-oo,oo].
 
Intervalinit (const Interval &x)
 Sets the value of this interval to x.
 
Intervalinit_from_list (const std::list< double > &l)
 Sets the bounds as the hull of a list of values.
 
Intervaloperator= (double x)
 Sets this to x.
 
Intervaloperator= (const Interval &x)
 Sets this to x.
 
bool operator== (const Interval &x) const
 Comparison (equality) between two intervals.
 
bool operator!= (const Interval &x) const
 Comparison (non equality) between two intervals.
 
double lb () const
 Returns the lower bound of this.
 
double ub () const
 Returns the upper bound of this.
 
double mid () const
 Returns the midpoint of this.
 
double mag () const
 Returns the magnitude of this i.e. max(|lower bound|, |upper bound|).
 
double mig () const
 Returns the mignitude of this.
 
double smag () const
 Returns the signed magnitude of this i.e. lower bound if |lower bound|>|upper bound|, upper bound otherwise.
 
double smig () const
 Returns the signed mignitude of this.
 
double rand () const
 Returns a random value inside the interval.
 
double rad () const
 Returns the radius of this.
 
double diam () const
 Returns the diameter of this.
 
double volume () const
 Returns the diameter of this.
 
Index size () const
 Returns the dimension of this (which is always )
 
void set_empty ()
 Sets this interval to the empty set.
 
bool is_empty () const
 Tests if this is empty.
 
bool contains (const double &x) const
 Tests if this contains x.
 
bool interior_contains (const double &x) const
 Tests if the interior of this contains x.
 
bool is_unbounded () const
 Tests if one of the bounds of this is infinite.
 
bool is_degenerated () const
 Tests if this is degenerated, that is, in the form of \([a,a]\).
 
bool is_integer () const
 Tests if this is an integer, that is, in the form of \([n,n]\) where n is an integer.
 
bool has_integer_bounds () const
 Checks whether the interval has integer lower and upper bounds.
 
bool intersects (const Interval &x) const
 Tests if this and x intersect.
 
bool is_disjoint (const Interval &x) const
 Tests if this and x do not intersect.
 
bool overlaps (const Interval &x) const
 Tests if this and x intersect and their intersection has a non-null volume.
 
bool is_subset (const Interval &x) const
 Tests if this is a subset of x.
 
bool is_strict_subset (const Interval &x) const
 Tests if this is a subset of x and not x itself.
 
bool is_interior_subset (const Interval &x) const
 Tests if this is in the interior of x.
 
bool is_strict_interior_subset (const Interval &x) const
 Tests if this is in the interior of x and different from x.
 
bool is_superset (const Interval &x) const
 Tests if this is a superset of x.
 
bool is_strict_superset (const Interval &x) const
 Tests if this is a superset of x and different from x.
 
Intervalinflate (const double &rad)
 Adds [-rad,+rad] to this.
 
bool is_bisectable () const
 Tests if this can be bisected into two non-degenerated intervals.
 
std::pair< Interval, Intervalbisect (float ratio=0.49) const
 Bisects this into two subintervals.
 
std::vector< Intervalcomplementary (bool compactness=true) const
 Computes the complementary of this.
 
std::vector< Intervaldiff (const Interval &y, bool compactness=true) const
 Computes the result of \([x]\backslash[y]\).
 
Intervaloperator|= (const Interval &x)
 Self union of this and x.
 
Intervaloperator&= (const Interval &x)
 Self intersection of this and x.
 
Intervaloperator+= (double x)
 Self addition of this and a real x.
 
Intervaloperator+= (const Interval &x)
 Self addition of this and x.
 
Interval operator- () const
 Substraction of this.
 
Intervaloperator-= (double x)
 Self substraction of this and a real x.
 
Intervaloperator-= (const Interval &x)
 Self substraction of this and x.
 
Intervaloperator*= (double x)
 Self multiplication of this and a real x.
 
Intervaloperator*= (const Interval &x)
 Self multiplication of this and x.
 
Intervaloperator/= (double x)
 Self division of this and a real x.
 
Intervaloperator/= (const Interval &x)
 Self division of this and x.
 

Static Public Member Functions

static Interval empty ()
 Provides an empty interval.
 
static Interval zero ()
 Provides an interval for \([0]\).
 
static Interval one ()
 Provides an interval for \([1]\).
 
static Interval half_pi ()
 Provides an interval for \([\frac{\pi}{2}]\).
 
static Interval pi ()
 Provides an interval for \([\pi]\).
 
static Interval two_pi ()
 Provides an interval for \([2\pi]\).
 

Detailed Description

Interval class, for representing closed and connected subsets of \(\mathbb{R}\).

The class also encapsulates the interval representation provided by the Gaol library.

This class reuses several functions developed for ibex::Interval. See ibex::Interval (IBEX lib, main author: Gilles Chabert) https://ibex-lib.readthedocs.io

Constructor & Destructor Documentation

◆ Interval() [1/6]

codac2::Interval::Interval ( double a)
inline

Creates a degenerate interval \([a,a]\), \(a\in\mathbb{R}\).

Parameters
asingle value contained in the resulting interval
28 : gaol::interval(a)
29 {
30 if(a == -oo || a == oo)
31 set_empty();
32 }
void set_empty()
Sets this interval to the empty set.
Definition codac2_Interval_impl.h:200

◆ Interval() [2/6]

codac2::Interval::Interval ( double a,
double b )
inline

Creates an interval \([a,b]\), \(a\in\mathbb{R}, b\in\mathbb{R}\).

Parameters
alower bound of the interval
bupper bound of the interval
35 : gaol::interval(a,b)
36 { }

◆ Interval() [3/6]

codac2::Interval::Interval ( const Interval & x)
inline

Creates an interval from another one.

Parameters
xthe interval to be copied
39 : gaol::interval(x)
40 { }

◆ Interval() [4/6]

codac2::Interval::Interval ( const std::array< double, 1 > & array)
inlineexplicit

Create an interval \([a,a]\) from a fixed-sized array of size 1.

Parameters
arraythe array of doubles
43 : Interval(array[0])
44 { }
Interval()
Creates an interval .
Definition codac2_Interval_impl.h:23

◆ Interval() [5/6]

codac2::Interval::Interval ( const std::array< double, 2 > & array)
inlineexplicit

Create an interval \([a,b]\) from a fixed-sized array of size 2.

Parameters
arraythe array of doubles
47 : Interval(array[0],array[1])
48 { }

◆ Interval() [6/6]

codac2::Interval::Interval ( std::initializer_list< double > l)
inline

Create an interval as the hull of a list of values.

Parameters
llist of values contained in the resulting interval
51 : Interval()
52 {
54 }
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

Member Function Documentation

◆ init() [1/2]

Interval & codac2::Interval::init ( )
inline

Sets the value of this interval to [-oo,oo].

Note
This function is used for template purposes.
Returns
a reference to this
57 {
58 *this = Interval(-oo,oo);
59 return *this;
60 }

◆ init() [2/2]

Interval & codac2::Interval::init ( const Interval & x)
inline

Sets the value of this interval to x.

Note
This function is used for template purposes.
Parameters
xthe value for re-initialization
Returns
a reference to this
63 {
64 *this = x;
65 return *this;
66 }

◆ init_from_list()

Interval & codac2::Interval::init_from_list ( const std::list< double > & l)
inline

Sets the bounds as the hull of a list of values.

Note
This function is separated from the constructor for py binding purposes.
Parameters
llist of values contained in the resulting interval
Returns
a reference to this
69 {
70 if(l.size() == 1)
71 *this = Interval(*l.begin());
72
73 else if(l.size() == 2)
74 *this = Interval(*l.begin(),*std::prev(l.end()));
75
76 else
77 {
78 assert_release("'Interval' can only be defined by one or two 'double' values.");
79 }
80
81 return *this;
82 }

◆ operator=() [1/2]

Interval & codac2::Interval::operator= ( double x)
inline

Sets this to x.

Parameters
xreal to be intervalized
Returns
a reference to this
85 {
86 if(x == -oo || x == oo)
87 set_empty();
88 else
89 gaol::interval::operator=(x);
90
91 return *this;
92 }

◆ operator=() [2/2]

Interval & codac2::Interval::operator= ( const Interval & x)
inline

Sets this to x.

Parameters
xinterval to be copied
Returns
a reference to this
95 {
96 gaol::interval::operator=(x);
97 return *this;
98 }

◆ operator==()

bool codac2::Interval::operator== ( const Interval & x) const
inline

Comparison (equality) between two intervals.

Parameters
xinterval to be compared with
Returns
true iff this and x are exactly the same intervals
101 {
102 return (is_empty() && x.is_empty()) || (lb() == x.lb() && ub() == x.ub());
103 }
bool is_empty() const
Tests if this is empty.
Definition codac2_Interval_impl.h:205
double ub() const
Returns the upper bound of this.
Definition codac2_Interval_impl.h:115
double lb() const
Returns the lower bound of this.
Definition codac2_Interval_impl.h:110

◆ operator!=()

bool codac2::Interval::operator!= ( const Interval & x) const
inline

Comparison (non equality) between two intervals.

Parameters
xinterval to be compared with
Returns
true iff this and x are not exactly the same intervals
106 {
107 return !(*this == x);
108 }

◆ lb()

double codac2::Interval::lb ( ) const
inline

Returns the lower bound of this.

Returns
lower bound
111 {
112 return gaol::interval::left();
113 }

◆ ub()

double codac2::Interval::ub ( ) const
inline

Returns the upper bound of this.

Returns
upper bound
116 {
117 return gaol::interval::right();
118 }

◆ mid()

double codac2::Interval::mid ( ) const
inline

Returns the midpoint of this.

Note
The return point is guaranteed to be included in this but not necessarily to be the closest floating point from the real midpoint. In particular, cases are:
  • [empty] -> Quiet NaN
  • [-oo,+oo] -> mid = 0.0
  • [-oo,b] -> mid = -MAXREAL
  • [a,+oo] -> mid = MAXREAL
  • [a,b] -> mid ~ a + .5*(b-a)
Returns
midpoint
121 {
122 double m = gaol::interval::midpoint();
123 gaol::round_upward();
124 return m;
125 }

◆ mag()

double codac2::Interval::mag ( ) const
inline

Returns the magnitude of this i.e. max(|lower bound|, |upper bound|).

Returns
the magnitude of the interval
128 {
129 return gaol::interval::mag();
130 }

◆ mig()

double codac2::Interval::mig ( ) const
inline

Returns the mignitude of this.

+(lower bound) if lower_bound > 0 -(upper bound) if upper_bound < 0 0 otherwise.

Returns
the mignitude of the interval
133 {
134 return gaol::interval::mig();
135 }

◆ smag()

double codac2::Interval::smag ( ) const
inline

Returns the signed magnitude of this i.e. lower bound if |lower bound|>|upper bound|, upper bound otherwise.

Returns
the signed magnitude of the interval
138 {
139 return (abs(lb()) > abs(ub())) ? lb() : ub();
140 }
Interval abs(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:264

◆ smig()

double codac2::Interval::smig ( ) const
inline

Returns the signed mignitude of this.

lower bound if lower_bound > 0, upper bound if upper_bound < 0, 0 otherwise.

Returns
the signed mignitude of the interval
143 {
144 return gaol::interval::smig();
145 }

◆ rand()

double codac2::Interval::rand ( ) const
inline

Returns a random value inside the interval.

Note
The seed of the pseudo-random number generator is voluntarily initialized outside this function, on demand.
In case of infinite bounds, only floating point values can be returned.
Returns
random value
148 {
149 if(is_empty())
150 return std::numeric_limits<double>::quiet_NaN();
151
152 double a = std::max<double>(next_float(-oo),lb());
153 double b = std::min<double>(prev_float(oo),ub());
154 double r = a + (((double)std::rand())/(double)RAND_MAX)*(b-a);
155 // The above operation may result in a floating point outside the bounds,
156 // due to floating-point errors. Such possible error is corrected below:
157 return std::max<double>(lb(),std::min<double>(r,ub()));
158 }
double prev_float(double x)
Returns the previous representable double-precision floating-point value before x.
Definition codac2_Interval_impl.h:614
double next_float(double x)
Returns the next representable double-precision floating-point value after x.
Definition codac2_Interval_impl.h:619

◆ rad()

double codac2::Interval::rad ( ) const
inline

Returns the radius of this.

Returns
the radius, or 0 if this is empty
161 {
162 if(is_empty())
163 return std::numeric_limits<double>::quiet_NaN();
164
165 else if(is_unbounded())
166 return oo;
167
168 else
169 {
170 double t = mid();
171 double t1 = (t-*this).ub();
172 double t2 = (*this-t).ub();
173 return (t1>t2) ? t1 : t2;
174 }
175 }
bool is_unbounded() const
Tests if one of the bounds of this is infinite.
Definition codac2_Interval_impl.h:220
double mid() const
Returns the midpoint of this.
Definition codac2_Interval_impl.h:120

◆ diam()

double codac2::Interval::diam ( ) const
inline

Returns the diameter of this.

Returns
the diameter, or 0 if this is empty
178 {
179 if(is_empty())
180 return std::numeric_limits<double>::quiet_NaN();
181
182 else
183 {
184 double d = gaol::interval::width();
185 gaol::round_upward();
186 return d;
187 }
188 }

◆ volume()

double codac2::Interval::volume ( ) const
inline

Returns the diameter of this.

Note
This function is used for template purposes. See diam()
Returns
the diameter, or 0 if this is empty
191 {
192 return diam();
193 }
double diam() const
Returns the diameter of this.
Definition codac2_Interval_impl.h:177

◆ size()

Index codac2::Interval::size ( ) const
inline

Returns the dimension of this (which is always )

Note
This function is used for template purposes.
Returns
1
196 {
197 return 1;
198 }

◆ is_empty()

bool codac2::Interval::is_empty ( ) const
inline

Tests if this is empty.

Returns
true in case of empty set
206 {
207 return gaol::interval::is_empty();
208 }

◆ contains()

bool codac2::Interval::contains ( const double & x) const
inline

Tests if this contains x.

Note
x can also be an "open bound", i.e., infinity. So this function is not restricted to a set-membership interpretation.
Parameters
xreal value
Returns
true if this contains x
211 {
212 return gaol::interval::set_contains(x);
213 }

◆ interior_contains()

bool codac2::Interval::interior_contains ( const double & x) const
inline

Tests if the interior of this contains x.

Parameters
xreal value
Returns
true if the interior of this contains x
216 {
217 return !is_empty() && x > lb() && x < ub();
218 }

◆ is_unbounded()

bool codac2::Interval::is_unbounded ( ) const
inline

Tests if one of the bounds of this is infinite.

Note
An empty interval is always bounded
Returns
true if of the bounds of this is infinite
221 {
222 return !gaol::interval::is_finite();
223 }

◆ is_degenerated()

bool codac2::Interval::is_degenerated ( ) const
inline

Tests if this is degenerated, that is, in the form of \([a,a]\).

Note
An empty interval is considered here as degenerated
Returns
true if this is degenerated
226 {
227 return is_empty() || gaol::interval::is_a_double();
228 }

◆ is_integer()

bool codac2::Interval::is_integer ( ) const
inline

Tests if this is an integer, that is, in the form of \([n,n]\) where n is an integer.

Returns
true if this is an integer singleton
231 {
232 return gaol::interval::is_an_int();
233 }

◆ has_integer_bounds()

bool codac2::Interval::has_integer_bounds ( ) const
inline

Checks whether the interval has integer lower and upper bounds.

Returns
true if this has integer lower and upper bounds; false otherwise.
236 {
237 return trunc(lb()) == lb() && trunc(ub()) == ub();
238 }

◆ intersects()

bool codac2::Interval::intersects ( const Interval & x) const
inline

Tests if this and x intersect.

Parameters
xthe other interval
Returns
true if the intervals intersect
241 {
242 return !is_empty() && !x.is_empty() && lb() <= x.ub() && ub() >= x.lb();
243 }

◆ is_disjoint()

bool codac2::Interval::is_disjoint ( const Interval & x) const
inline

Tests if this and x do not intersect.

Parameters
xthe other interval
Returns
true if the intervals are disjoint
246 {
247 return is_empty() || x.is_empty() || lb() > x.ub() || ub() < x.lb();
248 }

◆ overlaps()

bool codac2::Interval::overlaps ( const Interval & x) const
inline

Tests if this and x intersect and their intersection has a non-null volume.

Parameters
xthe other interval
Returns
true if some interior points (of this or x) belong to their intersection
251 {
252 return !is_empty() && !x.is_empty() && ub() > x.lb() && x.ub() > lb();
253 }

◆ is_subset()

bool codac2::Interval::is_subset ( const Interval & x) const
inline

Tests if this is a subset of x.

Note
If this is empty, always returns true
Parameters
xthe other interval
Returns
true iff this interval is a subset of x
256 {
257 return is_empty() || (!x.is_empty() && x.lb() <= lb() && x.ub() >= ub());
258 }

◆ is_strict_subset()

bool codac2::Interval::is_strict_subset ( const Interval & x) const
inline

Tests if this is a subset of x and not x itself.

Note
In particular, \([-\infty,\infty]\) is not a strict subset of \([-\infty,\infty]\) and \(\varnothing\) is not a strict subset of \(\varnothing\), although in both cases, the first is inside the interior of the second.
Parameters
xthe other interval
Returns
true iff this interval is a strict subset of x
261 {
262 return !x.is_empty() && (is_empty() || (x.lb() < lb() && x.ub() >= ub()) || (x.ub() > ub() && x.lb() <= lb()));
263 }

◆ is_interior_subset()

bool codac2::Interval::is_interior_subset ( const Interval & x) const
inline

Tests if this is in the interior of x.

Note
In particular, \([-\infty,\infty]\) is in the interior of \([-\infty,\infty]\) and \(\varnothing\) is in the interior of \(\varnothing\).
Parameters
xthe other interval
Returns
true iff this interval is in the interior of x
266 {
267 return is_empty() || (!x.is_empty() && (x.lb() == -oo || x.lb() < lb()) && (x.ub() == oo || x.ub() > ub()));
268 }

◆ is_strict_interior_subset()

bool codac2::Interval::is_strict_interior_subset ( const Interval & x) const
inline

Tests if this is in the interior of x and different from x.

Note
In particular, \([-\infty,\infty]\) is not strictly in the interior of \([-\infty,\infty]\) and \(\varnothing\) is not strictly in the interior of \(\varnothing\).
Parameters
xthe other interval
Returns
true iff this interval is a strict interior subset of x
271 {
272 return !x.is_empty() && (is_empty() || (
273 (x.lb() < lb() && (x.ub() == oo || x.ub() > ub()))
274 || (x.ub() > ub() && (x.lb() == -oo || x.lb() < lb()))
275 ));
276 }

◆ is_superset()

bool codac2::Interval::is_superset ( const Interval & x) const
inline

Tests if this is a superset of x.

Note
If this is empty, always returns true
Parameters
xthe other interval
Returns
true iff this interval is a superset of x
279 {
280 return x.is_subset(*this);
281 }

◆ is_strict_superset()

bool codac2::Interval::is_strict_superset ( const Interval & x) const
inline

Tests if this is a superset of x and different from x.

See also
is_strict_subset()
Parameters
xthe other interval
Returns
true iff this interval is a strict superset of x
284 {
285 return x.is_strict_subset(*this);
286 }

◆ inflate()

Interval & codac2::Interval::inflate ( const double & rad)
inline

Adds [-rad,+rad] to this.

Parameters
radthe radius of the inflation
Returns
a reference to this
289 {
290 (*this) += Interval(-rad,rad);
291 return *this;
292 }
double rad() const
Returns the radius of this.
Definition codac2_Interval_impl.h:160

◆ is_bisectable()

bool codac2::Interval::is_bisectable ( ) const
inline

Tests if this can be bisected into two non-degenerated intervals.

Note
Examples of non bisectable intervals are [0,next_float(0)] or [DBL_MAX,+oo).
Returns
true iff this can be bisected
295 {
296 if(is_empty())
297 return false;
298 double m = mid();
299 return lb() < m && m < ub();
300 }

◆ bisect()

std::pair< Interval, Interval > codac2::Interval::bisect ( float ratio = 0.49) const
inline

Bisects this into two subintervals.

Precondition
is_bisectable() must be true
0 < ratio < 1
Parameters
ratiooptional proportion of split (0.5 corresponds to middle)
Returns
a pair of resulting subintervals
303 {
304 assert_release(is_bisectable());
305 assert_release(Interval(0,1).interior_contains(ratio));
306
307 if(lb() == -oo)
308 {
309 if(ub() == oo)
310 return { Interval(-oo,0), Interval(0,oo) };
311 else
312 return { Interval(-oo,-std::numeric_limits<double>::max()), Interval(-std::numeric_limits<double>::max(),ub()) };
313 }
314
315 else if(ub() == oo)
316 return { Interval(lb(),std::numeric_limits<double>::max()), Interval(std::numeric_limits<double>::max(),oo) };
317
318 else
319 {
320 double m;
321
322 if(ratio == 0.5)
323 m = mid();
324
325 else
326 {
327 m = lb() + ratio*diam();
328 if(m >= ub())
329 m = next_float(lb());
330
331 assert(m < ub());
332 }
333
334 return { Interval(lb(),m), Interval(m,ub()) };
335 }
336 }
bool is_bisectable() const
Tests if this can be bisected into two non-degenerated intervals.
Definition codac2_Interval_impl.h:294
bool interior_contains(const double &x) const
Tests if the interior of this contains x.
Definition codac2_Interval_impl.h:215

◆ complementary()

std::vector< Interval > codac2::Interval::complementary ( bool compactness = true) const
inline

Computes the complementary of this.

Parameters
compactnessoptional boolean to obtain or not disjoint intervals
Returns
a vector of complementary intervals
339 {
340 if(is_empty() || (compactness && is_degenerated()))
341 return { {-oo,oo} };
342
343 std::vector<Interval> l;
344
345 if(lb() > -oo)
346 l.push_back({-oo,lb()});
347
348 if(ub() < oo)
349 l.push_back({ub(),oo});
350
351 return l;
352 }
bool is_degenerated() const
Tests if this is degenerated, that is, in the form of .
Definition codac2_Interval_impl.h:225

◆ diff()

std::vector< Interval > codac2::Interval::diff ( const Interval & y,
bool compactness = true ) const
inline

Computes the result of \([x]\backslash[y]\).

Parameters
yinterval to remove from this
compactnessoptional boolean to obtain or not disjoint intervals
Returns
a vector of resulting diff intervals
355 {
356 if(compactness && is_degenerated())
357 {
358 if(is_empty() || y.contains(lb()))
359 return {};
360 else
361 return { *this };
362 }
363
364 std::vector<Interval> l;
365 for(const auto& li : y.complementary(compactness))
366 {
367 Interval inter = li & *this;
368 if(!inter.is_degenerated())
369 l.push_back(inter);
370 }
371
372 return l;
373 }

◆ operator|=()

Interval & codac2::Interval::operator|= ( const Interval & x)
inline

Self union of this and x.

Parameters
xthe other interval
Returns
a reference to this
492 {
493 gaol::interval::operator|=(x);
494 return *this;
495 }

◆ operator&=()

Interval & codac2::Interval::operator&= ( const Interval & x)
inline

Self intersection of this and x.

Parameters
xthe other interval
Returns
a reference to this
498 {
499 gaol::interval::operator&=(x);
500 return *this;
501 }

◆ operator+=() [1/2]

Interval & codac2::Interval::operator+= ( double x)
inline

Self addition of this and a real x.

Parameters
xthe real to add
Returns
a reference to this
504 {
505 if(x == -oo || x == oo)
506 set_empty();
507 else
508 gaol::interval::operator+=(x);
509 return *this;
510 }

◆ operator+=() [2/2]

Interval & codac2::Interval::operator+= ( const Interval & x)
inline

Self addition of this and x.

Parameters
xthe other interval
Returns
a reference to this
513 {
514 gaol::interval::operator+=(x);
515 return *this;
516 }

◆ operator-()

Interval codac2::Interval::operator- ( ) const
inline

Substraction of this.

Returns
(- this)
519 {
520 return 0.-*this;
521 }

◆ operator-=() [1/2]

Interval & codac2::Interval::operator-= ( double x)
inline

Self substraction of this and a real x.

Parameters
xthe real to substract
Returns
a reference to this
524 {
525 if(x == -oo || x == oo)
526 set_empty();
527 else
528 gaol::interval::operator-=(x);
529 return *this;
530 }

◆ operator-=() [2/2]

Interval & codac2::Interval::operator-= ( const Interval & x)
inline

Self substraction of this and x.

Parameters
xthe other interval
Returns
a reference to this
533 {
534 gaol::interval::operator-=(x);
535 return *this;
536 }

◆ operator*=() [1/2]

Interval & codac2::Interval::operator*= ( double x)
inline

Self multiplication of this and a real x.

Parameters
xthe real to multiply
Returns
a reference to this
539 {
540 if(x == -oo || x == oo)
541 set_empty();
542 else
543 gaol::interval::operator*=(x);
544 return *this;
545 }

◆ operator*=() [2/2]

Interval & codac2::Interval::operator*= ( const Interval & x)
inline

Self multiplication of this and x.

Parameters
xthe other interval
Returns
a reference to this
548 {
549 gaol::interval::operator*=(x);
550 return *this;
551 }

◆ operator/=() [1/2]

Interval & codac2::Interval::operator/= ( double x)
inline

Self division of this and a real x.

Parameters
xthe real to divide
Returns
a reference to this
554 {
555 if(x == -oo || x == oo)
556 set_empty();
557 else
558 gaol::interval::operator/=(x);
559 return *this;
560 }

◆ operator/=() [2/2]

Interval & codac2::Interval::operator/= ( const Interval & x)
inline

Self division of this and x.

Note
This computation is more efficient than the non-self div operator, because it calculates the union of this/x as intermediate result.
Parameters
xthe other interval
Returns
a reference to this
563 {
564 gaol::interval::operator/=(x);
565 return *this;
566 }

◆ empty()

Interval codac2::Interval::empty ( )
inlinestatic

Provides an empty interval.

Returns
an empty set
569 {
570 return std::numeric_limits<double>::quiet_NaN();
571 }

◆ zero()

Interval codac2::Interval::zero ( )
inlinestatic

Provides an interval for \([0]\).

Returns
an interval containing \(0\)
574 {
575 return gaol::interval::zero();
576 }

◆ one()

Interval codac2::Interval::one ( )
inlinestatic

Provides an interval for \([1]\).

Returns
an interval containing \(1\)
579 {
580 return gaol::interval::one();
581 }

◆ half_pi()

Interval codac2::Interval::half_pi ( )
inlinestatic

Provides an interval for \([\frac{\pi}{2}]\).

Returns
an interval containing \(\frac{\pi}{2}\)
584 {
585 return gaol::interval::half_pi();
586 }

◆ pi()

Interval codac2::Interval::pi ( )
inlinestatic

Provides an interval for \([\pi]\).

Returns
an interval containing \(\pi\)
589 {
590 return gaol::interval::pi();
591 }

◆ two_pi()

Interval codac2::Interval::two_pi ( )
inlinestatic

Provides an interval for \([2\pi]\).

Returns
an interval containing \(2\pi\)
594 {
595 return gaol::interval::two_pi();
596 }

The documentation for this class was generated from the following files: