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_CINTERVAL_HPP_INCLUDED
00027 #define _CXSC_CINTERVAL_HPP_INCLUDED
00028
00029 #include <iostream>
00030 #include <string>
00031
00032
00033
00034 #include "except.hpp"
00035 #include "real.hpp"
00036 #include "complex.hpp"
00037 #include "interval.hpp"
00038
00039 namespace cxsc {
00040
00041 class civector;
00042 class cimatrix;
00043 class civector_slice;
00044 class cimatrix_slice;
00045
00047
00054 class cinterval
00055 {
00056 private:
00057
00058 interval re;
00059 interval im;
00060
00061 public:
00062
00064 inline cinterval(void) throw () {}
00066 inline cinterval(const interval & a,const interval &b) throw();
00068 inline cinterval(const complex & a,const complex & b) throw(ERROR_CINTERVAL_EMPTY_INTERVAL);
00069
00070
00071 #if(CXSC_INDEX_CHECK)
00072
00073 INLINE cinterval(const civector &) throw (ERROR_CIVECTOR_TYPE_CAST_OF_THICK_OBJ,ERROR_CIVECTOR_USE_OF_UNINITIALIZED_OBJ);
00075 INLINE cinterval(const civector_slice &) throw (ERROR_CIVECTOR_TYPE_CAST_OF_THICK_OBJ,ERROR_CIVECTOR_USE_OF_UNINITIALIZED_OBJ);
00077 INLINE cinterval(const cimatrix &) throw (ERROR_CIMATRIX_TYPE_CAST_OF_THICK_OBJ,ERROR_CIMATRIX_USE_OF_UNINITIALIZED_OBJ);
00079 INLINE cinterval(const cimatrix_slice &) throw (ERROR_CIMATRIX_TYPE_CAST_OF_THICK_OBJ,ERROR_CIMATRIX_USE_OF_UNINITIALIZED_OBJ);
00080 #else
00081
00082 INLINE cinterval(const civector &) throw ();
00084 INLINE cinterval(const civector_slice &) throw ();
00086 INLINE cinterval(const cimatrix &) throw ();
00088 INLINE cinterval(const cimatrix_slice &) throw ();
00089 #endif
00090
00091
00093 explicit inline cinterval(const real & a) throw();
00095 explicit inline cinterval(const interval & a) throw();
00097 explicit inline cinterval(const complex & a) throw();
00099 explicit cinterval(const dotprecision &) throw();
00101 explicit cinterval(const cdotprecision &) throw();
00103 explicit cinterval(const idotprecision &) throw();
00105 explicit cinterval(const cidotprecision &) throw();
00107 explicit cinterval(const l_cinterval&) throw();
00108
00109
00110
00112 inline cinterval & operator =(const real &) throw();
00114 inline cinterval & operator =(const interval &) throw();
00116 inline cinterval & operator =(const complex &) throw();
00118 inline cinterval & operator =(const cinterval &) throw();
00119
00121 inline cinterval & operator =(const dotprecision &) throw();
00123 inline cinterval & operator =(const idotprecision &) throw();
00125 inline cinterval & operator =(const cdotprecision &) throw();
00127 inline cinterval & operator =(const cidotprecision &) throw();
00129 cinterval & operator = (const l_cinterval&) throw();
00131 cinterval & operator = (const lx_cinterval&) throw();
00132
00133
00134
00136 friend inline cinterval _cinterval(const real &) throw ();
00138 friend inline cinterval _cinterval(const interval &) throw();
00140 friend inline cinterval _cinterval(const complex &) throw ();
00142 friend inline cinterval _cinterval(const dotprecision &) throw();
00144 friend inline cinterval _cinterval(const idotprecision &) throw();
00146 friend inline cinterval _cinterval(const cdotprecision &) throw();
00148 friend inline cinterval _cinterval(const cidotprecision &) throw();
00149
00151 friend inline cinterval _cinterval(const interval &,const interval &) throw();
00153 friend inline cinterval _cinterval(const real &,const interval &) throw();
00155 friend inline cinterval _cinterval(const interval &,const real &) throw();
00157 friend inline cinterval _cinterval(const complex &,const complex &) throw();
00159 friend inline cinterval _cinterval(const real &,const complex &) throw();
00161 friend inline cinterval _cinterval(const complex &,const real &) throw();
00163 friend inline cinterval _unchecked_cinterval(const complex &,const complex &) throw();
00165 friend inline cinterval _unchecked_cinterval(const real &,const complex &) throw();
00167 friend inline cinterval _unchecked_cinterval(const complex &,const real &) throw();
00168
00169
00170
00172 friend std::ostream & operator <<(std::ostream &,const cinterval &) throw();
00174 friend std::istream & operator >>(std::istream &,cinterval &) throw(ERROR_CINTERVAL_EMPTY_INTERVAL);
00176 friend std::string & operator <<(std::string &,const cinterval &) throw();
00178 friend std::string & operator >>(std::string &,cinterval &) throw(ERROR_CINTERVAL_EMPTY_INTERVAL);
00180 friend void operator >>(const char *,cinterval &) throw(ERROR_CINTERVAL_EMPTY_INTERVAL);
00182 friend void operator >>(const std::string &,cinterval &) throw(ERROR_CINTERVAL_EMPTY_INTERVAL);
00183
00184
00185
00187 friend inline cinterval operator -(const cinterval &) throw ();
00189 friend inline cinterval operator +(const cinterval &) throw ();
00191 friend inline bool operator! (const cinterval & a) throw();
00192
00193
00194
00196 friend inline cinterval operator +(const cinterval &,const cinterval &) throw();
00198 friend inline cinterval operator -(const cinterval &,const cinterval &) throw();
00200 friend cinterval operator *(const cinterval &,const cinterval &) throw();
00202 friend cinterval operator /(const cinterval &,const cinterval &) throw(DIV_BY_ZERO);
00204 friend inline cinterval operator |(const cinterval &,const cinterval &) throw();
00206 friend inline cinterval operator &(const cinterval &,const cinterval &) throw(ERROR_CINTERVAL_EMPTY_INTERVAL);
00207
00209 friend inline cinterval & operator +=(cinterval &, const cinterval &) throw();
00211 friend inline cinterval & operator -=(cinterval &, const cinterval &) throw();
00213 friend inline cinterval & operator *=(cinterval &, const cinterval &) throw();
00215 friend inline cinterval & operator /=(cinterval &, const cinterval &) throw();
00217 friend inline cinterval & operator |=(cinterval &, const cinterval &) throw();
00219 friend inline cinterval & operator &=(cinterval &, const cinterval &) throw(ERROR_CINTERVAL_EMPTY_INTERVAL);
00220
00221
00222
00224 friend inline cinterval operator +(const cinterval &,const real &) throw();
00226 friend inline cinterval operator +(const real &,const cinterval &) throw();
00228 friend inline cinterval operator -(const cinterval &,const real &) throw();
00230 friend inline cinterval operator -(const real &,const cinterval &) throw();
00232 friend inline cinterval operator *(const cinterval &,const real &) throw();
00234 friend inline cinterval operator *(const real &,const cinterval &) throw();
00236 friend inline cinterval operator /(const cinterval &,const real &) throw();
00238 friend inline cinterval operator /(const real &,const cinterval &) throw();
00240 friend inline cinterval operator |(const cinterval &,const real &) throw();
00242 friend inline cinterval operator |(const real &,const cinterval &) throw();
00244 friend inline cinterval operator &(const cinterval &,const real &) throw();
00246 friend inline cinterval operator &(const real &,const cinterval &) throw();
00247
00249 friend inline cinterval & operator +=(cinterval &, const real &) throw();
00251 friend inline cinterval & operator -=(cinterval &, const real &) throw();
00253 friend inline cinterval & operator *=(cinterval &, const real &) throw();
00255 friend inline cinterval & operator /=(cinterval &, const real &) throw();
00257 friend inline cinterval & operator |=(cinterval &, const real &) throw();
00259 friend inline cinterval & operator &=(cinterval &, const real &) throw();
00260
00261
00262
00264 friend inline cinterval operator +(const cinterval &,const interval &) throw();
00266 friend inline cinterval operator +(const interval &,const cinterval &) throw();
00268 friend inline cinterval operator -(const cinterval &,const interval &) throw();
00270 friend inline cinterval operator -(const interval &,const cinterval &) throw();
00272 friend inline cinterval operator *(const cinterval &,const interval &) throw();
00274 friend inline cinterval operator *(const interval &,const cinterval &) throw();
00276 friend inline cinterval operator /(const cinterval &,const interval &) throw();
00278 friend inline cinterval operator /(const interval &,const cinterval &) throw();
00280 friend inline cinterval operator |(const cinterval &,const interval &) throw();
00282 friend inline cinterval operator |(const interval &,const cinterval &) throw();
00284 friend inline cinterval operator &(const cinterval &,const interval &) throw();
00286 friend inline cinterval operator &(const interval &,const cinterval &) throw();
00287
00289 friend inline cinterval & operator +=(cinterval &, const interval &) throw();
00291 friend inline cinterval & operator -=(cinterval &, const interval &) throw();
00293 friend inline cinterval & operator *=(cinterval &, const interval &) throw();
00295 friend inline cinterval & operator /=(cinterval &, const interval &) throw();
00297 friend inline cinterval & operator |=(cinterval &, const interval &) throw();
00299 friend inline cinterval & operator &=(cinterval &, const interval &) throw();
00300
00301
00302
00304 friend inline cinterval operator +(const cinterval &,const complex &) throw();
00306 friend inline cinterval operator +(const complex &,const cinterval &) throw();
00308 friend inline cinterval operator -(const cinterval &,const complex &) throw();
00310 friend inline cinterval operator -(const complex &,const cinterval &) throw();
00312 friend inline cinterval operator *(const cinterval &,const complex &) throw();
00314 friend inline cinterval operator *(const complex &,const cinterval &) throw();
00316 friend inline cinterval operator /(const cinterval &,const complex &) throw();
00318 friend inline cinterval operator /(const complex &,const cinterval &) throw();
00320 friend inline cinterval operator |(const cinterval &,const complex &) throw();
00322 friend inline cinterval operator |(const complex &,const cinterval &) throw();
00324 friend inline cinterval operator &(const cinterval &,const complex &) throw();
00326 friend inline cinterval operator &(const complex &,const cinterval &) throw();
00327
00328
00330 friend inline cinterval & operator +=(cinterval &, const complex &) throw();
00332 friend inline cinterval & operator -=(cinterval &, const complex &) throw();
00334 friend inline cinterval & operator *=(cinterval &, const complex &) throw();
00336 friend inline cinterval & operator /=(cinterval &, const complex &) throw();
00338 friend inline cinterval & operator |=(cinterval &, const complex &) throw();
00340 friend inline cinterval & operator &=(cinterval &, const complex &) throw();
00341
00342
00343
00345 friend inline cinterval operator |(const complex &,const real &) throw();
00347 friend inline cinterval operator |(const real &,const complex &) throw();
00348
00349
00350
00352 friend inline cinterval operator +(const complex &,const interval &) throw();
00354 friend inline cinterval operator +(const interval &,const complex &) throw();
00356 friend inline cinterval operator -(const complex &,const interval &) throw();
00358 friend inline cinterval operator -(const interval &,const complex &) throw();
00360 friend inline cinterval operator *(const complex &,const interval &) throw();
00362 friend inline cinterval operator *(const interval &,const complex &) throw();
00364 friend inline cinterval operator /(const complex &,const interval &) throw();
00366 friend inline cinterval operator /(const interval &,const complex &) throw();
00368 friend inline cinterval operator |(const complex &,const interval &) throw();
00370 friend inline cinterval operator |(const interval &,const complex &) throw();
00372 friend inline cinterval operator &(const complex &,const interval &) throw();
00374 friend inline cinterval operator &(const interval &,const complex &) throw();
00375
00376
00377
00378
00380 friend inline cinterval operator |(const complex &,const complex &) throw();
00381
00382
00383
00385 friend inline bool operator== (const cinterval & a, const cinterval & b) throw();
00387 friend inline bool operator!= (const cinterval & a, const cinterval & b) throw();
00388
00389
00390
00392 friend inline bool operator== (const cinterval & a, const real & b) throw();
00394 friend inline bool operator== (const real & a, const cinterval & b) throw();
00396 friend inline bool operator!= (const cinterval & a, const real & b) throw();
00398 friend inline bool operator!= (const real & a, const cinterval & b) throw();
00399
00400
00401
00403 friend inline bool operator== (const cinterval & a, const interval & b) throw();
00405 friend inline bool operator== (const interval & a, const cinterval & b) throw();
00407 friend inline bool operator!= (const cinterval & a, const interval & b) throw();
00409 friend inline bool operator!= (const interval & a, const cinterval & b) throw();
00410
00411
00412
00414 friend inline bool operator== (const cinterval & a, const complex & b) throw();
00416 friend inline bool operator== (const complex & a, const cinterval & b) throw();
00418 friend inline bool operator!= (const cinterval & a, const complex & b) throw();
00420 friend inline bool operator!= (const complex & a, const cinterval & b) throw();
00421
00422
00423
00425 friend inline bool operator <(const cinterval &,const cinterval &) throw();
00427 friend inline bool operator >(const cinterval &,const cinterval &) throw();
00429 friend inline bool operator <=(const cinterval &,const cinterval &) throw();
00431 friend inline bool operator >=(const cinterval &,const cinterval &) throw();
00432
00433
00434
00436 friend inline bool operator <(const real &,const cinterval &) throw();
00438 friend inline bool operator >(const real &,const cinterval &) throw();
00440 friend inline bool operator <=(const real &,const cinterval &) throw();
00442 friend inline bool operator >=(const real &,const cinterval &) throw();
00443
00445 friend inline bool operator <(const cinterval &,const real &) throw();
00447 friend inline bool operator >(const cinterval &,const real &) throw();
00449 friend inline bool operator <=(const cinterval &,const real &) throw();
00451 friend inline bool operator >=(const cinterval &,const real &) throw();
00452
00453
00454
00456 friend inline bool operator <(const interval &,const cinterval &) throw();
00458 friend inline bool operator >(const interval &,const cinterval &) throw();
00460 friend inline bool operator <=(const interval &,const cinterval &) throw();
00462 friend inline bool operator >=(const interval &,const cinterval &) throw();
00463
00465 friend inline bool operator <(const cinterval &,const interval &) throw();
00467 friend inline bool operator >(const cinterval &,const interval &) throw();
00469 friend inline bool operator <=(const cinterval &,const interval &) throw();
00471 friend inline bool operator >=(const cinterval &,const interval &) throw();
00472
00473
00474
00476 friend inline bool operator <(const complex &,const cinterval &) throw();
00478 friend inline bool operator >(const complex &,const cinterval &) throw();
00480 friend inline bool operator <=(const complex &,const cinterval &) throw();
00482 friend inline bool operator >=(const complex &,const cinterval &) throw();
00483
00485 friend inline bool operator <(const cinterval &,const complex &) throw();
00487 friend inline bool operator >(const cinterval &,const complex &) throw();
00489 friend inline bool operator <=(const cinterval &,const complex &) throw();
00491 friend inline bool operator >=(const cinterval &,const complex &) throw();
00492
00493
00495 friend inline complex Inf(const cinterval &) throw();
00497 friend inline complex Sup(const cinterval &) throw();
00498
00500 friend inline cinterval & SetInf(cinterval &,const complex &) throw(ERROR_CINTERVAL_EMPTY_INTERVAL);
00502 friend inline cinterval & SetInf(cinterval &,const real &) throw(ERROR_CINTERVAL_EMPTY_INTERVAL);
00504 friend inline cinterval & SetSup(cinterval &,const complex &) throw(ERROR_CINTERVAL_EMPTY_INTERVAL);
00506 friend inline cinterval & SetSup(cinterval &,const real &) throw(ERROR_CINTERVAL_EMPTY_INTERVAL);
00508 friend inline cinterval & UncheckedSetInf(cinterval &,const complex &) throw();
00510 friend inline cinterval & UncheckedSetInf(cinterval &,const real &) throw();
00512 friend inline cinterval & UncheckedSetSup(cinterval &,const complex &) throw();
00514 friend inline cinterval & UncheckedSetSup(cinterval &,const real &) throw();
00515
00517 friend inline interval & Re(cinterval & a) throw();
00519 friend inline interval Re(const cinterval & a) throw();
00521 friend inline interval & Im(cinterval & a) throw();
00523 friend inline interval Im(const cinterval & a) throw();
00524
00526 friend inline cinterval & SetRe(cinterval & a,const interval & b);
00528 friend inline cinterval & SetIm(cinterval & a,const interval & b);
00530 friend inline cinterval & SetRe(cinterval & a,const real & b);
00532 friend inline cinterval & SetIm(cinterval & a,const real & b);
00533
00535 friend inline real InfRe(const cinterval &a) throw();
00537 friend inline real InfIm(const cinterval &a) throw();
00539 friend inline real SupRe(const cinterval &a) throw();
00541 friend inline real SupIm(const cinterval &a) throw();
00542
00544 friend inline real & InfRe(cinterval &a) throw();
00546 friend inline real & InfIm(cinterval &a) throw();
00548 friend inline real & SupRe(cinterval &a) throw();
00550 friend inline real & SupIm(cinterval &a) throw();
00551
00553 friend interval abs(const cinterval &) throw();
00555 friend inline cinterval conj(const cinterval &) throw();
00557 friend inline complex mid(const cinterval &) throw();
00559 friend inline complex diam(const cinterval &) throw();
00560 };
00561
00563 extern int in ( const cinterval&, const cinterval& );
00565 extern cinterval Blow ( cinterval, const real& );
00566
00567
00568 interval abs(const cinterval &) throw();
00569
00570 }
00571
00572 #include "cinterval.inl"
00573 #include "cimath.hpp"
00574
00575 #endif // _CXSC_CINTERVAL_HPP_INCLUDED
00576