C-XSC - A C++ Class Library for Extended Scientific Computing  2.5.4
cinterval.inl
00001 /*
00002 **  CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4)
00003 **
00004 **  Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik,
00005 **                          Universitaet Karlsruhe, Germany
00006 **            (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie
00007 **                          Universitaet Wuppertal, Germany   
00008 **
00009 **  This library is free software; you can redistribute it and/or
00010 **  modify it under the terms of the GNU Library General Public
00011 **  License as published by the Free Software Foundation; either
00012 **  version 2 of the License, or (at your option) any later version.
00013 **
00014 **  This library is distributed in the hope that it will be useful,
00015 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 **  Library General Public License for more details.
00018 **
00019 **  You should have received a copy of the GNU Library General Public
00020 **  License along with this library; if not, write to the Free
00021 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 */
00023 
00024 /* CVS $Id: cinterval.inl,v 1.20 2014/01/30 17:23:44 cxsc Exp $ */
00025 
00026 namespace cxsc {
00027 
00028 // Inlined functions for cinterval.
00029 
00030 // ---- implicit constructors  ------------------------------
00031       
00032 inline cinterval::cinterval(const interval & a,const interval & b) throw()
00033       : re(a), im(b)
00034 {
00035 }
00036 
00037 inline cinterval::cinterval(const complex & a,const complex & b)  throw(ERROR_CINTERVAL_EMPTY_INTERVAL)
00038    : re(Re(a),Re(b)),
00039      im(Im(a),Im(b))
00040 {
00041    if(Inf(re)>Sup(re) || Inf(im)>Sup(im))
00042       cxscthrow(ERROR_CINTERVAL_EMPTY_INTERVAL("cinterval::cinterval(const complex & a,const complex & b)"));
00043 }
00044 
00045 // ---- explicit constructors  ------------------------------
00046 
00047 inline cinterval::cinterval(const real     & a) throw() : re(a,a), im(0,0) {}
00048 inline cinterval::cinterval(const interval & a) throw() : re(a), im(0,0) {}
00049 inline cinterval::cinterval(const complex  & a) throw() : re(Re(a),Re(a)),im(Im(a),Im(a)) {} 
00050       
00051 // ---- assignments -----------------------------------------
00052 
00053 inline cinterval & cinterval::operator =(const real & a) throw()
00054 {
00055    re=a,im=0.0;
00056    return *this;   
00057 }
00058 
00059 inline cinterval & cinterval::operator =(const interval & a) throw()
00060 {
00061    re=a,im=0.0;
00062    return *this;
00063 }
00064 
00065 inline cinterval & cinterval::operator =(const complex & a) throw()
00066 {
00067    re=Re(a),im=Im(a);
00068    return *this;
00069 }
00070 
00071 inline cinterval & cinterval::operator =(const cinterval & a) throw()
00072 {
00073    re=a.re;
00074    im=a.im;
00075    return *this;
00076 }
00077 
00078 inline cinterval & cinterval::operator =(const dotprecision & a) throw()
00079 {
00080    return *this=cinterval(a);
00081 }
00082 
00083 inline cinterval & cinterval::operator =(const idotprecision & a) throw()
00084 {
00085    return *this=cinterval(a);
00086 }
00087 
00088 inline cinterval & cinterval::operator =(const cdotprecision & a) throw()
00089 {
00090    return *this=cinterval(a);
00091 }
00092 
00093 inline cinterval & cinterval::operator =(const cidotprecision & a) throw()
00094 {
00095    return *this=cinterval(a);
00096 }
00097 
00098 // ---- compatiblility typecasts ----------------------------
00099 
00105 inline cinterval _cinterval(const real & a) throw ()
00106 {
00107    return cinterval(interval(a,a), interval(0.0,0.0));
00108 }
00109 
00115 inline cinterval _cinterval(const complex & a) throw ()
00116 {
00117    return cinterval(a,a);
00118 }
00119 
00125 inline cinterval _cinterval(const interval & a) throw()
00126 {
00127    return cinterval(a,_interval(0.0,0.0));
00128 }
00129 
00135 inline cinterval _cinterval(const dotprecision & a) throw() { return cinterval(a); }
00136 
00142 inline cinterval _cinterval(const cdotprecision & a) throw() { return cinterval(a); }
00143 
00149 inline cinterval _cinterval(const idotprecision & a) throw() { return cinterval(a); }
00150 
00156 inline cinterval _cinterval(const cidotprecision & a) throw() { return cinterval(a); }
00157 
00163 inline cinterval _cinterval(const complex & a,const complex & b) throw()
00164 {
00165    return cinterval(interval(Re(a),Re(b)),interval(Im(a),Im(b)));
00166 }
00167 
00173 inline cinterval _cinterval(const real & a,const complex & b) throw()
00174 {
00175    return cinterval(complex(a),b);
00176 }
00177 
00183 inline cinterval _cinterval(const complex & a,const real & b) throw()
00184 {
00185    return cinterval(a,complex(b));
00186 }
00187 
00193 inline cinterval _cinterval(const interval & a,const interval & b) throw()
00194 {
00195    return cinterval(a,b);
00196 }
00197 
00203 inline cinterval _cinterval(const real & a,const interval & b) throw()
00204 {
00205    return cinterval(interval(a),b);   
00206 }
00207 
00213 inline cinterval _cinterval(const interval & a,const real & b) throw()
00214 {
00215    return cinterval(a,interval(b));
00216 }
00217 
00223 inline cinterval _unchecked_cinterval(const complex & a,const complex & b) throw()
00224 {
00225    cinterval tmp;
00226    UncheckedSetInf(tmp,a);
00227    UncheckedSetSup(tmp,b);
00228    return tmp;
00229 }
00230 
00236 inline cinterval _unchecked_cinterval(const real & a,const complex & b) throw()
00237 {
00238    cinterval tmp;
00239    UncheckedSetInf(tmp,_complex(a));
00240    UncheckedSetSup(tmp,b);
00241    return tmp;
00242 }
00243 
00249 inline cinterval _unchecked_cinterval(const complex & a,const real & b) throw()
00250 {
00251    cinterval tmp;
00252    UncheckedSetInf(tmp,a);
00253    UncheckedSetSup(tmp,_complex(b));
00254    return tmp;
00255 }
00256 
00257 // ---- Std.Operators ---------------------------------------
00258 
00259 inline cinterval operator -(const cinterval & a) throw ()
00260 {
00261    return cinterval(-a.re,-a.im);
00262 }
00263 
00264 inline cinterval operator +(const cinterval & a) throw ()
00265 {
00266    return a;
00267 }
00268 
00269 inline cinterval operator +(const cinterval & a,const cinterval & b) throw()
00270 {
00271    return cinterval(a.re+b.re,a.im+b.im);
00272 }
00273 
00274 inline cinterval operator -(const cinterval & a,const cinterval & b) throw()
00275 {
00276    return cinterval(a.re-b.re,a.im-b.im);
00277 }
00278 
00279 inline cinterval operator &(const cinterval & a,const cinterval & b) throw(ERROR_CINTERVAL_EMPTY_INTERVAL)
00280 {
00281    cinterval tmp = a;
00282    SetInf(tmp.re, max(Inf(a.re), Inf(b.re)));
00283    SetInf(tmp.im, max(Inf(a.im), Inf(b.im)));
00284    SetSup(tmp.re, min(Sup(a.re), Sup(b.re)));
00285    SetSup(tmp.im, min(Sup(a.im), Sup(b.im)));
00286    if (Inf(tmp.re) > Sup(tmp.re) || Inf(tmp.im) > Sup(tmp.im)) 
00287       cxscthrow(ERROR_CINTERVAL_EMPTY_INTERVAL("inline cinterval operator &(const cinterval & a,const cinterval & b)"));
00288   return tmp;
00289 }
00290 
00291 inline cinterval operator |(const cinterval & a,const cinterval & b) throw()
00292 {
00293    cinterval tmp = a;
00294    SetInf(tmp.re, min(Inf(a.re), Inf(b.re)));
00295    SetInf(tmp.im, min(Inf(a.im), Inf(b.im)));
00296    SetSup(tmp.re, max(Sup(a.re), Sup(b.re)));
00297    SetSup(tmp.im, max(Sup(a.im), Sup(b.im)));
00298    return tmp;
00299 }
00300 
00301 inline cinterval & operator +=(cinterval & a, const cinterval & b) throw() { return a=a+b; }
00302 inline cinterval & operator -=(cinterval & a, const cinterval & b) throw() { return a=a-b; }
00303 inline cinterval & operator *=(cinterval & a, const cinterval & b) throw() { return a=a*b; }
00304 inline cinterval & operator /=(cinterval & a, const cinterval & b) throw() { return a=a/b; }
00305 inline cinterval & operator |=(cinterval & a, const cinterval & b) throw() { return a=a|b; }
00306 inline cinterval & operator &=(cinterval & a, const cinterval & b) throw(ERROR_CINTERVAL_EMPTY_INTERVAL) { return a=a&b; }
00307 
00308 // CI-R
00309 
00310 inline cinterval operator +(const cinterval & a,const real & b) throw() { return a+_cinterval(b); }
00311 inline cinterval operator +(const real & a,const cinterval & b) throw() { return _cinterval(a)+b; }
00312 inline cinterval operator -(const cinterval & a,const real & b) throw() { return a-_cinterval(b); }
00313 inline cinterval operator -(const real & a,const cinterval & b) throw() { return _cinterval(a)-b; }
00314 inline cinterval operator *(const cinterval & a,const real & b) throw() { return a*_cinterval(b); }
00315 inline cinterval operator *(const real & a,const cinterval & b) throw()
00316 { // return _cinterval(a)*b;
00317      return cinterval(b.re*a, b.im*a); // Blomquist 07.11.02;
00318 }
00319 inline cinterval operator /(const cinterval & a,const real & b) throw()
00320 { // return a/_cinterval(b);
00321      return cinterval(a.re/b, a.im/b); // Blomquist 07.11.02;
00322 }
00323 inline cinterval operator /(const real & a,const cinterval & b) throw() { return _cinterval(a)/b; }
00324 inline cinterval operator |(const cinterval & a,const real & b) throw() { return a|_cinterval(b); }
00325 inline cinterval operator |(const real & a,const cinterval & b) throw() { return _cinterval(a)|b; }
00326 inline cinterval operator &(const cinterval & a,const real & b) throw() { return a&_cinterval(b); }
00327 inline cinterval operator &(const real & a,const cinterval & b) throw() { return _cinterval(a)&b; }
00328 
00329 inline cinterval & operator +=(cinterval & a, const real & b) throw() { return a=a+_cinterval(b); }
00330 inline cinterval & operator -=(cinterval & a, const real & b) throw() { return a=a-_cinterval(b); }
00331 inline cinterval & operator *=(cinterval & a, const real & b) throw()
00332 { // return a=a*_cinterval(b);
00333      return a = a * b;  // Blomquist 07.11.02;
00334 }
00335 inline cinterval & operator /=(cinterval & a, const real & b) throw()
00336 { // return a=a/_cinterval(b);
00337      return a = a / b;  // Blomquist 07.11.02;
00338 }
00339 inline cinterval & operator |=(cinterval & a, const real & b) throw() { return a=a|_cinterval(b); }
00340 inline cinterval & operator &=(cinterval & a, const real & b) throw() { return a=a&_cinterval(b); }
00341 
00342 // CI-C
00343 
00344 inline cinterval operator +(const cinterval & a,const complex & b) throw() { return a+_cinterval(b); }
00345 inline cinterval operator +(const complex & a,const cinterval & b) throw() { return _cinterval(a)+b; }
00346 inline cinterval operator -(const cinterval & a,const complex & b) throw() { return a-_cinterval(b); }
00347 inline cinterval operator -(const complex & a,const cinterval & b) throw() { return _cinterval(a)-b; }
00348 inline cinterval operator *(const cinterval & a,const complex & b) throw() { return a*_cinterval(b); }
00349 inline cinterval operator *(const complex & a,const cinterval & b) throw() { return _cinterval(a)*b; }
00350 inline cinterval operator /(const cinterval & a,const complex & b) throw() { return a/_cinterval(b); }
00351 inline cinterval operator /(const complex & a,const cinterval & b) throw() { return _cinterval(a)/b; }
00352 inline cinterval operator |(const cinterval & a,const complex & b) throw() { return a|_cinterval(b); }
00353 inline cinterval operator |(const complex & a,const cinterval & b) throw() { return _cinterval(a)|b; }
00354 inline cinterval operator &(const cinterval & a,const complex & b) throw() { return a&_cinterval(b); }
00355 inline cinterval operator &(const complex & a,const cinterval & b) throw() { return _cinterval(a)&b; }
00356 
00357 inline cinterval & operator +=(cinterval & a, const complex & b) throw() { return a=a+_cinterval(b); }
00358 inline cinterval & operator -=(cinterval & a, const complex & b) throw() { return a=a-_cinterval(b); }
00359 inline cinterval & operator *=(cinterval & a, const complex & b) throw() { return a=a*_cinterval(b); }
00360 inline cinterval & operator /=(cinterval & a, const complex & b) throw() { return a=a/_cinterval(b); }
00361 inline cinterval & operator |=(cinterval & a, const complex & b) throw() { return a=a|_cinterval(b); }
00362 inline cinterval & operator &=(cinterval & a, const complex & b) throw() { return a=a&_cinterval(b); }
00363 
00364 // CI-I
00365 
00366 inline cinterval operator +(const cinterval & a,const interval & b) throw() { return a+_cinterval(b); }
00367 inline cinterval operator +(const interval & a,const cinterval & b) throw() { return _cinterval(a)+b; }
00368 inline cinterval operator -(const cinterval & a,const interval & b) throw() { return a-_cinterval(b); }
00369 inline cinterval operator -(const interval & a,const cinterval & b) throw() { return _cinterval(a)-b; }
00370 inline cinterval operator *(const cinterval & a,const interval & b) throw()
00371 { // return a*_cinterval(b);
00372      return cinterval(a.re*b,a.im*b);  // Blomquist, 07.11.02;
00373 }
00374 inline cinterval operator *(const interval & a,const cinterval & b) throw()
00375 { // return _cinterval(a)*b;
00376      return cinterval(b.re*a,b.im*a);
00377 }
00378 inline cinterval operator /(const cinterval & a,const interval & b) throw()
00379 { // return a/_cinterval(b);
00380      return cinterval(a.re/b,a.im/b);
00381 }
00382 inline cinterval operator /(const interval & a,const cinterval & b) throw() { return _cinterval(a)/b; }
00383 inline cinterval operator |(const cinterval & a,const interval & b) throw() { return a|_cinterval(b); }
00384 inline cinterval operator |(const interval & a,const cinterval & b) throw() { return _cinterval(a)|b; }
00385 inline cinterval operator &(const cinterval & a,const interval & b) throw() { return a&_cinterval(b); }
00386 inline cinterval operator &(const interval & a,const cinterval & b) throw() { return _cinterval(a)&b; }
00387 
00388 inline cinterval & operator +=(cinterval & a, const interval & b) throw() { return a=a+_cinterval(b); }
00389 inline cinterval & operator -=(cinterval & a, const interval & b) throw() { return a=a-_cinterval(b); }
00390 inline cinterval & operator *=(cinterval & a, const interval & b) throw() { return a=a*_cinterval(b); }
00391 inline cinterval & operator /=(cinterval & a, const interval & b) throw() { return a=a/_cinterval(b); }
00392 inline cinterval & operator |=(cinterval & a, const interval & b) throw() { return a=a|_cinterval(b); }
00393 inline cinterval & operator &=(cinterval & a, const interval & b) throw() { return a=a&_cinterval(b); }
00394 
00395 // C-R
00396 
00397 inline cinterval operator |(const complex & a,const real & b) throw() { return _cinterval(a)|_cinterval(b); }
00398 inline cinterval operator |(const real & a,const complex & b) throw() { return _cinterval(a)|_cinterval(b); }
00399 
00400 // C-I
00401 
00402 inline cinterval operator +(const complex & a,const interval & b) throw() { return _cinterval(a)+_cinterval(b); }
00403 inline cinterval operator +(const interval & a,const complex & b) throw() { return _cinterval(a)+_cinterval(b); }
00404 inline cinterval operator -(const complex & a,const interval & b) throw() { return _cinterval(a)-_cinterval(b); }
00405 inline cinterval operator -(const interval & a,const complex & b) throw() { return _cinterval(a)-_cinterval(b); }
00406 inline cinterval operator *(const complex & a,const interval & b) throw()
00407 { // return _cinterval(a)*_cinterval(b);
00408      return _cinterval(a)*b;  // Blomquist, 07.11.02;
00409 }
00410 inline cinterval operator *(const interval & a,const complex & b) throw()
00411 { // return _cinterval(a)*_cinterval(b);
00412      return _cinterval(b) * a;  // Blomquist, 07.11.02;
00413 }
00414 inline cinterval operator /(const complex & a,const interval & b) throw()
00415 { // return _cinterval(a)/_cinterval(b);
00416      return _cinterval(a) / b;  // Blomquist, 07.11.02;
00417 }
00418 inline cinterval operator /(const interval & a,const complex & b) throw() { return _cinterval(a)/_cinterval(b); }
00419 inline cinterval operator |(const complex & a,const interval & b) throw() { return _cinterval(a)|_cinterval(b); }
00420 inline cinterval operator |(const interval & a,const complex & b) throw() { return _cinterval(a)|_cinterval(b); }
00421 inline cinterval operator &(const complex & a,const interval & b) throw() { return _cinterval(a)&_cinterval(b); }
00422 inline cinterval operator &(const interval & a,const complex & b) throw() { return _cinterval(a)&_cinterval(b); }
00423       
00424 // C-C
00425 
00426 inline cinterval operator |(const complex & a,const complex & b) throw() { return _cinterval(a)|_cinterval(b); }
00427 
00428 // ---- Comp.Operat.  ---------------------------------------
00429 inline bool operator!  (const cinterval & a)  throw()
00430 {
00431    return !a.re && !a.im;
00432 }
00433 
00434 inline bool operator== (const cinterval & a, const cinterval & b) throw()
00435 {
00436    return a.re==b.re && a.im==b.im;
00437 }
00438 
00439 inline bool operator!= (const cinterval & a, const cinterval & b) throw()
00440 {
00441    return a.re!=b.re || a.im!=b.im;
00442 }
00443 
00444 // CI-R
00445 
00446 inline bool operator== (const cinterval & a, const real & b) throw() { return a==_cinterval(b); }
00447 inline bool operator== (const real & a, const cinterval & b) throw() { return _cinterval(a)==b; }
00448 inline bool operator!= (const cinterval & a, const real & b) throw() { return a!=_cinterval(b); }
00449 inline bool operator!= (const real & a, const cinterval & b) throw() { return _cinterval(a)!=b; }
00450 
00451 // CI-C
00452 
00453 inline bool operator== (const cinterval & a, const complex & b) throw() { return a==_cinterval(b); }
00454 inline bool operator== (const complex & a, const cinterval & b) throw() { return _cinterval(a)==b; }
00455 inline bool operator!= (const cinterval & a, const complex & b) throw() { return a!=_cinterval(b); }
00456 inline bool operator!= (const complex & a, const cinterval & b) throw() { return _cinterval(a)!=b; }
00457 
00458 // CI-I
00459 
00460 inline bool operator== (const cinterval & a, const interval & b) throw() { return a==_cinterval(b); }
00461 inline bool operator== (const interval & a, const cinterval & b) throw() { return _cinterval(a)==b; }
00462 inline bool operator!= (const cinterval & a, const interval & b) throw() { return a!=_cinterval(b); }
00463 inline bool operator!= (const interval & a, const cinterval & b) throw() { return _cinterval(a)!=b; }
00464 
00465 // ---- Set Operators ----
00466 inline bool operator  <(const cinterval & a,const cinterval & b) throw()
00467 {
00468    if (Inf(a.re) <= Inf(b.re) || Sup(a.re) >= Sup(b.re)) 
00469       return false;
00470    if (Inf(a.im) <= Inf(b.im) || Sup(a.im) >= Sup(b.im)) 
00471       return false;
00472       
00473    return true; 
00474 }
00475 
00476 inline bool operator  >(const cinterval & a,const cinterval & b) throw() { return b<a; }
00477 
00478 inline bool operator <=(const cinterval & a,const cinterval & b) throw()
00479 {
00480    if (Inf(a.re) < Inf(b.re) || Sup(a.re) > Sup(b.re)) 
00481       return false;
00482    if (Inf(a.im) < Inf(b.im) || Sup(a.im) > Sup(b.im)) 
00483       return false;
00484       
00485    return true; 
00486 }
00487 
00488 inline bool operator >=(const cinterval & a,const cinterval & b) throw() { return b<=a; }
00489 
00490 // CI-R
00491 
00492 inline bool operator  <(const real & a,const cinterval & b) throw() { return _cinterval(a)<b; }
00493 inline bool operator  >(const real & a,const cinterval & b) throw() { return _cinterval(a)>b; }
00494 inline bool operator <=(const real & a,const cinterval & b) throw() { return _cinterval(a)<=b; }
00495 inline bool operator >=(const real & a,const cinterval & b) throw() { return _cinterval(a)>=b; }
00496 
00497 inline bool operator  <(const cinterval & a,const real & b) throw() { return a<_cinterval(b); }
00498 inline bool operator  >(const cinterval & a,const real & b) throw() { return a>_cinterval(b); }
00499 inline bool operator <=(const cinterval & a,const real & b) throw() { return a<=_cinterval(b); }
00500 inline bool operator >=(const cinterval & a,const real & b) throw() { return a>=_cinterval(b); }
00501 
00502 // CI-C
00503 
00504 inline bool operator  <(const complex & a,const cinterval & b) throw() { return _cinterval(a)<b; }
00505 inline bool operator  >(const complex & a,const cinterval & b) throw() { return _cinterval(a)>b; }
00506 inline bool operator <=(const complex & a,const cinterval & b) throw() { return _cinterval(a)<=b; }
00507 inline bool operator >=(const complex & a,const cinterval & b) throw() { return _cinterval(a)>=b; }
00508 
00509 inline bool operator  <(const cinterval & a,const complex & b) throw() { return a<_cinterval(b); }
00510 inline bool operator  >(const cinterval & a,const complex & b) throw() { return a>_cinterval(b); }
00511 inline bool operator <=(const cinterval & a,const complex & b) throw() { return a<=_cinterval(b); }
00512 inline bool operator >=(const cinterval & a,const complex & b) throw() { return a>=_cinterval(b); }
00513 
00514 // CI-C
00515 
00516 inline bool operator  <(const interval & a,const cinterval & b) throw() { return _cinterval(a)<b; }
00517 inline bool operator  >(const interval & a,const cinterval & b) throw() { return _cinterval(a)>b; }
00518 inline bool operator <=(const interval & a,const cinterval & b) throw() { return _cinterval(a)<=b; }
00519 inline bool operator >=(const interval & a,const cinterval & b) throw() { return _cinterval(a)>=b; }
00520 
00521 inline bool operator  <(const cinterval & a,const interval & b) throw() { return a<_cinterval(b); }
00522 inline bool operator  >(const cinterval & a,const interval & b) throw() { return a>_cinterval(b); }
00523 inline bool operator <=(const cinterval & a,const interval & b) throw() { return a<=_cinterval(b); }
00524 inline bool operator >=(const cinterval & a,const interval & b) throw() { return a>=_cinterval(b); }
00525 
00526 // ---- Others   -------------------------------------------
00527 inline complex    Inf(const cinterval & a) throw() { return _complex(Inf(a.re),Inf(a.im)); }
00528 inline complex    Sup(const cinterval & a) throw() { return _complex(Sup(a.re),Sup(a.im)); }
00529 
00530 inline cinterval & SetInf(cinterval & a,const complex & b) throw(ERROR_CINTERVAL_EMPTY_INTERVAL)
00531 {
00532    Inf(a.re)=Re(b);
00533    Inf(a.im)=Im(b);
00534 
00535    if (Inf(a.re) > Sup(a.re) || Inf(a.im) > Sup(a.im)) 
00536       cxscthrow(ERROR_CINTERVAL_EMPTY_INTERVAL("inline cinterval & SetInf(cinterval & a,const complex & b)"));
00537    
00538    return a;
00539 }
00540 
00541 inline cinterval & SetSup(cinterval & a,const complex & b) throw(ERROR_CINTERVAL_EMPTY_INTERVAL)
00542 {
00543    Sup(a.re)=Re(b);
00544    Sup(a.im)=Im(b);
00545 
00546    if (Inf(a.re) > Sup(a.re) || Inf(a.im) > Sup(a.im)) 
00547       cxscthrow(ERROR_CINTERVAL_EMPTY_INTERVAL("inline cinterval & SetSup(cinterval & a,const complex & b)"));
00548    
00549    return a;
00550 }
00551 
00552 inline cinterval & SetInf(cinterval & a,const real & b) throw(ERROR_CINTERVAL_EMPTY_INTERVAL)
00553 {
00554    Inf(a.re)=b;
00555    Inf(a.im)=0.0;
00556 
00557    if (Inf(a.re) > Sup(a.re) || Inf(a.im) > Sup(a.im)) 
00558       cxscthrow(ERROR_CINTERVAL_EMPTY_INTERVAL("inline cinterval & SetInf(cinterval & a,const real & b)"));
00559    
00560    return a;
00561 }
00562 
00563 inline cinterval & SetSup(cinterval & a,const real & b) throw(ERROR_CINTERVAL_EMPTY_INTERVAL)
00564 {
00565    Sup(a.re)=b;
00566    Sup(a.im)=0.0;
00567 
00568    if (Inf(a.re) > Sup(a.re) || Inf(a.im) > Sup(a.im)) 
00569       cxscthrow(ERROR_CINTERVAL_EMPTY_INTERVAL("inline cinterval & SetSup(cinterval & a,const real & b)"));
00570    
00571    return a;
00572 }
00573 
00574 inline cinterval & UncheckedSetInf(cinterval & a,const complex & b) throw()
00575 {
00576    Inf(a.re)=Re(b);
00577    Inf(a.im)=Im(b);
00578    return a;
00579 }
00580 
00581 inline cinterval & UncheckedSetInf(cinterval & a,const real & b) throw()
00582 {
00583    Inf(a.re)=b;
00584    Inf(a.im)=0.0;
00585    return a;
00586 }
00587 
00588 inline cinterval & UncheckedSetSup(cinterval & a,const complex & b) throw()
00589 {
00590    Sup(a.re)=Re(b);
00591    Sup(a.im)=Im(b);
00592    return a;
00593 }
00594 
00595 inline cinterval & UncheckedSetSup(cinterval & a,const real & b) throw()
00596 {
00597    Sup(a.re)=b;
00598    Sup(a.im)=0.0;
00599    return a;
00600 }
00601 
00602 inline interval & Re(cinterval & a)       throw() { return a.re; }
00603 inline interval   Re(const cinterval & a) throw() { return a.re; }
00604 inline interval & Im(cinterval & a)       throw() { return a.im; }
00605 inline interval   Im(const cinterval & a) throw() { return a.im; }
00606       
00607 inline cinterval & SetRe(cinterval & a,const interval & b) { a.re=b; return a; }
00608 inline cinterval & SetIm(cinterval & a,const interval & b) { a.im=b; return a; } 
00609 inline cinterval & SetRe(cinterval & a,const real     & b) { a.re=b; return a; }
00610 inline cinterval & SetIm(cinterval & a,const real     & b) { a.im=b; return a; } 
00611 
00612 inline real InfRe(const cinterval &a) throw() { return Inf(a.re); }
00613 inline real InfIm(const cinterval &a) throw() { return Inf(a.im); }
00614 inline real SupRe(const cinterval &a) throw() { return Sup(a.re); }
00615 inline real SupIm(const cinterval &a) throw() { return Sup(a.im); }
00616       
00617 inline real & InfRe(cinterval &a) throw() { return Inf(a.re); }
00618 inline real & InfIm(cinterval &a) throw() { return Inf(a.im); }
00619 inline real & SupRe(cinterval &a) throw() { return Sup(a.re); }
00620 inline real & SupIm(cinterval &a) throw() { return Sup(a.im); }
00621 
00622 
00623 
00624 
00625 
00626 
00627 
00628 
00629 
00630 
00631 inline cinterval conj(const cinterval & a) throw() { return cinterval(a.re,-a.im); }
00632 
00633 inline complex mid(const cinterval &a) throw() { return complex(mid(a.re),mid(a.im)); }
00634 inline complex diam(const cinterval &a) throw(){ return complex(diam(a.re),diam(a.im)); }
00635 
00636 cinterval mult_operator(const cinterval & a,const cinterval & b) throw();
00637 cinterval div_operator(const cinterval & a,const cinterval & b) throw(DIV_BY_ZERO);
00638 
00639 inline cinterval operator *(const cinterval & a,const cinterval & b) throw()
00640 {
00641 #ifdef CXSC_FAST_COMPLEX_OPERATIONS
00642   return cinterval(Re(a)*Re(b)-Im(a)*Im(b), Re(a)*Im(b)+Im(a)*Re(b));
00643 #else
00644   return mult_operator(a,b);
00645 #endif
00646 } 
00647 
00648 inline cinterval operator / (const cinterval & a, const cinterval & b) throw(DIV_BY_ZERO)
00649 {
00650     if (0.0 <= Re(b) && 0.0 <= Im(b) ) {
00651       cxscthrow(DIV_BY_ZERO("cinterval operator / (const cinterval&, const cinterval&)"));
00652       return a; // dummy result
00653     }      
00654 #ifdef CXSC_FAST_COMPLEX_OPERATIONS
00655     return a * (1.0 / b);
00656 #else
00657     return div_operator(a,b);
00658 #endif
00659 }
00660 
00661 
00662 } // namespace cxsc
00663