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 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:190

◆ 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:195
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 }

◆ 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
138 {
139 if(is_empty())
140 return std::numeric_limits<double>::quiet_NaN();
141
142 double a = std::max<double>(next_float(-oo),lb());
143 double b = std::min<double>(previous_float(oo),ub());
144 double r = a + (((double)std::rand())/(double)RAND_MAX)*(b-a);
145 // The above operation may result in a floating point outside the bounds,
146 // due to floating-point errors. Such possible error is corrected below:
147 return std::max<double>(lb(),std::min<double>(r,ub()));
148 }
double next_float(double x)
Returns the next representable double-precision floating-point value after x.
Definition codac2_Interval_impl.h:609
double previous_float(double x)
Returns the previous representable double-precision floating-point value before x.
Definition codac2_Interval_impl.h:604

◆ rad()

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

Returns the radius of this.

Returns
the radius, or 0 if this is empty
151 {
152 if(is_empty())
153 return std::numeric_limits<double>::quiet_NaN();
154
155 else if(is_unbounded())
156 return oo;
157
158 else
159 {
160 double t = mid();
161 double t1 = (t-*this).ub();
162 double t2 = (*this-t).ub();
163 return (t1>t2) ? t1 : t2;
164 }
165 }
bool is_unbounded() const
Tests if one of the bounds of this is infinite.
Definition codac2_Interval_impl.h:210
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
168 {
169 if(is_empty())
170 return std::numeric_limits<double>::quiet_NaN();
171
172 else
173 {
174 double d = gaol::interval::width();
175 gaol::round_upward();
176 return d;
177 }
178 }

◆ 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
181 {
182 return diam();
183 }
double diam() const
Returns the diameter of this.
Definition codac2_Interval_impl.h:167

◆ 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
186 {
187 return 1;
188 }

◆ is_empty()

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

Tests if this is empty.

Returns
true in case of empty set
196 {
197 return gaol::interval::is_empty();
198 }

◆ 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
201 {
202 return gaol::interval::set_contains(x);
203 }

◆ 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
206 {
207 return !is_empty() && x > lb() && x < ub();
208 }

◆ 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
211 {
212 return !gaol::interval::is_finite();
213 }

◆ 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
216 {
217 return is_empty() || gaol::interval::is_a_double();
218 }

◆ 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
221 {
222 return gaol::interval::is_an_int();
223 }

◆ 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.
226 {
227 return trunc(lb()) == lb() && trunc(ub()) == ub();
228 }

◆ 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
231 {
232 return !is_empty() && !x.is_empty() && lb() <= x.ub() && ub() >= x.lb();
233 }

◆ 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
236 {
237 return is_empty() || x.is_empty() || lb() > x.ub() || ub() < x.lb();
238 }

◆ 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
241 {
242 return !is_empty() && !x.is_empty() && ub() > x.lb() && x.ub() > lb();
243 }

◆ 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
246 {
247 return is_empty() || (!x.is_empty() && x.lb() <= lb() && x.ub() >= ub());
248 }

◆ 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
251 {
252 return !x.is_empty() && (is_empty() || (x.lb() < lb() && x.ub() >= ub()) || (x.ub() > ub() && x.lb() <= lb()));
253 }

◆ 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
256 {
257 return is_empty() || (!x.is_empty() && (x.lb() == -oo || x.lb() < lb()) && (x.ub() == oo || x.ub() > ub()));
258 }

◆ 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
261 {
262 return !x.is_empty() && (is_empty() || (
263 (x.lb() < lb() && (x.ub() == oo || x.ub() > ub()))
264 || (x.ub() > ub() && (x.lb() == -oo || x.lb() < lb()))
265 ));
266 }

◆ 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
269 {
270 return x.is_subset(*this);
271 }

◆ 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
274 {
275 return x.is_strict_subset(*this);
276 }

◆ 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
279 {
280 (*this) += Interval(-rad,rad);
281 return *this;
282 }
double rad() const
Returns the radius of this.
Definition codac2_Interval_impl.h:150

◆ 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
285 {
286 if(is_empty())
287 return false;
288 double m = mid();
289 return lb() < m && m < ub();
290 }

◆ 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
293 {
294 assert_release(is_bisectable());
295 assert_release(Interval(0,1).interior_contains(ratio));
296
297 if(lb() == -oo)
298 {
299 if(ub() == oo)
300 return { Interval(-oo,0), Interval(0,oo) };
301 else
302 return { Interval(-oo,-std::numeric_limits<double>::max()), Interval(-std::numeric_limits<double>::max(),ub()) };
303 }
304
305 else if(ub() == oo)
306 return { Interval(lb(),std::numeric_limits<double>::max()), Interval(std::numeric_limits<double>::max(),oo) };
307
308 else
309 {
310 double m;
311
312 if(ratio == 0.5)
313 m = mid();
314
315 else
316 {
317 m = lb() + ratio*diam();
318 if(m >= ub())
319 m = next_float(lb());
320
321 assert(m < ub());
322 }
323
324 return { Interval(lb(),m), Interval(m,ub()) };
325 }
326 }
bool is_bisectable() const
Tests if this can be bisected into two non-degenerated intervals.
Definition codac2_Interval_impl.h:284
bool interior_contains(const double &x) const
Tests if the interior of this contains x.
Definition codac2_Interval_impl.h:205

◆ 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
329 {
330 if(is_empty() || (compactness && is_degenerated()))
331 return { {-oo,oo} };
332
333 std::vector<Interval> l;
334
335 if(lb() > -oo)
336 l.push_back({-oo,lb()});
337
338 if(ub() < oo)
339 l.push_back({ub(),oo});
340
341 return l;
342 }
bool is_degenerated() const
Tests if this is degenerated, that is, in the form of .
Definition codac2_Interval_impl.h:215

◆ 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
345 {
346 if(compactness && is_degenerated())
347 {
348 if(is_empty() || y.contains(lb()))
349 return {};
350 else
351 return { *this };
352 }
353
354 std::vector<Interval> l;
355 for(const auto& li : y.complementary(compactness))
356 {
357 Interval inter = li & *this;
358 if(!inter.is_degenerated())
359 l.push_back(inter);
360 }
361
362 return l;
363 }

◆ operator|=()

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

Self union of this and x.

Parameters
xthe other interval
Returns
a reference to this
482 {
483 gaol::interval::operator|=(x);
484 return *this;
485 }

◆ operator&=()

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

Self intersection of this and x.

Parameters
xthe other interval
Returns
a reference to this
488 {
489 gaol::interval::operator&=(x);
490 return *this;
491 }

◆ 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
494 {
495 if(x == -oo || x == oo)
496 set_empty();
497 else
498 gaol::interval::operator+=(x);
499 return *this;
500 }

◆ 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
503 {
504 gaol::interval::operator+=(x);
505 return *this;
506 }

◆ operator-()

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

Substraction of this.

Returns
(- this)
509 {
510 return 0.-*this;
511 }

◆ 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
514 {
515 if(x == -oo || x == oo)
516 set_empty();
517 else
518 gaol::interval::operator-=(x);
519 return *this;
520 }

◆ 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
523 {
524 gaol::interval::operator-=(x);
525 return *this;
526 }

◆ 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
529 {
530 if(x == -oo || x == oo)
531 set_empty();
532 else
533 gaol::interval::operator*=(x);
534 return *this;
535 }

◆ 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
538 {
539 gaol::interval::operator*=(x);
540 return *this;
541 }

◆ 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
544 {
545 if(x == -oo || x == oo)
546 set_empty();
547 else
548 gaol::interval::operator/=(x);
549 return *this;
550 }

◆ 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
553 {
554 gaol::interval::operator/=(x);
555 return *this;
556 }

◆ empty()

Interval codac2::Interval::empty ( )
inlinestatic

Provides an empty interval.

Returns
an empty set
559 {
560 return std::numeric_limits<double>::quiet_NaN();
561 }

◆ zero()

Interval codac2::Interval::zero ( )
inlinestatic

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

Returns
an interval containing \(0\)
564 {
565 return gaol::interval::zero();
566 }

◆ one()

Interval codac2::Interval::one ( )
inlinestatic

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

Returns
an interval containing \(1\)
569 {
570 return gaol::interval::one();
571 }

◆ half_pi()

Interval codac2::Interval::half_pi ( )
inlinestatic

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

Returns
an interval containing \(\frac{\pi}{2}\)
574 {
575 return gaol::interval::half_pi();
576 }

◆ pi()

Interval codac2::Interval::pi ( )
inlinestatic

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

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

◆ two_pi()

Interval codac2::Interval::two_pi ( )
inlinestatic

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

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

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