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 inline void l_interval::_allo(int nprec)
00029 #if (CXSC_INDEX_CHECK)
00030 throw(ERROR_LINTERVAL_WRONG_STAGPREC)
00031 #else
00032 throw()
00033 #endif
00034 {
00035 prec=nprec;
00036 #if (CXSC_INDEX_CHECK)
00037 if(nprec<=0)
00038 cxscthrow(ERROR_LINTERVAL_WRONG_STAGPREC("void l_interval::_allo(int nprec)"));
00039 #endif
00040 data=new real[(prec)+1];
00041 }
00042
00043
00044
00045 inline l_interval::l_interval()
00046 #if (CXSC_INDEX_CHECK)
00047 throw(ERROR_LINTERVAL_WRONG_STAGPREC)
00048 #else
00049 throw()
00050 #endif
00051 {
00052 _allo(stagprec);
00053 }
00054
00055 inline l_interval::l_interval(const l_interval & a)
00056 #if (CXSC_INDEX_CHECK)
00057 throw(ERROR_LINTERVAL_WRONG_STAGPREC)
00058 #else
00059 throw()
00060 #endif
00061 {
00062 int i;
00063 _allo(a.prec);
00064 for(i=0;i<=prec;i++)
00065 data[i]=a.data[i];
00066 }
00067
00068 inline l_interval::l_interval(const real &a, const real &b)
00069 #if (CXSC_INDEX_CHECK)
00070 throw(ERROR_LINTERVAL_WRONG_STAGPREC,ERROR_LINTERVAL_EMPTY_INTERVAL)
00071 #else
00072 throw(ERROR_LINTERVAL_EMPTY_INTERVAL)
00073 #endif
00074 {
00075 _allo(1);
00076 if(a>b)
00077 cxscthrow(ERROR_LINTERVAL_EMPTY_INTERVAL("inline l_interval::l_interval(const real &a, const real &b)"));
00078 elem(1)=a,elem(2)=b;
00079
00080 }
00081
00082 l_interval::l_interval(const real &a) throw()
00083 {
00084 try { _allo(1); }
00085 catch(const ERROR_LINTERVAL_WRONG_STAGPREC &) {}
00086 elem(1)=a,elem(2)=a;
00087 }
00088
00089 inline l_interval & l_interval::operator= (const real & a) throw()
00090 {
00091 return (*this)=_l_interval(a);
00092 }
00093
00094 inline l_interval & l_interval::operator= (const l_real & a) throw()
00095 {
00096 return (*this)=_l_interval(a);
00097 }
00098
00099 inline l_interval & l_interval::operator= (const interval & a) throw()
00100 {
00101 return (*this)=_l_interval(a);
00102 }
00103
00104 inline l_interval::~l_interval() throw()
00105 {
00106 delete [] data;
00107 }
00108
00109
00110 l_interval::l_interval(const interval & a) throw()
00111 {
00112 try { _allo(1); }
00113 catch(const ERROR_LINTERVAL_WRONG_STAGPREC &) {}
00114 elem(1)=Inf(a),elem(2)=Sup(a);
00115 }
00116
00117 l_interval::l_interval(const l_real & a) throw()
00118 {
00119 try { _allo(StagPrec(a)); }
00120 catch(const ERROR_LINTERVAL_WRONG_STAGPREC &) {}
00121 int i;
00122 for(i=1;i<=prec;i++)
00123 elem(i)=a[i];
00124 elem(prec+1)=a[prec];
00125 }
00126
00127 inline interval _interval(const real & a, const l_real & b) throw()
00128 {
00129 return _interval(_l_interval(_l_real(a),b));
00130 }
00131
00132 inline interval _interval(const l_real & a, const real & b) throw()
00133 {
00134 return _interval(_l_interval(a,_l_real(b)));
00135 }
00136
00137 inline interval _interval(const l_real & a) throw()
00138 {
00139 return _interval(_l_interval(a,a));
00140 }
00141
00142 inline interval _unchecked_interval(const l_real & a, const l_real & b) throw()
00143 {
00144 return _unchecked_interval(_real(a),_real(b));
00145 }
00146
00147
00148
00149 inline l_interval operator+(const l_interval &a) throw() { return a; }
00150
00151
00152 inline l_interval operator|(const l_interval & li1, const l_interval & li2) throw(ERROR_LINTERVAL_IN_EXACT_CH_OR_IS)
00153 {
00154
00155 l_interval li3, li4;
00156
00157 ConvexHull(li1, li2, li3, li4);
00158
00159 if (li3!=li4)
00160 {
00161 cxscthrow(ERROR_LINTERVAL_IN_EXACT_CH_OR_IS("inline l_interval operator|(const l_interval & li1, const l_interval & li2)"));
00162 }
00163 return li4;
00164 }
00165
00166 inline l_interval operator&(const l_interval & li1, const l_interval & li2) throw(ERROR_LINTERVAL_EMPTY_INTERVAL, ERROR_LINTERVAL_IN_EXACT_CH_OR_IS)
00167 {
00168
00169 l_interval li3, li4;
00170
00171 try
00172 {
00173 Intersection(li1, li2, li3, li4);
00174 }
00175 catch(const EMPTY_INTERVAL &)
00176 {
00177 cxscthrow(ERROR_LINTERVAL_EMPTY_INTERVAL("inline l_interval operator&(const l_interval & li1, const l_interval & li2)"));
00178 }
00179
00180 if (li3!=li4)
00181 {
00182 cxscthrow(ERROR_LINTERVAL_IN_EXACT_CH_OR_IS("inline l_interval operator&(const l_interval & li1, const l_interval & li2)"));
00183 }
00184 return li4;
00185 }
00186
00187 inline l_interval & operator +=(l_interval &a,const l_interval &b) throw() { return a=a+b; }
00188 inline l_interval & operator -=(l_interval &a,const l_interval &b) throw() { return a=a-b; }
00189 inline l_interval & operator *=(l_interval &a,const l_interval &b) throw() { return a=a*b; }
00190 inline l_interval & operator /=(l_interval &a,const l_interval &b) throw() { return a=a/b; }
00191 inline l_interval & operator |=(l_interval &a,const l_interval &b) throw() { return a=a|b; }
00192 inline l_interval & operator &=(l_interval &a,const l_interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a=a&b; }
00193
00194
00195 inline l_interval operator +(const l_interval &a,const l_real &b) throw() { return a+_l_interval(b); }
00196 inline l_interval operator +(const l_real &a,const l_interval &b) throw() { return _l_interval(a)+b; }
00197 inline l_interval operator -(const l_interval &a,const l_real &b) throw() { return a-_l_interval(b); }
00198 inline l_interval operator -(const l_real &a,const l_interval &b) throw() { return _l_interval(a)-b; }
00199 inline l_interval operator *(const l_interval &a,const l_real &b) throw() { return a*_l_interval(b); }
00200 inline l_interval operator *(const l_real &a,const l_interval &b) throw() { return _l_interval(a)*b; }
00201 inline l_interval operator /(const l_interval &a,const l_real &b) throw() { return a/_l_interval(b); }
00202 inline l_interval operator /(const l_real &a,const l_interval &b) throw() { return _l_interval(a)/b; }
00203 inline l_interval operator |(const l_real &a,const l_interval &b) throw() { return _l_interval(a)|b; }
00204 inline l_interval operator |(const l_interval &a,const l_real &b) throw() { return a|_l_interval(b); }
00205 inline l_interval operator |(const l_real &a,const l_real &b) throw() { return _l_interval(a)|_l_interval(b); }
00206 inline l_interval operator &(const l_real &a,const l_interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return _l_interval(a)&b; }
00207 inline l_interval operator &(const l_interval &a,const l_real &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a&_l_interval(b); }
00208
00209 inline l_interval & operator +=(l_interval &a,const l_real &b) throw() { return a=a+_l_interval(b); }
00210 inline l_interval & operator -=(l_interval &a,const l_real &b) throw() { return a=a-_l_interval(b); }
00211 inline l_interval & operator *=(l_interval &a,const l_real &b) throw() { return a=a*_l_interval(b); }
00212 inline l_interval & operator /=(l_interval &a,const l_real &b) throw() { return a=a/_l_interval(b); }
00213 inline l_interval & operator |=(l_interval &a,const l_real &b) throw() { return a=a|_l_interval(b); }
00214 inline l_interval & operator &=(l_interval &a,const l_real &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a=a&_l_interval(b); }
00215
00216
00217 inline l_interval operator +(const l_interval &a,const interval &b) throw() { return a+_l_interval(b); }
00218 inline l_interval operator +(const interval &a,const l_interval &b) throw() { return _l_interval(a)+b; }
00219 inline l_interval operator -(const l_interval &a,const interval &b) throw() { return a-_l_interval(b); }
00220 inline l_interval operator -(const interval &a,const l_interval &b) throw() { return _l_interval(a)-b; }
00221 inline l_interval operator *(const l_interval &a,const interval &b) throw() { return a*_l_interval(b); }
00222 inline l_interval operator *(const interval &a,const l_interval &b) throw() { return _l_interval(a)*b; }
00223 inline l_interval operator /(const l_interval &a,const interval &b) throw() { return a/_l_interval(b); }
00224 inline l_interval operator /(const interval &a,const l_interval &b) throw() { return _l_interval(a)/b; }
00225 inline l_interval operator |(const interval &a,const l_interval &b) throw() { return _l_interval(a)|b; }
00226 inline l_interval operator |(const l_interval &a,const interval &b) throw() { return a|_l_interval(b); }
00227 inline l_interval operator &(const interval &a,const l_interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return _l_interval(a)&b; }
00228 inline l_interval operator &(const l_interval &a,const interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a&_l_interval(b); }
00229
00230 inline l_interval & operator +=(l_interval &a,const interval &b) throw() { return a=a+_l_interval(b); }
00231 inline l_interval & operator -=(l_interval &a,const interval &b) throw() { return a=a-_l_interval(b); }
00232 inline l_interval & operator *=(l_interval &a,const interval &b) throw() { return a=a*_l_interval(b); }
00233 inline l_interval & operator /=(l_interval &a,const interval &b) throw() { return a=a/_l_interval(b); }
00234 inline l_interval & operator |=(l_interval &a,const interval &b) throw() { return a=a|_l_interval(b); }
00235 inline l_interval & operator &=(l_interval &a,const interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a=a&_l_interval(b); }
00236
00237
00238 inline l_interval operator +(const l_interval &a,const real &b) throw() { return a+_l_interval(b); }
00239 inline l_interval operator +(const real &a,const l_interval &b) throw() { return _l_interval(a)+b; }
00240 inline l_interval operator -(const l_interval &a,const real &b) throw() { return a-_l_interval(b); }
00241 inline l_interval operator -(const real &a,const l_interval &b) throw() { return _l_interval(a)-b; }
00242 inline l_interval operator *(const l_interval &a,const real &b) throw() { return a*_l_interval(b); }
00243 inline l_interval operator *(const real &a,const l_interval &b) throw() { return _l_interval(a)*b; }
00244 inline l_interval operator /(const l_interval &a,const real &b) throw() { return a/_l_interval(b); }
00245 inline l_interval operator /(const real &a,const l_interval &b) throw() { return _l_interval(a)/b; }
00246 inline l_interval operator |(const real &a,const l_interval &b) throw() { return _l_interval(a)|b; }
00247 inline l_interval operator |(const l_interval &a,const real &b) throw() { return a|_l_interval(b); }
00248 inline l_interval operator &(const real &a,const l_interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return _l_interval(a)&b; }
00249 inline l_interval operator &(const l_interval &a,const real &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a&_l_interval(b); }
00250
00251 inline l_interval & operator +=(l_interval &a,const real &b) throw() { return a=a+_l_interval(b); }
00252 inline l_interval & operator -=(l_interval &a,const real &b) throw() { return a=a-_l_interval(b); }
00253 inline l_interval & operator *=(l_interval &a,const real &b) throw() { return a=a*_l_interval(b); }
00254 inline l_interval & operator /=(l_interval &a,const real &b) throw() { return a=a/_l_interval(b); }
00255 inline l_interval & operator |=(l_interval &a,const real &b) throw() { return a=a|_l_interval(b); }
00256 inline l_interval & operator &=(l_interval &a,const real &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a=a&_l_interval(b); }
00257
00258
00259 inline idotprecision operator +(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)+b; }
00260 inline idotprecision operator +(const idotprecision &a,const l_interval &b) throw() { return a+_idotprecision(b); }
00261 inline idotprecision operator -(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)-b; }
00262 inline idotprecision operator -(const idotprecision &a,const l_interval &b) throw() { return a-_idotprecision(b); }
00263 inline idotprecision operator |(const idotprecision &a,const l_interval &b) throw() { return a|_idotprecision(b); }
00264 inline idotprecision operator |(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)|b; }
00265 inline idotprecision operator &(const idotprecision &a,const l_interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a&_idotprecision(b); }
00266 inline idotprecision operator &(const l_interval &a,const idotprecision &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return _idotprecision(a)&b; }
00267
00268 inline idotprecision & operator +=(idotprecision &a,const l_interval &b) throw() { return a+=_idotprecision(b); }
00269 inline idotprecision & operator -=(idotprecision &a,const l_interval &b) throw() { return a-=_idotprecision(b); }
00270 inline idotprecision & operator |=(idotprecision &a,const l_interval &b) throw() { return a|=_idotprecision(b); }
00271 inline idotprecision & operator &=(idotprecision &a,const l_interval &b) throw(ERROR_IDOTPRECISION_EMPTY_INTERVAL) { return a&=idotprecision(b); }
00272
00273
00274 inline l_interval operator |(const real &a,const l_real &b) throw() { return l_real(a)|b; }
00275 inline l_interval operator |(const l_real &a,const real &b) throw() { return a|l_real(b); }
00276
00277
00278 inline idotprecision operator |(const dotprecision &a,const l_real &b) throw() { return a|dotprecision(b); }
00279 inline idotprecision operator |(const l_real &a,const dotprecision &b) throw() { return dotprecision(a)|b; }
00280
00281
00282 inline l_interval operator +(const l_real &a,const interval &b) throw() { return a+_l_interval(b); }
00283 inline l_interval operator +(const interval &a,const l_real &b) throw() { return _l_interval(a)+b; }
00284 inline l_interval operator -(const l_real &a,const interval &b) throw() { return a-_l_interval(b); }
00285 inline l_interval operator -(const interval &a,const l_real &b) throw() { return _l_interval(a)-b; }
00286 inline l_interval operator *(const l_real &a,const interval &b) throw() { return a*_l_interval(b); }
00287 inline l_interval operator *(const interval &a,const l_real &b) throw() { return _l_interval(a)*b; }
00288 inline l_interval operator /(const l_real &a,const interval &b) throw() { return a/_l_interval(b); }
00289 inline l_interval operator /(const interval &a,const l_real &b) throw() { return _l_interval(a)/b; }
00290 inline l_interval operator |(const interval &a,const l_real &b) throw() { return _l_interval(a)|b; }
00291 inline l_interval operator |(const l_real &a,const interval &b) throw() { return a|_l_interval(b); }
00292 inline l_interval operator &(const interval &a,const l_real &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return _l_interval(a)&b; }
00293 inline l_interval operator &(const l_real &a,const interval &b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a&_l_interval(b); }
00294
00295
00296 inline bool operator !=(const l_interval &a,const l_interval &b) throw() { return !(a==b); }
00297
00298 inline bool operator ==(const l_real &a,const l_interval &b) throw() { return _l_interval(a)==b; }
00299 inline bool operator !=(const l_real &a,const l_interval &b) throw() { return _l_interval(a)!=b; }
00300 inline bool operator ==(const l_interval &a,const l_real &b) throw() { return a==_l_interval(b); }
00301 inline bool operator !=(const l_interval &a,const l_real &b) throw() { return a!=_l_interval(b); }
00302
00303 inline bool operator ==(const interval &a,const l_interval &b) throw() { return _l_interval(a)==b; }
00304 inline bool operator !=(const interval &a,const l_interval &b) throw() { return _l_interval(a)!=b; }
00305 inline bool operator ==(const l_interval &a,const interval &b) throw() { return a==_l_interval(b); }
00306 inline bool operator !=(const l_interval &a,const interval &b) throw() { return a!=_l_interval(b); }
00307
00308 inline bool operator ==(const real &a,const l_interval &b) throw() { return _l_interval(a)==b; }
00309 inline bool operator !=(const real &a,const l_interval &b) throw() { return _l_interval(a)!=b; }
00310 inline bool operator ==(const l_interval &a,const real &b) throw() { return a==_l_interval(b); }
00311 inline bool operator !=(const l_interval &a,const real &b) throw() { return a!=_l_interval(b); }
00312
00313 inline bool operator ==(const idotprecision &a,const l_interval &b) throw() { return a==_idotprecision(b); }
00314 inline bool operator !=(const idotprecision &a,const l_interval &b) throw() { return a!=_idotprecision(b); }
00315 inline bool operator ==(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)==b; }
00316 inline bool operator !=(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)!=b; }
00317
00318 inline bool operator ==(const dotprecision &a,const l_interval &b) throw() { return a==_idotprecision(b); }
00319 inline bool operator !=(const dotprecision &a,const l_interval &b) throw() { return a!=_idotprecision(b); }
00320 inline bool operator ==(const l_interval &a,const dotprecision &b) throw() { return _idotprecision(a)==b; }
00321 inline bool operator !=(const l_interval &a,const dotprecision &b) throw() { return _idotprecision(a)!=b; }
00322
00323
00324 inline bool operator <(const l_real &a,const l_interval &b) throw() { return _l_interval(a)<b; }
00325 inline bool operator >(const l_real &a,const l_interval &b) throw() { return _l_interval(a)>b; }
00326 inline bool operator <=(const l_real &a,const l_interval &b) throw() { return _l_interval(a)<=b; }
00327 inline bool operator >=(const l_real &a,const l_interval &b) throw() { return _l_interval(a)>=b; }
00328 inline bool operator <(const l_interval &a,const l_real &b) throw() { return a<_l_interval(b); }
00329 inline bool operator >(const l_interval &a,const l_real &b) throw() { return a>_l_interval(b); }
00330 inline bool operator <=(const l_interval &a,const l_real &b) throw() { return a<=_l_interval(b); }
00331 inline bool operator >=(const l_interval &a,const l_real &b) throw() { return a>=_l_interval(b); }
00332
00333 inline bool operator <(const interval &a,const l_interval &b) throw() { return _l_interval(a)<b; }
00334 inline bool operator >(const interval &a,const l_interval &b) throw() { return _l_interval(a)>b; }
00335 inline bool operator <=(const interval &a,const l_interval &b) throw() { return _l_interval(a)<=b; }
00336 inline bool operator >=(const interval &a,const l_interval &b) throw() { return _l_interval(a)>=b; }
00337 inline bool operator <(const l_interval &a,const interval &b) throw() { return a<_l_interval(b); }
00338 inline bool operator >(const l_interval &a,const interval &b) throw() { return a>_l_interval(b); }
00339 inline bool operator <=(const l_interval &a,const interval &b) throw() { return a<=_l_interval(b); }
00340 inline bool operator >=(const l_interval &a,const interval &b) throw() { return a>=_l_interval(b); }
00341
00342 inline bool operator <(const real &a,const l_interval &b) throw() { return _l_interval(a)<b; }
00343 inline bool operator >(const real &a,const l_interval &b) throw() { return _l_interval(a)>b; }
00344 inline bool operator <=(const real &a,const l_interval &b) throw() { return _l_interval(a)<=b; }
00345 inline bool operator >=(const real &a,const l_interval &b) throw() { return _l_interval(a)>=b; }
00346 inline bool operator <(const l_interval &a,const real &b) throw() { return a<_l_interval(b); }
00347 inline bool operator >(const l_interval &a,const real &b) throw() { return a>_l_interval(b); }
00348 inline bool operator <=(const l_interval &a,const real &b) throw() { return a<=_l_interval(b); }
00349 inline bool operator >=(const l_interval &a,const real &b) throw() { return a>=_l_interval(b); }
00350
00351 inline bool operator <(const idotprecision &a,const l_interval &b) throw() { return a<_idotprecision(b); }
00352 inline bool operator >(const idotprecision &a,const l_interval &b) throw() { return a>_idotprecision(b); }
00353 inline bool operator <=(const idotprecision &a,const l_interval &b) throw() { return a<=_idotprecision(b); }
00354 inline bool operator >=(const idotprecision &a,const l_interval &b) throw() { return a>=_idotprecision(b); }
00355 inline bool operator <(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)<b; }
00356 inline bool operator >(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)>b; }
00357 inline bool operator <=(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)<=b; }
00358 inline bool operator >=(const l_interval &a,const idotprecision &b) throw() { return _idotprecision(a)>=b; }
00359
00360 inline bool operator <(const dotprecision &a,const l_interval &b) throw() { return a<_idotprecision(b); }
00361 inline bool operator >(const dotprecision &a,const l_interval &b) throw() { return a>_idotprecision(b); }
00362 inline bool operator <=(const dotprecision &a,const l_interval &b) throw() { return a<=_idotprecision(b); }
00363 inline bool operator >=(const dotprecision &a,const l_interval &b) throw() { return a>=_idotprecision(b); }
00364 inline bool operator <(const l_interval &a,const dotprecision &b) throw() { return _idotprecision(a)<b; }
00365 inline bool operator >(const l_interval &a,const dotprecision &b) throw() { return _idotprecision(a)>b; }
00366 inline bool operator <=(const l_interval &a,const dotprecision &b) throw() { return _idotprecision(a)<=b; }
00367 inline bool operator >=(const l_interval &a,const dotprecision &b) throw() { return _idotprecision(a)>=b; }
00368
00369
00370
00371 static const int LI_Min_Exp_ = -1074,
00372 LI_maxexpo1 = 1023;
00373
00374
00375
00376 inline l_real Inf (const l_interval &li) throw()
00377 {
00378
00379 int save_stagprec=stagprec;
00380 stagprec=li.prec;
00381 l_real lr;
00382
00383 for (int i=1; i<=stagprec; i++)
00384 lr.elem(i)=li.elem(i);
00385
00386 stagprec=save_stagprec;
00387
00388 return lr;
00389 }
00390 inline l_real Sup (const l_interval &li) throw()
00391 {
00392
00393 int save_stagprec=stagprec;
00394 stagprec=li.prec;
00395 l_real lr;
00396
00397 for (int i=1; i<stagprec; i++)
00398 lr.elem(i)=li.elem(i);
00399
00400 lr.elem(stagprec)=li.elem(stagprec+1);
00401
00402 stagprec=save_stagprec;
00403
00404 return lr;
00405 }
00406
00407 inline int StagPrec(const l_interval &a) throw() { return a.prec; }
00408
00409 inline l_interval & SetInf (l_interval & a, const l_real & b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a=_l_interval(b,Sup((const l_interval)a)); }
00410 inline l_interval & SetSup (l_interval & a, const l_real & b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return a=_l_interval(Inf((const l_interval)a),b); }
00411 inline l_interval & SetInf (l_interval & a, const real & b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return SetInf(a,_l_real(b)); }
00412 inline l_interval & SetSup (l_interval & a, const real & b) throw(ERROR_LINTERVAL_EMPTY_INTERVAL) { return SetSup(a,_l_real(b)); }
00413
00414 inline l_interval adjust(const l_interval & x) throw()
00415 {
00416 l_interval y;
00417
00418 if (x.prec == stagprec)
00419 y = x;
00420 else if (x.prec > stagprec)
00421 {
00422 y = x + 0.0;
00423 }
00424 else
00425 {
00426 int i;
00427 for (i = 0; i <= stagprec-x.prec-1; i++)
00428 y.data[i] = 0.0;
00429 for (i = stagprec-x.prec; i <= stagprec; i++)
00430 y.data[i] = x.data[i-(stagprec-x.prec)];
00431 }
00432 return y;
00433 }
00434
00435 inline l_interval & UncheckedSetInf (l_interval & a, const l_real & b) throw() { return a=_unchecked_l_interval(b,Sup(a)); }
00436 inline l_interval & UncheckedSetSup (l_interval & a, const l_real & b) throw() { return a=_unchecked_l_interval(Inf(a),b); }
00437 inline l_interval & UncheckedSetInf (l_interval & a, const real & b) throw() { return UncheckedSetInf(a,_l_real(b)); }
00438 inline l_interval & UncheckedSetSup (l_interval & a, const real & b) throw() { return UncheckedSetSup(a,_l_real(b)); }
00439
00440 inline l_interval abs (const l_interval & li1) throw()
00441 {
00442 l_interval li2;
00443 l_real i = Inf(li1), s = Sup(li1);
00444 l_real inf = abs(i), sup = abs(s);
00445
00446 if (i>s)
00447 li2 = li1;
00448 else if (!li1)
00449 li2 = l_interval(0.0, (inf > sup) ? inf : sup);
00450 else if (inf > sup)
00451 li2 = l_interval(sup, inf);
00452 else
00453 li2 = l_interval(inf, sup);
00454
00455 return li2;
00456 }
00457
00458 inline l_real diam (const l_interval & li) throw()
00459 {
00460 return _l_real(diam(_interval(li.elem(li.prec),li.elem(li.prec+1))));
00461 }
00462
00463 inline void accumulate(idotprecision & a, const real & b, const l_interval & c) throw() { accumulate(a,_l_interval(b),c); }
00464 inline void accumulate(idotprecision & a, const l_interval & b, const real & c) throw() { accumulate(a,b,_l_interval(c)); }
00465 inline void accumulate(idotprecision & a, const interval & b, const l_real & c) throw() { accumulate(a,_l_interval(b),_l_interval(c)); }
00466 inline void accumulate(idotprecision & a, const l_real & b, const interval & c) throw() { accumulate(a,_l_interval(b),_l_interval(c)); }
00467 inline void accumulate(idotprecision & a, const l_interval & b, const l_real & c) throw() { accumulate(a,b,_l_interval(c)); }
00468 inline void accumulate(idotprecision & a, const l_real & b, const l_interval & c) throw() { accumulate(a,_l_interval(b),c); }
00469 inline void accumulate(idotprecision & a, const l_interval & b, const interval & c) throw() { accumulate(a,b,_l_interval(c)); }
00470 inline void accumulate(idotprecision & a, const interval & b, const l_interval & c) throw() { accumulate(a,_l_interval(b),c); }
00471
00472
00473 inline real & l_interval::operator[](int a)
00474 #if (CXSC_INDEX_CHECK)
00475 throw(ERROR_LINTERVAL_ELEMENT_NOT_IN_LONG)
00476 #else
00477 throw()
00478 #endif
00479 {
00480 #if (CXSC_INDEX_CHECK)
00481 if(a<1 || a>prec+1)
00482 cxscthrow(ERROR_LINTERVAL_ELEMENT_NOT_IN_LONG("inline real & l_interval::operator[](int a)"));
00483 #endif
00484 return data[a-1];
00485 }
00486
00487 inline void l_interval::_clear(int p) throw()
00488 {
00489 int i;
00490
00491
00492 for (i=p; i<=prec+1; i++)
00493 this->elem(i)=0.0;
00494 }
00495
00496 inline bool point_intv(const l_interval &a )
00497 {
00498 int k(a.prec);
00499 return a.elem(k+1) == a.elem(k);
00500 }
00501
00502 inline bool zero_(const l_interval& li) throw()
00503 {
00504 int i=1, p=StagPrec(li)+1;
00505 bool tmp = true;
00506 do
00507 {
00508 if (sign(li.elem(i))!=0) tmp = false;
00509 i++;
00510 } while(tmp && i <= p );
00511 return tmp;
00512 }
00513
00514
00515
00522 inline int expo_gr(const l_interval& x)
00523
00524 {
00525 int k(1),p(x.prec),ex1,ex2;
00526 l_interval y(x);
00527 while (y.elem(k)==0 && k<p) k++;
00528 ex1 = expo(y.elem(k));
00529 ex2 = expo(y.elem(k+1));
00530 if (ex2>ex1) ex1 = ex2;
00531 return ex1;
00532 }
00539 inline int expo_sm(const l_interval& x)
00540
00541 {
00542 int k(x.prec+1),ex1,ex2;
00543 l_interval y(x);
00544
00545 while (y.elem(k)==0 && k>2) k--;
00546 ex1 = expo(y.elem(k));
00547 ex2 = expo(y.elem(k-1));
00548 if (ex2<ex1)
00549 {
00550 k = ex1; ex1 = ex2; ex2 = k;
00551 }
00552 if (ex1<-100000) ex1 = ex2;
00553 return ex1;
00554 }
00555
00556
00557 }
00558