34 cxscthrow(ERROR_INTERVAL_EMPTY_INTERVAL(
"inline interval::interval(const real &a,const real &b)"));
92 return interval((a.inf<b.inf)?a.inf:b.inf,(a.sup>b.sup)?a.sup:b.sup);
96 return interval((a.inf>b.inf)?a.inf:b.inf,(a.sup<b.sup)?a.sup:b.sup);
100 return interval((a<b.inf)?a:b.inf,(a>b.sup)?a:b.sup);
104 return interval((a>b.inf)?a:b.inf,(a<b.sup)?a:b.sup);
108 return interval((a.inf<b)?a.inf:b,(a.sup>b)?a.sup:b);
117 return interval((a.inf>b)?a.inf:b,(a.sup<b)?a.sup:b);
121 a.inf=(a.inf<b.inf)?a.inf:b.inf,a.sup=(a.sup>b.sup)?a.sup:b.sup;
126 a.inf=(a.inf>b.inf)?a.inf:b.inf,a.sup=(a.sup<b.sup)?a.sup:b.sup;
128 cxscthrow(ERROR_INTERVAL_EMPTY_INTERVAL(
"inline interval & operator &=(interval &a,const interval &b)"));
133 a.inf=(a.inf<b)?a.inf:b,a.sup=(a.sup>b)?a.sup:b;
138 a.inf=(a.inf>b)?a.inf:b,a.sup=(a.sup<b)?a.sup:b;
140 cxscthrow(ERROR_INTERVAL_EMPTY_INTERVAL(
"inline interval & operator &=(interval &a,const real &b)"));
145inline bool operator ==(
const interval &a,
const interval &b)
noexcept {
return(a.inf==b.inf && a.sup==b.sup); }
146inline bool operator !=(
const interval &a,
const interval &b)
noexcept {
return(a.inf!=b.inf || a.sup!=b.sup); }
147inline bool operator ==(
const real &r,
const interval &a)
noexcept {
return(r==a.inf && r==a.sup); }
148inline bool operator !=(
const real &r,
const interval &a)
noexcept {
return(r!=a.inf || r!=a.sup); }
149inline bool operator ==(
const interval &a,
const real &r)
noexcept {
return(r==a.inf && r==a.sup); }
150inline bool operator !=(
const interval &a,
const real &r)
noexcept {
return(r!=a.inf || r!=a.sup); }
152inline bool operator ==(
const int &r,
const interval &a)
noexcept {
return(r==a.inf && r==a.sup); }
153inline bool operator !=(
const int &r,
const interval &a)
noexcept {
return(r!=a.inf || r!=a.sup); }
154inline bool operator ==(
const interval &a,
const int &r)
noexcept {
return(r==a.inf && r==a.sup); }
155inline bool operator !=(
const interval &a,
const int &r)
noexcept {
return(r!=a.inf || r!=a.sup); }
157inline bool operator ==(
const long &r,
const interval &a)
noexcept {
return(r==a.inf && r==a.sup); }
158inline bool operator !=(
const long &r,
const interval &a)
noexcept {
return(r!=a.inf || r!=a.sup); }
159inline bool operator ==(
const interval &a,
const long &r)
noexcept {
return(r==a.inf && r==a.sup); }
160inline bool operator !=(
const interval &a,
const long &r)
noexcept {
return(r!=a.inf || r!=a.sup); }
162inline bool operator ==(
const double &r,
const interval &a)
noexcept {
return(r==a.inf && r==a.sup); }
163inline bool operator !=(
const double &r,
const interval &a)
noexcept {
return(r!=a.inf || r!=a.sup); }
164inline bool operator ==(
const interval &a,
const double &r)
noexcept {
return(r==a.inf && r==a.sup); }
165inline bool operator !=(
const interval &a,
const double &r)
noexcept {
return(r!=a.inf || r!=a.sup); }
171 return(a.inf>=b.inf && a.sup<=b.sup);
175 return(a.inf<=b.inf && a.sup>=b.sup);
179 return(a.inf>b.inf && a.sup<b.sup);
183 return(a.inf<b.inf && a.sup>b.sup);
188 return(a>=b.inf && a<=b.sup);
192 return(a<=b.inf && a>=b.sup);
196 return(a>b.inf && a<b.sup);
201 return(a.inf>=b && a.sup<=b);
205 return(a.inf<=b && a.sup>=b);
209 return(a.inf<b && a.sup>b);
212inline bool operator !(
const interval &a)
noexcept {
return (a.inf <= 0.0 && a.sup >= 0.0); }
224inline bool IsEmpty(
const interval &a)
noexcept {
return (a.inf>a.sup); }
231 if (IsEmpty(a))
return a;
233 return interval(0.0, (h1 > h2) ? h1 : h2);
242 return subup(a.sup,a.inf);
247 return addd( a.inf, subd(0.5*a.sup,0.5*a.inf) );
254 r1 = x.inf; r2 = x.sup;
256 if (j >= -1021) r1 = comp(mant(r1),j);
260 r1 = comp(mant(r1), -1021);
263 if (sign(r1)>=0) r1 = 0;
266 r1 = muld(r1,comp(0.5,j+1));
269 if (j >= -1021) r2 = comp(mant(r2),j);
273 r2 = comp(mant(r2), -1021);
278 }
else r2 = mulu(r2,comp(0.5,j+1));
280 x = _interval(r1,r2);
284 {
return interval (adddown(a.inf,b.inf),addup(a.sup,b.sup)); }
286 {
return interval (adddown(a.inf,b),addup(a.sup,b)); }
288 {
return interval (adddown(a,b.inf),addup(a,b.sup)); }
291 {
return interval ( subdown(a.inf,b.sup), subup(a.sup,b.inf)); }
293 {
return interval ( subdown(a.inf,b), subup(a.sup,b)); }
295 {
return interval ( subdown(a,b.sup), subup(a,b.inf)); }
315 if (sign(a.inf) >= 0)
317 if (sign(b.inf) >= 0)
319 tmp.inf = multdown(a.inf,b.inf);
320 tmp.sup = multup(a.sup,b.sup);
321 }
else if (sign(b.sup) >= 0)
323 tmp.inf = multdown(a.sup,b.inf);
324 tmp.sup = multup(a.sup,b.sup);
327 tmp.inf = multdown(a.sup,b.inf);
328 tmp.sup = multup(a.inf,b.sup);
330 }
else if (sign(a.sup) >= 0)
332 if (sign(b.inf) >= 0)
334 tmp.inf = multdown(a.inf,b.sup);
335 tmp.sup = multup(a.sup,b.sup);
336 }
else if (sign(b.sup) >= 0)
340 tmp.inf = multdown(a.inf,b.sup);
341 hlp = multdown(a.sup,b.inf);
346 tmp.sup = multup(a.inf,b.inf);
347 hlp = multup(a.sup,b.sup);
353 tmp.inf = multdown(a.sup,b.inf);
354 tmp.sup = multup(a.inf,b.inf);
358 if (sign(b.inf) >= 0)
360 tmp.inf = multdown(a.inf,b.sup);
361 tmp.sup = multup(a.sup,b.inf);
362 }
else if (sign(b.sup) >= 0)
364 tmp.inf = multdown(a.inf,b.sup);
365 tmp.sup = multup(a.inf,b.inf);
368 tmp.inf = multdown(a.sup,b.sup);
369 tmp.sup = multup(a.inf,b.inf);
391 if ((sign(b.inf) <= 0) && (sign(b.sup) >= 0))
392 cxscthrow(DIV_BY_ZERO(
"interval::interval operator/(const interval&,const interval&)"));
394 if (sign(a.inf) >= 0)
398 tmp.inf = divdown(a.inf,b.sup);
399 tmp.sup = divup(a.sup,b.inf);
402 tmp.inf = divdown(a.sup,b.sup);
403 tmp.sup = divup(a.inf,b.inf);
405 }
else if (sign(a.sup) >= 0)
409 tmp.inf = divdown(a.inf,b.inf);
410 tmp.sup = divup(a.sup,b.inf);
413 tmp.inf = divdown(a.sup,b.sup);
414 tmp.sup = divup(a.inf,b.sup);
420 tmp.inf = divdown(a.inf,b.inf);
421 tmp.sup = divup(a.sup,b.sup);
424 tmp.inf = divdown(a.sup,b.inf);
425 tmp.sup = divup(a.inf,b.sup);
439 }
else if (sign(a) > 0)
441 tmp.inf = multdown(a,b.inf);
442 tmp.sup = multup(a,b.sup);
445 tmp.inf = multdown(a,b.sup);
446 tmp.sup = multup(a,b.inf);
458 }
else if (sign(b) > 0)
460 tmp.inf = multdown(a.inf,b);
461 tmp.sup = multup(a.sup,b);
464 tmp.inf = multdown(a.sup,b);
465 tmp.sup = multup(a.inf,b);
The Scalar Type interval.
interval & operator=(const real &a)
Implementation of standard assigning operator.
interval()
Constructor of class interval.
The namespace cxsc, providing all functionality of the class library C-XSC.
cdotprecision & operator+=(cdotprecision &cd, const l_complex &lc) noexcept
Implementation of standard algebraic addition and allocation operation.
civector operator/(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of division operation.
cvector diam(const cimatrix_subv &mv) noexcept
Returns the diameter of the matrix.
const real minreal
Smallest positive denormalized representable floating-point number.
interval _unchecked_interval(const real &a, const real &b)
cimatrix & operator*=(cimatrix &m, const cinterval &c) noexcept
Implementation of multiplication and allocation operation.
ivector abs(const cimatrix_subv &mv) noexcept
Returns the absolute value of the matrix.
void times2pown(cinterval &x, int n) noexcept
Fast multiplication of reference parameter [z] with .
civector operator*(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of multiplication operation.
cimatrix & operator/=(cimatrix &m, const cinterval &c) noexcept
Implementation of division and allocation operation.