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 #ifndef _CXSC_IDOT_HPP_INCLUDED
00027 #define _CXSC_IDOT_HPP_INCLUDED
00028
00029 #include <iostream>
00030 #include <string>
00031 #include "dot.hpp"
00032 #include "interval.hpp"
00033
00034 namespace cxsc {
00035
00037
00047 class idotprecision
00048 {
00049 private:
00050
00051 dotprecision inf,sup;
00052 int k;
00053
00054 public:
00055
00057 idotprecision() : k(0) {}
00059 inline idotprecision(const dotprecision&, const dotprecision&) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00061 inline idotprecision(const idotprecision&);
00062
00063
00064
00065
00066
00067
00068
00069
00071 explicit inline idotprecision(const real & a) : inf(a), sup(a), k(0) { }
00073 explicit inline idotprecision(const real & a,const real & b) : inf(a), sup(b), k(0) { }
00075 explicit inline idotprecision(const interval & a) : inf(Inf(a)), sup(Sup(a)), k(0) { }
00077 explicit inline idotprecision(const dotprecision &r) : inf(r), sup(r), k(0) { inf.set_k(0); sup.set_k(0); }
00079 explicit idotprecision(const l_real &) throw();
00081 explicit idotprecision(const l_real &,const l_real &);
00083 explicit idotprecision(const l_interval &) throw();
00084
00086 inline int get_k() const { return k; }
00088 inline void set_k(unsigned int i) { k=i; inf.set_k(i); sup.set_k(i); }
00090 inline int get_dotprec() const { return k; }
00092 inline void set_dotprec(unsigned int i) { k=i; inf.set_k(i); sup.set_k(i); }
00093
00094
00096 inline idotprecision& operator= (const real& a) { inf=sup=a; return *this; }
00098 inline idotprecision& operator= (const interval& a) { inf=Inf(a); sup=Sup(a); return *this; }
00099
00101 inline idotprecision& operator= (const dotprecision& a) { inf=sup=a; return *this; }
00103 inline idotprecision& operator= (const idotprecision& a){ inf=a.inf; sup=a.sup; return *this; }
00105 inline idotprecision& operator= (const l_real & a) { inf=sup=a; return *this; }
00107 idotprecision& operator= (const l_interval &) throw();
00108
00109
00110
00111
00112
00114 friend inline idotprecision _idotprecision(const real &);
00116 friend inline idotprecision _idotprecision(const real &,const real &);
00118 friend inline idotprecision _unchecked_idotprecision(const real &,const real &);
00120 friend inline idotprecision _idotprecision(const dotprecision&);
00122 friend inline idotprecision _idotprecision(const dotprecision&, const dotprecision&);
00124 friend inline idotprecision _unchecked_idotprecision(const dotprecision&, const dotprecision&);
00125
00127 friend inline idotprecision _idotprecision(const l_real &a) throw() { return idotprecision(a); }
00129 friend inline idotprecision _idotprecision(const l_real &a,const l_real &b) { return idotprecision(a,b); }
00130
00131
00132
00134 friend std::istream& operator >> (std::istream& s, idotprecision& a) throw();
00136 friend std::ostream& operator << (std::ostream& s, const idotprecision& a) throw();
00138 friend std::string& operator >> (std::string& s, idotprecision& a) throw();
00140 friend std::string& operator << (std::string& s, const idotprecision& a) throw();
00142 friend void operator >> (const std::string &s,idotprecision& a) throw();
00144 friend void operator >> (const char *s ,idotprecision& a) throw();
00145
00146
00148 friend inline idotprecision operator -(const idotprecision &) throw();
00150 friend inline idotprecision operator +(const idotprecision &) throw();
00151
00153 friend inline idotprecision operator +(const idotprecision &,const idotprecision &) throw();
00155 friend inline idotprecision operator -(const idotprecision &,const idotprecision &) throw();
00157 friend inline idotprecision operator |(const idotprecision &,const idotprecision &) throw();
00159 friend inline idotprecision operator &(const idotprecision &,const idotprecision &) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00160
00162 friend inline idotprecision operator +(const idotprecision &,const dotprecision &) throw();
00164 friend inline idotprecision operator +(const dotprecision &,const idotprecision &) throw();
00166 friend inline idotprecision operator -(const idotprecision &,const dotprecision &) throw();
00168 friend inline idotprecision operator -(const dotprecision &,const idotprecision &) throw();
00170 friend inline idotprecision operator |(const dotprecision &,const idotprecision &) throw();
00172 friend inline idotprecision operator |(const idotprecision &,const dotprecision &) throw();
00174 friend inline idotprecision operator |(const dotprecision &,const dotprecision &) throw();
00176 friend inline idotprecision operator &(const dotprecision &,const idotprecision &) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00178 friend inline idotprecision operator &(const idotprecision &,const dotprecision &) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00179
00181 friend inline idotprecision operator +(const idotprecision &,const long &) throw();
00183 friend inline idotprecision operator +(const long &,const idotprecision &) throw();
00185 friend inline idotprecision operator -(const idotprecision &,const long &) throw();
00187 friend inline idotprecision operator -(const long &,const idotprecision &) throw();
00189 friend inline idotprecision operator |(const long &,const idotprecision &) throw();
00191 friend inline idotprecision operator |(const idotprecision &,const long &) throw();
00193 friend inline idotprecision operator &(const long &,const idotprecision &) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00195 friend inline idotprecision operator &(const idotprecision &,const long &) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00196
00198 friend inline idotprecision operator +(const idotprecision &,const real &) throw();
00200 friend inline idotprecision operator +(const real &,const idotprecision &) throw();
00202 friend inline idotprecision operator -(const idotprecision &,const real &) throw();
00204 friend inline idotprecision operator -(const real &,const idotprecision &) throw();
00206 friend inline idotprecision operator |(const real &,const idotprecision &) throw();
00208 friend inline idotprecision operator |(const idotprecision &,const real &) throw();
00210 friend inline idotprecision operator &(const real &,const idotprecision &) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00212 friend inline idotprecision operator &(const idotprecision &,const real &) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00213
00215 friend idotprecision operator +(const idotprecision &,const l_real &) throw();
00217 friend idotprecision operator +(const l_real &,const idotprecision &) throw();
00219 friend idotprecision operator -(const idotprecision &,const l_real &) throw();
00221 friend idotprecision operator -(const l_real &,const idotprecision &) throw();
00223 friend idotprecision operator |(const l_real &,const idotprecision &) throw();
00225 friend idotprecision operator |(const idotprecision &,const l_real &) throw();
00227 friend idotprecision operator &(const l_real &,const idotprecision &) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00229 friend idotprecision operator &(const idotprecision &,const l_real &) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00230
00232 friend inline idotprecision operator +(const idotprecision &,const interval &) throw();
00234 friend inline idotprecision operator +(const interval &,const idotprecision &) throw();
00236 friend inline idotprecision operator -(const idotprecision &,const interval &) throw();
00238 friend inline idotprecision operator -(const interval &,const idotprecision &) throw();
00240 friend inline idotprecision operator |(const interval &,const idotprecision &) throw();
00242 friend inline idotprecision operator |(const idotprecision &,const interval &) throw();
00244 friend inline idotprecision operator &(const interval &,const idotprecision &) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00246 friend inline idotprecision operator &(const idotprecision &,const interval &) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00247
00249 friend inline idotprecision & operator +=(idotprecision &,const idotprecision &) throw();
00251 friend inline idotprecision & operator -=(idotprecision &,const idotprecision &) throw();
00253 friend inline idotprecision & operator +=(idotprecision &,const interval &) throw();
00255 friend inline idotprecision & operator -=(idotprecision &,const interval &) throw();
00257 friend inline idotprecision & operator +=(idotprecision &,const real &) throw();
00259 friend inline idotprecision & operator -=(idotprecision &,const real &) throw();
00261 friend idotprecision & operator +=(idotprecision &,const l_real &) throw();
00263 friend idotprecision & operator -=(idotprecision &,const l_real &) throw();
00265 friend inline idotprecision & operator +=(idotprecision &,const l_interval &) throw();
00267 friend inline idotprecision & operator -=(idotprecision &,const l_interval &) throw();
00268
00270 friend inline idotprecision & operator |=(idotprecision &,const idotprecision &) throw();
00272 friend inline idotprecision & operator &=(idotprecision &,const idotprecision &) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00273
00275 friend inline idotprecision & operator +=(idotprecision &,const dotprecision &) throw();
00277 friend inline idotprecision & operator -=(idotprecision &,const dotprecision &) throw();
00278
00280 friend inline idotprecision & operator |=(idotprecision &,const dotprecision &) throw();
00282 friend inline idotprecision & operator &=(idotprecision &,const dotprecision &) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00283
00284
00285
00287 friend inline idotprecision & operator |=(idotprecision & i,const real & l) throw() { return i|=dotprecision(l); }
00289 friend inline idotprecision & operator &=(idotprecision & i,const real & l) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL) { return i&=dotprecision(l); }
00290
00292 friend idotprecision & operator |=(idotprecision & i,const l_real & l) throw();
00294 friend idotprecision & operator &=(idotprecision & i,const l_real & l) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00295
00297 friend inline idotprecision & operator |=(idotprecision & i,const l_interval & l) throw();
00299 friend inline idotprecision & operator &=(idotprecision & i,const l_interval & l) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL);
00300
00301
00302
00304 friend inline bool operator ==(const idotprecision &,const idotprecision &) throw();
00306 friend inline bool operator !=(const idotprecision &,const idotprecision &) throw();
00307
00309 friend inline bool operator ==(const dotprecision &,const idotprecision &) throw();
00311 friend inline bool operator !=(const dotprecision &,const idotprecision &) throw();
00312
00314 friend inline bool operator ==(const idotprecision &,const dotprecision &) throw();
00316 friend inline bool operator !=(const idotprecision &,const dotprecision &) throw();
00317
00319 friend inline bool operator ==(const real &,const idotprecision &) throw();
00321 friend inline bool operator !=(const real &,const idotprecision &) throw();
00322
00324 friend inline bool operator ==(const idotprecision &,const real &) throw();
00326 friend inline bool operator !=(const idotprecision &,const real &) throw();
00327
00329 friend inline bool operator ==(const interval &,const idotprecision &) throw();
00331 friend inline bool operator !=(const interval &,const idotprecision &) throw();
00332
00334 friend inline bool operator ==(const idotprecision &,const interval &) throw();
00336 friend inline bool operator !=(const idotprecision &,const interval &) throw();
00337
00338
00339
00341 friend inline bool operator <(const idotprecision &,const idotprecision &) throw();
00343 friend inline bool operator >(const idotprecision &,const idotprecision &) throw();
00345 friend inline bool operator <=(const idotprecision &,const idotprecision &) throw();
00347 friend inline bool operator >=(const idotprecision &,const idotprecision &) throw();
00348
00350 friend inline bool operator <(const dotprecision &,const idotprecision &) throw();
00352 friend inline bool operator >(const dotprecision &,const idotprecision &) throw() { return false; }
00354 friend inline bool operator <=(const dotprecision &,const idotprecision &) throw();
00356 friend inline bool operator >=(const dotprecision &,const idotprecision &) throw();
00357
00359 friend inline bool operator <(const idotprecision &,const dotprecision &) throw() { return false; }
00361 friend inline bool operator >(const idotprecision &,const dotprecision &) throw();
00363 friend inline bool operator <=(const idotprecision &,const dotprecision &) throw();
00365 friend inline bool operator >=(const idotprecision &,const dotprecision &) throw();
00366
00368 friend inline bool operator <(const real &,const idotprecision &) throw();
00370 friend inline bool operator >(const real &,const idotprecision &) throw() { return false; }
00372 friend inline bool operator <=(const real &,const idotprecision &) throw();
00374 friend inline bool operator >=(const real &,const idotprecision &) throw();
00375
00377 friend inline bool operator <(const idotprecision &,const real &) throw() { return false; }
00379 friend inline bool operator >(const idotprecision &,const real &) throw();
00381 friend inline bool operator <=(const idotprecision &,const real &) throw();
00383 friend inline bool operator >=(const idotprecision &,const real &) throw();
00384
00386 friend inline bool operator <(const interval &,const idotprecision &) throw();
00388 friend inline bool operator >(const interval &,const idotprecision &) throw();
00390 friend inline bool operator <=(const interval &,const idotprecision &) throw();
00392 friend inline bool operator >=(const interval &,const idotprecision &) throw();
00393
00395 friend inline bool operator <(const idotprecision &,const interval &) throw();
00397 friend inline bool operator >(const idotprecision &,const interval &) throw();
00399 friend inline bool operator <=(const idotprecision &,const interval &) throw();
00401 friend inline bool operator >=(const idotprecision &,const interval &) throw();
00402
00404 friend inline bool operator !(const idotprecision&) throw();
00405
00406
00407
00408
00410 friend dotprecision & Inf(idotprecision& a) throw() { return a.inf; }
00412 friend dotprecision & Sup(idotprecision& a) throw() { return a.sup; }
00414 friend const dotprecision & Inf(const idotprecision& a) throw() { return a.inf; }
00416 friend const dotprecision & Sup(const idotprecision& a) throw() { return a.sup; }
00417
00419 friend inline idotprecision& SetInf (idotprecision &, const dotprecision &) throw();
00421 friend inline idotprecision& SetSup (idotprecision &, const dotprecision &) throw();
00423 friend inline idotprecision& SetInf (idotprecision &, const real &) throw();
00425 friend inline idotprecision& SetSup (idotprecision &, const real &) throw();
00427 friend inline idotprecision& UncheckedSetInf (idotprecision &, const dotprecision &) throw();
00429 friend inline idotprecision& UncheckedSetSup (idotprecision &, const dotprecision &) throw();
00431 friend inline idotprecision& UncheckedSetInf (idotprecision &, const real &) throw();
00433 friend inline idotprecision& UncheckedSetSup (idotprecision &, const real &) throw();
00434
00436 friend inline bool IsEmpty (const idotprecision& a) throw();
00437
00439 friend inline idotprecision abs (const idotprecision& a) throw();
00441 friend inline dotprecision mid (const idotprecision& a) throw();
00443 friend inline dotprecision diam (const idotprecision& a) throw();
00444
00445 friend void rnd(const idotprecision &,interval &) throw();
00446 friend interval rnd(const idotprecision &) throw();
00447
00449 friend void accumulate (idotprecision&, const interval&, const interval&) throw();
00451 friend inline void accumulate (idotprecision&, const interval&, const real&) throw();
00453 friend inline void accumulate (idotprecision&, const real&, const interval&) throw();
00455 friend inline void accumulate (idotprecision&, const real&, const real&) throw();
00456 };
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466 }
00467
00468 #include "idot.inl"
00469
00470 #endif
00471