00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 namespace cxsc {
00027
00028
00029
00030 inline idotprecision::idotprecision(const dotprecision &a,const dotprecision &b) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL)
00031 : inf(a), sup(b), k(0)
00032 {
00033 if(a>b)
00034 cxscthrow(ERROR_IDOTPRECISION_EMPTY_INTERVAL("inline idotprecision::idotprecision(const dotprecision &a,const dotprecision &b)"));
00035 inf.set_k(0);
00036 sup.set_k(0);
00037 }
00038
00039 inline idotprecision::idotprecision(const idotprecision &a)
00040 : inf(a.inf), sup(a.sup), k(a.k)
00041 {
00042
00043 }
00044
00045
00051 inline idotprecision _idotprecision(const real & a)
00052 {
00053 return idotprecision (a,a);
00054 }
00060 inline idotprecision _idotprecision(const real & a, const real & b)
00061 {
00062 return idotprecision (a,b);
00063 }
00069 inline idotprecision _unchecked_idotprecision(const real & a, const real & b) {
00070 idotprecision tmp;
00071 tmp.inf = a;
00072 tmp.sup = b;
00073 return tmp;
00074 }
00075
00081 inline idotprecision _idotprecision(const dotprecision & a)
00082 {
00083 return idotprecision (a,a);
00084 }
00090 inline idotprecision _idotprecision(const dotprecision & a, const dotprecision & b)
00091 {
00092 return idotprecision (a,b);
00093 }
00099 inline idotprecision _unchecked_idotprecision(const dotprecision & a, const dotprecision & b) {
00100 idotprecision tmp;
00101 tmp.inf = a;
00102 tmp.sup = b;
00103 return tmp;
00104 }
00105
00106
00107
00108
00109 inline idotprecision operator-(const idotprecision &a) throw() { return idotprecision (-a.sup, -a.inf); }
00110 inline idotprecision operator+(const idotprecision &a) throw() { return a; }
00111
00112 inline idotprecision operator+(const idotprecision &a,const idotprecision &b) throw() { return idotprecision(a.inf+b.inf,a.sup+b.sup); }
00113 inline idotprecision operator-(const idotprecision &a,const idotprecision &b) throw() { return idotprecision(a.inf-b.sup,a.sup-b.inf); }
00114 inline idotprecision operator |(const idotprecision &a,const idotprecision &b) throw()
00115 {
00116 return idotprecision((a.inf<b.inf)?a.inf:b.inf,(a.sup>b.sup)?a.sup:b.sup);
00117 }
00118
00119
00120 inline idotprecision operator +(const idotprecision &a,const dotprecision &b) throw() { return idotprecision(a.inf+b,a.sup+b); }
00121 inline idotprecision operator +(const dotprecision &b,const idotprecision &a) throw() { return idotprecision(a.inf+b,a.sup+b); }
00122 inline idotprecision operator -(const idotprecision &a,const dotprecision &b) throw() { return idotprecision(a.inf-b,a.sup-b); }
00123 inline idotprecision operator -(const dotprecision &a,const idotprecision &b) throw() { return idotprecision(a-b.sup,a-b.inf); }
00124
00125 inline idotprecision operator |(const dotprecision &a,const idotprecision &b) throw()
00126 {
00127 return idotprecision((a<b.inf)?a:b.inf,(a>b.sup)?a:b.sup);
00128 }
00129 inline idotprecision operator |(const idotprecision &a,const dotprecision &b) throw()
00130 {
00131 return idotprecision((a.inf<b)?a.inf:b,(a.sup>b)?a.sup:b);
00132 }
00133 inline idotprecision operator |(const dotprecision &a,const dotprecision &b) throw()
00134 {
00135 if(a>b) return idotprecision(b,a);
00136 else return idotprecision(a,b);
00137 }
00138 inline idotprecision operator &(const dotprecision &a,const idotprecision &b) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL)
00139 {
00140 return idotprecision((a>b.inf)?a:b.inf,(a<b.sup)?a:b.sup);
00141 }
00142 inline idotprecision operator &(const idotprecision &a,const dotprecision &b) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL)
00143 {
00144 return idotprecision((a.inf>b)?a.inf:b,(a.sup<b)?a.sup:b);
00145 }
00146
00147
00148
00149 inline idotprecision operator +(const idotprecision &a,const long &b) throw() { return idotprecision(a.inf+b,a.sup+b); }
00150 inline idotprecision operator +(const long &b,const idotprecision &a) throw() { return idotprecision(a.inf+b,a.sup+b); }
00151 inline idotprecision operator -(const idotprecision &a,const long &b) throw() { return idotprecision(a.inf-b,a.sup-b); }
00152 inline idotprecision operator -(const long &a,const idotprecision &b) throw() { return idotprecision(a-b.sup,a-b.inf); }
00153
00154 inline idotprecision operator |(const long &a,const idotprecision &b) throw()
00155 {
00156 return idotprecision((a<b.inf)?dotprecision(a):b.inf,(a>b.sup)?dotprecision(a):b.sup);
00157 }
00158 inline idotprecision operator |(const idotprecision &a,const long &b) throw()
00159 {
00160 return idotprecision((a.inf<b)?a.inf:dotprecision(b),(a.sup>b)?a.sup:dotprecision(b));
00161 }
00162 inline idotprecision operator &(const idotprecision &a,const idotprecision &b) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL)
00163 {
00164 return idotprecision((a.inf>b.inf)?a.inf:b.inf,(a.sup<b.sup)?a.sup:b.sup);
00165 }
00166 inline idotprecision operator &(const long &a,const idotprecision &b) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL)
00167 {
00168 return idotprecision((a>b.inf)?dotprecision(a):b.inf,(a<b.sup)?dotprecision(a):b.sup);
00169 }
00170 inline idotprecision operator &(const idotprecision &a,const long &b) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL)
00171 {
00172 return idotprecision((a.inf>b)?a.inf:dotprecision(b),(a.sup<b)?a.sup:dotprecision(b));
00173 }
00174
00175
00176
00177 inline idotprecision operator +(const idotprecision &a,const real &b) throw() { return idotprecision(a.inf+b,a.sup+b); }
00178 inline idotprecision operator +(const real &b,const idotprecision &a) throw() { return idotprecision(a.inf+b,a.sup+b); }
00179 inline idotprecision operator -(const idotprecision &a,const real &b) throw() { return idotprecision(a.inf-b,a.sup-b); }
00180 inline idotprecision operator -(const real &a,const idotprecision &b) throw() { return idotprecision(a-b.sup,a-b.inf); }
00181
00182 inline idotprecision operator |(const real &a,const idotprecision &b) throw()
00183 {
00184 return idotprecision((a<b.inf)?dotprecision(a):b.inf,(a>b.sup)?dotprecision(a):b.sup);
00185 }
00186 inline idotprecision operator |(const idotprecision &a,const real &b) throw()
00187 {
00188 return idotprecision((a.inf<b)?a.inf:dotprecision(b),(a.sup>b)?a.sup:dotprecision(b));
00189 }
00190 inline idotprecision operator &(const real &a,const idotprecision &b) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL)
00191 {
00192 return idotprecision((a>b.inf)?dotprecision(a):b.inf,(a<b.sup)?dotprecision(a):b.sup);
00193 }
00194 inline idotprecision operator &(const idotprecision &a,const real &b) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL)
00195 {
00196 return idotprecision((a.inf>b)?a.inf:dotprecision(b),(a.sup<b)?a.sup:dotprecision(b));
00197 }
00198
00199
00200
00201
00202 inline idotprecision operator +(const idotprecision &a,const interval &b) throw() { return idotprecision(a.inf+b.inf,a.sup+b.sup); }
00203 inline idotprecision operator +(const interval &b,const idotprecision &a) throw() { return idotprecision(a.inf+b.inf,a.sup+b.sup); }
00204 inline idotprecision operator -(const idotprecision &a,const interval &b) throw() { return idotprecision(a.inf-b.sup,a.sup-b.inf); }
00205 inline idotprecision operator -(const interval &a,const idotprecision &b) throw() { return idotprecision(a.inf-b.sup,a.sup-b.inf); }
00206
00207 inline idotprecision operator |(const interval &a,const idotprecision &b) throw()
00208 {
00209 return idotprecision((a.inf<b.inf)?dotprecision(a.inf):b.inf,(a.sup>b.sup)?dotprecision(a.sup):b.sup);
00210 }
00211 inline idotprecision operator |(const idotprecision &a,const interval &b) throw()
00212 {
00213 return idotprecision((a.inf<b.inf)?a.inf:dotprecision(b.inf),(a.sup>b.sup)?a.sup:dotprecision(b.sup));
00214 }
00215 inline idotprecision operator &(const interval &a,const idotprecision &b) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL)
00216 {
00217 return idotprecision((a.inf>b.inf)?dotprecision(a.inf):b.inf,(a.sup<b.sup)?dotprecision(a.sup):b.sup);
00218 }
00219 inline idotprecision operator &(const idotprecision &a,const interval &b) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL)
00220 {
00221 return idotprecision((a.inf>b.inf)?a.inf:dotprecision(b.inf),(a.sup<b.sup)?a.sup:dotprecision(b.sup));
00222 }
00223
00224
00225
00226 inline idotprecision operator |(const dotprecision &a,const real &b) throw()
00227 {
00228 if(a<b)
00229 return idotprecision(a,dotprecision(b));
00230 return idotprecision(dotprecision(b),a);
00231 }
00232 inline idotprecision operator |(const real &b,const dotprecision &a) throw()
00233 {
00234 if(a<b)
00235 return idotprecision(a,dotprecision(b));
00236 return idotprecision(dotprecision(b),a);
00237 }
00238
00239
00240
00241 inline idotprecision & operator +=(idotprecision &a,const idotprecision &b) throw() { a.inf+=b.inf,a.sup+=b.sup; return a;}
00242 inline idotprecision & operator +=(idotprecision &a,const dotprecision &b) throw() { a.inf+=b,a.sup+=b; return a;}
00243 inline idotprecision & operator -=(idotprecision &a,const idotprecision &b) throw() { a.inf-=b.inf,a.sup-=b.sup; return a;}
00244 inline idotprecision & operator -=(idotprecision &a,const dotprecision &b) throw() { a.inf-=b,a.sup-=b; return a;}
00245 inline idotprecision & operator +=(idotprecision &a,const interval &b) throw()
00246 {
00247 a.inf+=Inf(b);
00248 a.sup+=Sup(b);
00249 return a;
00250 }
00251 inline idotprecision & operator -=(idotprecision &a,const interval &b) throw()
00252 {
00253 a.inf-=Sup(b);
00254 a.sup-=Inf(b);
00255 return a;
00256 }
00257 inline idotprecision & operator +=(idotprecision &a,const real &b) throw()
00258 {
00259 a.inf+=b;
00260 a.sup+=b;
00261 return a;
00262 }
00263 inline idotprecision & operator -=(idotprecision &a,const real &b) throw()
00264 {
00265 a.inf-=b;
00266 a.sup-=b;
00267 return a;
00268 }
00269
00270
00271 inline idotprecision & operator |=(idotprecision &a,const idotprecision &b) throw()
00272 {
00273 if(b.inf<a.inf)
00274 a.inf=b.inf;
00275 if(b.sup>a.sup)
00276 a.sup=b.sup;
00277 return a;
00278 }
00279 inline idotprecision & operator &=(idotprecision &a,const idotprecision &b) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL)
00280 {
00281 if(b.inf>a.inf)
00282 a.inf=b.inf;
00283 if(b.sup<a.sup)
00284 a.sup=b.sup;
00285
00286 if(a.inf>a.sup)
00287 cxscthrow(ERROR_IDOTPRECISION_EMPTY_INTERVAL("inline idotprecision & operator &=(idotprecision &a,const idotprecision &b)"));
00288 return a;
00289 }
00290 inline idotprecision & operator |=(idotprecision &a,const dotprecision &b) throw()
00291 {
00292 if(b<a.inf)
00293 a.inf=b;
00294 if(b>a.sup)
00295 a.sup=b;
00296 return a;
00297 }
00298 inline idotprecision & operator &=(idotprecision &a,const dotprecision &b) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL)
00299 {
00300 if(b>a.inf)
00301 a.inf=b;
00302 if(b<a.sup)
00303 a.sup=b;
00304 if(a.inf>a.sup)
00305 cxscthrow(ERROR_IDOTPRECISION_EMPTY_INTERVAL("inline idotprecision & operator &=(idotprecision &a,const dotprecision &b)"));
00306 return a;
00307 }
00308
00309
00310 inline bool operator ==(const idotprecision &a,const idotprecision &b) throw() { return(a.inf==b.inf && a.sup==b.sup); }
00311 inline bool operator !=(const idotprecision &a,const idotprecision &b) throw() { return(a.inf!=b.inf || a.sup!=b.sup); }
00312 inline bool operator ==(const dotprecision &r,const idotprecision &a) throw() { return(r==a.inf && r==a.sup); }
00313 inline bool operator !=(const dotprecision &r,const idotprecision &a) throw() { return(r!=a.inf || r!=a.sup); }
00314 inline bool operator ==(const idotprecision &a,const dotprecision &r) throw() { return(r==a.inf && r==a.sup); }
00315 inline bool operator !=(const idotprecision &a,const dotprecision &r) throw() { return(r!=a.inf || r!=a.sup); }
00316
00317 inline bool operator ==(const real &r,const idotprecision &a) throw() { return(r==a.inf && r==a.sup); }
00318 inline bool operator !=(const real &r,const idotprecision &a) throw() { return(r!=a.inf || r!=a.sup); }
00319 inline bool operator ==(const idotprecision &a,const real &r) throw() { return(r==a.inf && r==a.sup); }
00320 inline bool operator !=(const idotprecision &a,const real &r) throw() { return(r!=a.inf || r!=a.sup); }
00321
00322 inline bool operator ==(const interval &a,const idotprecision &b) throw() { return(Inf(a)==b.inf && Sup(a)==b.sup); }
00323 inline bool operator !=(const interval &a,const idotprecision &b) throw() { return(Inf(a)!=b.inf || Sup(a)!=b.sup); }
00324 inline bool operator ==(const idotprecision &a,const interval &b) throw() { return(a.inf==Inf(b) && a.sup==Sup(b)); }
00325 inline bool operator !=(const idotprecision &a,const interval &b) throw() { return(a.inf!=Inf(b) || a.sup!=Sup(b)); }
00326
00327
00328
00329 inline bool operator <=(const idotprecision &a,const idotprecision &b) throw()
00330 {
00331 return(a.inf>=b.inf && a.sup<=b.sup);
00332 }
00333 inline bool operator >=(const idotprecision &a,const idotprecision &b) throw()
00334 {
00335 return(a.inf<=b.inf && a.sup>=b.sup);
00336 }
00337 inline bool operator <(const idotprecision &a,const idotprecision &b) throw()
00338 {
00339 return(a.inf>b.inf && a.sup<b.sup);
00340 }
00341 inline bool operator >(const idotprecision &a,const idotprecision &b) throw()
00342 {
00343 return(a.inf<b.inf && a.sup>b.sup);
00344 }
00345
00346 inline bool operator <=(const dotprecision &a,const idotprecision &b) throw()
00347 {
00348 return(a>=b.inf && a<=b.sup);
00349 }
00350 inline bool operator >=(const dotprecision &a,const idotprecision &b) throw()
00351 {
00352 return(a<=b.inf && a>=b.sup);
00353 }
00354 inline bool operator <(const dotprecision &a,const idotprecision &b) throw()
00355 {
00356 return(a>b.inf && a<b.sup);
00357 }
00358
00359 inline bool operator <=(const idotprecision &a,const dotprecision &b) throw()
00360 {
00361 return(a.inf>=b && a.sup<=b);
00362 }
00363 inline bool operator >=(const idotprecision &a,const dotprecision &b) throw()
00364 {
00365 return(a.inf<=b && a.sup>=b);
00366 }
00367 inline bool operator >(const idotprecision &a,const dotprecision &b) throw()
00368 {
00369 return(a.inf<b && a.sup>b);
00370 }
00371
00372 inline bool operator <=(const real &a,const idotprecision &b) throw()
00373 {
00374 return(a>=b.inf && a<=b.sup);
00375 }
00376 inline bool operator >=(const real &a,const idotprecision &b) throw()
00377 {
00378 return(a<=b.inf && a>=b.sup);
00379 }
00380 inline bool operator <(const real &a,const idotprecision &b) throw()
00381 {
00382 return(a>b.inf && a<b.sup);
00383 }
00384
00385 inline bool operator <=(const idotprecision &a,const real &b) throw()
00386 {
00387 return(a.inf>=b && a.sup<=b);
00388 }
00389 inline bool operator >=(const idotprecision &a,const real &b) throw()
00390 {
00391 return(a.inf<=b && a.sup>=b);
00392 }
00393 inline bool operator >(const idotprecision &a,const real &b) throw()
00394 {
00395 return(a.inf<b && a.sup>b);
00396 }
00397
00398 inline bool operator <=(const interval &a,const idotprecision &b) throw()
00399 {
00400 return(Inf(a)>=b.inf && Sup(a)<=b.sup);
00401 }
00402 inline bool operator >=(const interval &a,const idotprecision &b) throw()
00403 {
00404 return(Inf(a)<=b.inf && Sup(a)>=b.sup);
00405 }
00406 inline bool operator <(const interval &a,const idotprecision &b) throw()
00407 {
00408 return(Inf(a)>b.inf && Sup(a)<b.sup);
00409 }
00410 inline bool operator >(const interval &a,const idotprecision &b) throw()
00411 {
00412 return(Inf(a)<b.inf && Sup(a)>b.sup);
00413 }
00414
00415 inline bool operator <=(const idotprecision &a,const interval &b) throw()
00416 {
00417 return(a.inf>=Inf(b) && a.sup<=Sup(b));
00418 }
00419 inline bool operator >=(const idotprecision &a,const interval &b) throw()
00420 {
00421 return(a.inf<=Inf(b) && a.sup>=Sup(b));
00422 }
00423 inline bool operator <(const idotprecision &a,const interval &b) throw()
00424 {
00425 return(a.inf>Inf(b) && a.sup<Sup(b));
00426 }
00427 inline bool operator >(const idotprecision &a,const interval &b) throw()
00428 {
00429 return(a.inf<Inf(b) && a.sup>Sup(b));
00430 }
00431
00432
00433
00434 inline idotprecision & SetInf (idotprecision & a, const dotprecision & b) throw()
00435 {
00436 a.inf=b;
00437 return a;
00438 }
00439 inline idotprecision & SetSup (idotprecision & a, const dotprecision & b) throw()
00440 {
00441 a.sup=b;
00442 return a;
00443 }
00444 inline idotprecision & SetInf (idotprecision & a, const real & b) throw()
00445 {
00446 a.inf=b;
00447 return a;
00448 }
00449 inline idotprecision & SetSup (idotprecision & a, const real & b) throw()
00450 {
00451 a.sup=b;
00452 return a;
00453 }
00454 inline idotprecision & UncheckedSetInf (idotprecision & a, const dotprecision & b) throw()
00455 {
00456 a.inf=b;
00457 return a;
00458 }
00459 inline idotprecision & UncheckedSetSup (idotprecision & a, const dotprecision & b) throw()
00460 {
00461 a.sup=b;
00462 return a;
00463 }
00464 inline idotprecision & UncheckedSetInf (idotprecision & a, const real & b) throw()
00465 {
00466 a.inf=b;
00467 return a;
00468 }
00469 inline idotprecision & UncheckedSetSup (idotprecision & a, const real & b) throw()
00470 {
00471 a.sup=b;
00472 return a;
00473 }
00474
00475 inline bool operator !(const idotprecision &a) throw() { return (a.inf <= dotprecision(0.0) && a.sup >= dotprecision(0.0)); }
00476
00477 inline bool IsEmpty(const idotprecision &a) throw() { return (a.inf>a.sup); }
00478
00479 inline idotprecision abs(const idotprecision &a) throw()
00480 {
00481 dotprecision h1 = abs(a.inf);
00482 dotprecision h2 = abs(a.sup);
00483
00484 if (IsEmpty(a)) return a;
00485 if (!a)
00486 return idotprecision(dotprecision(0.0), (h1 > h2) ? h1 : h2);
00487 if (h1 > h2)
00488 return idotprecision(h2, h1);
00489
00490 return idotprecision(h1, h2);
00491 }
00492
00493 inline void accumulate (idotprecision & a, const interval & b, const real & c) throw() { accumulate(a,b,_interval(c)); }
00494 inline void accumulate (idotprecision & a, const real & b, const interval & c) throw() { accumulate(a,_interval(b),c); }
00495 inline void accumulate (idotprecision & a, const real & b, const real & c) throw() { accumulate(a,_interval(b),_interval(c)); }
00496
00497 }
00498