codac 1.5.6
Loading...
Searching...
No Matches
codac2_Interval_operations.h File Reference
Include dependency graph for codac2_Interval_operations.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Interval codac2::sqr (const Interval &x)
 Returns \([x]^2\).
 
Interval codac2::sqrt (const Interval &x)
 Returns \(\sqrt{[x]}\).
 
Interval codac2::pow (const Interval &x, int n)
 Returns \([x]^n\), \(n\in\mathbb{Z}\).
 
Interval codac2::pow (const Interval &x, double p)
 Returns \([x]^p\), \(p\in\mathbb{R}\).
 
Interval codac2::pow (const Interval &x, const Interval &p)
 Returns \([x]^{[p]}\), \(p\in\mathbb{IR}\).
 
Interval codac2::root (const Interval &x, int p)
 Returns the p-th root: \(\sqrt[p]{[x]}\).
 
Interval codac2::exp (const Interval &x)
 Returns \(\exp([x])\).
 
Interval codac2::log (const Interval &x)
 Returns \(\log([x])\).
 
Interval codac2::cos (const Interval &x)
 Returns \(\cos([x])\).
 
Interval codac2::sin (const Interval &x)
 Returns \(\sin([x])\).
 
Interval codac2::tan (const Interval &x)
 Returns \(\tan([x])\).
 
Interval codac2::acos (const Interval &x)
 Returns \(\acos([x])\).
 
Interval codac2::asin (const Interval &x)
 Returns \(\asin([x])\).
 
Interval codac2::atan (const Interval &x)
 Returns \(\atan([x])\).
 
Interval codac2::atan2 (const Interval &y, const Interval &x)
 Returns \(\mathrm{arctan2}([y],[x])\).
 
Interval codac2::cosh (const Interval &x)
 Returns \(\cosh([x])\).
 
Interval codac2::sinh (const Interval &x)
 Returns \(\sinh([x])\).
 
Interval codac2::tanh (const Interval &x)
 Returns \(\tanh([x])\).
 
Interval codac2::acosh (const Interval &x)
 Returns \(\acosh([x])\).
 
Interval codac2::asinh (const Interval &x)
 Returns \(\asinh([x])\).
 
Interval codac2::atanh (const Interval &x)
 Returns \(\atanh([x])\).
 
Interval codac2::abs (const Interval &x)
 Returns \(\mid[x]\mid = \left\{\mid x \mid, x\in[x]\right\}\).
 
Interval codac2::min (const Interval &x, const Interval &y)
 Returns \(\min([x],[y])=\left\{\min(x,y), x\in[x], y\in[y]\right\}\).
 
Interval codac2::max (const Interval &x, const Interval &y)
 Returns \(\max([x],[y])=\left\{\max(x,y), x\in[x], y\in[y]\right\}\).
 
Interval codac2::sign (const Interval &x)
 Returns \(\sign([x])=\left[\left\{\sign(x), x\in[x]\right\}\right]\).
 
Interval codac2::integer (const Interval &x)
 Returns the largest integer interval included in \([x]\).
 
Interval codac2::floor (const Interval &x)
 Returns floor of \([x]\).
 
Interval codac2::ceil (const Interval &x)
 Returns ceil of \([x]\).
 
Interval codac2::chi (const Interval &x, const Interval &y, const Interval &z)
 Return \([y]\) if \(x^+ <= 0\), \([z]\) if \(x^- > 0\), \([y]\sqcup[z]\) else.
 

Detailed Description

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


Date
2024
Author
Gilles Chabert, Simon Rohou
License: GNU Lesser General Public License (LGPL)

Function Documentation

◆ sqr()

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

Returns \([x]^2\).

Parameters
xinterval value
Returns
the operation result
22 {
23 return gaol::sqr(x);
24 }

◆ sqrt()

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

Returns \(\sqrt{[x]}\).

Parameters
xinterval value
Returns
the operation result
27 {
28 Interval y = gaol::sqrt(x);
29 gaol::round_upward();
30 return y;
31 }
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:62

◆ pow() [1/3]

Interval codac2::pow ( const Interval & x,
int n )
inline

Returns \([x]^n\), \(n\in\mathbb{Z}\).

Parameters
xinterval value
ninteger power value
Returns
the operation result
34 {
35 Interval y = gaol::pow(x,p);
36 //gaol::round_upward(); // not necessary?
37 return y;
38 }

◆ pow() [2/3]

Interval codac2::pow ( const Interval & x,
double p )
inline

Returns \([x]^p\), \(p\in\mathbb{R}\).

Parameters
xinterval value
preal power value
Returns
the operation result
41 {
42 if(p == -oo || p == oo)
43 return Interval::empty();
44
45 else
46 {
47 Interval y = gaol::pow(x,p);
48 gaol::round_upward();
49 return y;
50 }
51 }
static Interval empty()
Provides an empty interval.
Definition codac2_Interval_impl.h:535

◆ pow() [3/3]

Interval codac2::pow ( const Interval & x,
const Interval & p )
inline

Returns \([x]^{[p]}\), \(p\in\mathbb{IR}\).

Parameters
xinterval value
pinterval power value
Returns
the operation result
54 {
55 Interval y = gaol::pow(x,p);
56 gaol::round_upward();
57 return y;
58 }

◆ root()

Interval codac2::root ( const Interval & x,
int p )
inline

Returns the p-th root: \(\sqrt[p]{[x]}\).

Parameters
xinterval value
pinteger root
Returns
the operation result
61 {
62 // Get the root of the positive part (gaol does
63 // not consider negative values to be in the definition
64 // domain of the root function)
65
66 gaol::interval y = gaol::nth_root(x, p>=0 ? p : -p);
67
68 if(p%2 == 1 && x.lb() < 0)
69 y |= -gaol::nth_root(-x, p >= 0 ? p : -p);
70
71 if(p < 0)
72 y = 1.0/y;
73
74 gaol::round_upward();
75 return y;
76 }
double lb() const
Returns the lower bound of this.
Definition codac2_Interval_impl.h:102

◆ exp()

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

Returns \(\exp([x])\).

Parameters
xinterval value
Returns
the operation result
79 {
80 Interval y = gaol::exp(x);
81 gaol::round_upward();
82 return y;
83 }

◆ log()

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

Returns \(\log([x])\).

Parameters
xinterval value
Returns
the operation result
86 {
87 if(x.ub() <= 0) // gaol returns (-oo,-DBL_MAX) if x.ub()==0, instead of empty set
88 return Interval::empty();
89
90 else
91 {
92 Interval y = gaol::log(x);
93 gaol::round_upward();
94 return y;
95 }
96 }
double ub() const
Returns the upper bound of this.
Definition codac2_Interval_impl.h:107

◆ cos()

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

Returns \(\cos([x])\).

Parameters
xinterval value
Returns
the operation result
99 {
100 Interval y = gaol::cos(x);
101 gaol::round_upward();
102 return y;
103 }

◆ sin()

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

Returns \(\sin([x])\).

Parameters
xinterval value
Returns
the operation result
106 {
107 Interval y = gaol::sin(x);
108 gaol::round_upward();
109 return y;
110 }

◆ tan()

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

Returns \(\tan([x])\).

Parameters
xinterval value
Returns
the operation result
113 {
114 Interval y = gaol::tan(x);
115 gaol::round_upward();
116 return y;
117 }

◆ acos()

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

Returns \(\acos([x])\).

Parameters
xinterval value
Returns
the operation result
120 {
121 Interval y = gaol::acos(x);
122 gaol::round_upward();
123 return y;
124 }

◆ asin()

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

Returns \(\asin([x])\).

Parameters
xinterval value
Returns
the operation result
127 {
128 Interval y = gaol::asin(x);
129 gaol::round_upward();
130 return y;
131 }

◆ atan()

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

Returns \(\atan([x])\).

Parameters
xinterval value
Returns
the operation result
134 {
135 Interval y = gaol::atan(x);
136 gaol::round_upward();
137 return y;
138 }

◆ atan2()

Interval codac2::atan2 ( const Interval & y,
const Interval & x )
inline

Returns \(\mathrm{arctan2}([y],[x])\).

Parameters
yinterval value
xinterval value
Returns
the operation result
141 {
142 if(y.is_empty() || x.is_empty())
143 return Interval::empty();
144
145 // We handle the special case x=[0,0] separately
146 else if(x == Interval::zero())
147 {
148 if(y.lb() >= 0)
149 {
150 if(y.ub() == 0)
151 return Interval::empty(); // atan2(0,0) is undefined
152 else
153 return Interval::half_pi();
154 }
155
156 else if(y.ub() <= 0)
157 return -Interval::half_pi();
158
159 else
160 return Interval(-1,1)*Interval::half_pi();
161 }
162
163 else if(x.lb() >= 0)
164 return atan(y/x); // now, x.ub()>0 -> atan does not give an empty set
165
166 else if(x.ub() <= 0)
167 {
168 if(y.lb() >= 0)
169 return atan(y/x) + Interval::pi(); // x.lb()<0
170 else if(y.ub() < 0)
171 return atan(y/x) - Interval::pi();
172 else
173 return Interval(-1,1)*Interval::pi();
174 }
175
176 else
177 {
178 if(y.lb() >= 0)
179 return atan(y/x.ub()) | (atan(y/x.lb()) + Interval::pi());
180
181 else if(y.ub() <= 0)
182 {
183 if(x.lb() != -oo)
184 {
185 if(x.ub() != oo)
186 return (atan(y/x.lb())-Interval::pi()) | atan(y/x.ub());
187 else
188 return (atan(y/x.lb())-Interval::pi()) | Interval::zero();
189 }
190
191 else
192 {
193 if(x.ub() != oo)
194 return (-Interval::pi()) | atan(y/x.ub());
195 else
196 return -Interval::pi() | Interval::zero();
197 }
198 }
199
200 else
201 return Interval(-1,1)*Interval::pi();
202 }
203 }
bool is_empty() const
Tests if this is empty.
Definition codac2_Interval_impl.h:187
static Interval pi()
Provides an interval for .
Definition codac2_Interval_impl.h:555
static Interval zero()
Provides an interval for .
Definition codac2_Interval_impl.h:540
static Interval half_pi()
Provides an interval for .
Definition codac2_Interval_impl.h:550
Interval atan(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:133

◆ cosh()

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

Returns \(\cosh([x])\).

Parameters
xinterval value
Returns
the operation result
206 {
207 Interval y;
208 if(x.is_unbounded())
209 y = Interval(gaol::cosh(x).left(),oo);
210 else
211 y = gaol::cosh(x);
212 gaol::round_upward();
213 return y;
214 }
bool is_unbounded() const
Tests if one of the bounds of this is infinite.
Definition codac2_Interval_impl.h:202

◆ sinh()

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

Returns \(\sinh([x])\).

Parameters
xinterval value
Returns
the operation result
217 {
218 Interval y = gaol::sinh(x);
219 gaol::round_upward();
220 return y;
221 }

◆ tanh()

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

Returns \(\tanh([x])\).

Parameters
xinterval value
Returns
the operation result
224 {
225 Interval y = gaol::tanh(x);
226 gaol::round_upward();
227 return y;
228 }

◆ acosh()

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

Returns \(\acosh([x])\).

Parameters
xinterval value
Returns
the operation result
231 {
232 Interval y = gaol::acosh(x);
233 gaol::round_upward();
234 return y;
235 }

◆ asinh()

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

Returns \(\asinh([x])\).

Parameters
xinterval value
Returns
the operation result
238 {
239 if(x.is_empty())
240 return Interval::empty();
241
242 else if(x.lb() >= 0)
243 return gaol::asinh(x);
244
245 else if(x.ub() <= 0)
246 return -gaol::asinh(-x);
247
248 else
249 return {
250 -gaol::asinh(gaol::interval(0,-x.lb())).right(),
251 gaol::asinh(gaol::interval(0,x.ub())).right()
252 };
253
254 // no round_upward?
255 }

◆ atanh()

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

Returns \(\atanh([x])\).

Parameters
xinterval value
Returns
the operation result
258 {
259 Interval y = gaol::atanh(x);
260 gaol::round_upward();
261 return y;
262 }

◆ abs()

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

Returns \(\mid[x]\mid = \left\{\mid x \mid, x\in[x]\right\}\).

Parameters
xinterval value
Returns
the operation result
265 {
266 return gaol::abs(x);
267 }

◆ min()

Interval codac2::min ( const Interval & x,
const Interval & y )
inline

Returns \(\min([x],[y])=\left\{\min(x,y), x\in[x], y\in[y]\right\}\).

Parameters
xinterval value
yinterval value
Returns
the operation result
270 {
271 return gaol::min(x,y);
272 }

◆ max()

Interval codac2::max ( const Interval & x,
const Interval & y )
inline

Returns \(\max([x],[y])=\left\{\max(x,y), x\in[x], y\in[y]\right\}\).

Parameters
xinterval value
yinterval value
Returns
the operation result
275 {
276 return gaol::max(x,y);
277 }

◆ sign()

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

Returns \(\sign([x])=\left[\left\{\sign(x), x\in[x]\right\}\right]\).

Note
By convention, \( 0\in[x] \Longrightarrow \sign([x])=[-1,1]\).
Parameters
xinterval value
Returns
the operation result
280 {
281 return x.ub() < 0 ? -1. : x.lb() > 0 ? 1. : Interval(-1.,1.);
282 }

◆ integer()

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

Returns the largest integer interval included in \([x]\).

Parameters
xinterval value
Returns
the operation result
285 {
286 return gaol::integer(x);
287 }

◆ floor()

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

Returns floor of \([x]\).

Parameters
xinterval value
Returns
the operation result
290 {
291 return gaol::floor(x);
292 }

◆ ceil()

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

Returns ceil of \([x]\).

Parameters
xinterval value
Returns
the operation result
295 {
296 return gaol::ceil(x);
297 }

◆ chi()

Interval codac2::chi ( const Interval & x,
const Interval & y,
const Interval & z )
inline

Return \([y]\) if \(x^+ <= 0\), \([z]\) if \(x^- > 0\), \([y]\sqcup[z]\) else.

Parameters
xinterval value
yinterval value
zinterval value
Returns
the operation result
300 {
301 if(x.ub() <= 0)
302 return y;
303
304 else if(x.lb() > 0)
305 return z;
306
307 else
308 return y | z;
309 }