26 #include "interval.hpp"
27 #include "ioflags.hpp"
61 cxscthrow(ERROR_INTERVAL_EMPTY_INTERVAL(
"interval::interval(const dotprecision &,const dotprecision &)"));
67 inf=rnd(dot,RND_DOWN);
69 sup = rnd(dot,RND_UP);
71 cxscthrow(ERROR_INTERVAL_EMPTY_INTERVAL(
"interval::interval(const l_real &,const l_real &)"));
109 return(a>=b.inf && a<=b.sup);
113 return(a<=b.inf && a>=b.sup);
117 return(a>b.inf && a<b.sup);
122 return(a.inf>=b && a.sup<=b);
126 return(a.inf<=b && a.sup>=b);
130 return(a.inf<b && a.sup>b);
137 std::ostream & operator << (std::ostream &s,
const interval& a)
throw()
139 s <<
'[' << SaveOpt << RndDown
140 << a.inf <<
',' << RndUp
141 << a.sup << RestoreOpt
145 std::string & operator << (std::string &s,
const interval &a)
throw()
148 s << SaveOpt << RndDown
152 << a.sup << RestoreOpt;
157 std::istream & operator >> (std::istream &s,
interval &a)
throw()
161 skipeolnflag = inpdotflag =
true;
162 c = skipwhitespacessinglechar (s,
'[');
166 s >> SaveOpt >> RndDown >> a.inf;
168 skipeolnflag = inpdotflag =
true;
169 c = skipwhitespacessinglechar (s,
',');
170 if (inpdotflag) s.putback(c);
172 s >> RndUp >> a.sup >> RestoreOpt;
176 skipeolnflag =
false, inpdotflag =
true;
177 c = skipwhitespaces (s);
178 if (inpdotflag && c !=
']')
188 std::string & operator >> (std::string &s,
interval &a)
throw()
190 s = skipwhitespacessinglechar (s,
'[');
191 s >> SaveOpt >> RndDown >> a.inf;
192 s = skipwhitespacessinglechar (s,
',');
193 s >> RndUp >> a.sup >> RestoreOpt;
194 s = skipwhitespaces (s);
205 void operator >>(
const std::string &s,
interval &a)
throw()
210 void operator >>(
const char *s,
interval &a)
throw()
224 Dotprecision ptr = *dot.ptr();
229 ptr[(a_intg)++ptr[A_END]] = ZERO;
231 b_shr1 (&ptr[(a_intg)ptr[A_BEGIN]], (a_intg)(ptr[A_END]-ptr[A_BEGIN]+1));
233 if (ptr[(a_intg)ptr[A_END]] == ZERO)
236 if (ptr[(a_intg)ptr[A_BEGIN]] == ZERO)
247 {
return ( (Inf(y) <= x) && (x <= Sup(y)) ); }
251 return ( (Inf(y) < Inf(x)) && (Sup(x) < Sup(y)) );
284 tmp = (1.0+eps)*x - eps*x;
285 return interval(pred(Inf(tmp)),succ(Sup(tmp)));
290 return (Inf(a) > Sup(b)) || (Inf(b) > Sup(a));
297 else if (Inf(x) > 0.0)
341 for (i = 1; i <= n; i++) Infimum = succ(Infimum);
342 return (Infimum >= Sup(x));
347 const real Pi_Inf = 7074237752028440.0 / 2251799813685248.0;
350 const real Pi2_Inf = 7074237752028440.0 / 1125899906842624.0;
353 const real Pi3_Inf = 5305678314021330.0 / 562949953421312.0;
356 const real Pid2_Inf = 7074237752028440.0 / 4503599627370496.0;
359 const real Pid3_Inf = 4716158501352293.0 / 4503599627370496.0;
362 const real Pid4_Inf = 7074237752028440.0 / 9007199254740992.0;
365 const real Pir_Inf = 5734161139222658.0 / 18014398509481984.0;
368 const real Pi2r_Inf = 5734161139222658.0 / 36028797018963968.0;
372 const real Pip2_Inf = 5556093337880030.0 / 562949953421312.0;
375 const real SqrtPi_Inf = 7982422502469482.0 / 4503599627370496.0;
379 const real Sqrt2Pi_Inf = 5644425081792261.0 / 2251799813685248.0;
383 const real SqrtPir_Inf = 5081767996463981.0 / 9007199254740992.0;
387 const real Sqrt2Pir_Inf = 7186705221432912.0 / 18014398509481984.0;
391 const real Sqrt2_Inf = 6369051672525772.0 / 4503599627370496.0;
395 const real Sqrt5_Inf = 5035177455121575.0 / 2251799813685248.0;
399 const real Sqrt7_Inf = 5957702309312745.0 / 2251799813685248.0;
403 const real Sqrt2r_Inf = 6369051672525772.0 / 9007199254740992.0;
407 const real Sqrt3_Inf = 7800463371553962.0 / 4503599627370496.0;
411 const real Sqrt3d2_Inf = 7800463371553962.0 / 9007199254740992.0;
415 const real Sqrt3r_Inf = 5200308914369308.0 / 9007199254740992.0;
419 const real Ln2_Inf = 6243314768165359.0 / 9007199254740992.0;
422 const real Ln2r_Inf = 6497320848556798.0 / 4503599627370496.0;
425 const real Ln10_Inf = 5184960683398421.0 / 2251799813685248.0;
428 const real Ln10r_Inf = 7823553867474190.0 / 18014398509481984.0;
432 const real LnPi_Inf = 5155405087351229.0 / 4503599627370496.0;
435 const real Ln2Pi_Inf = 8277062471433908.0 / 4503599627370496.0;
439 const real E_Inf = 6121026514868073.0 / 2251799813685248.0;
442 const real Er_Inf = 6627126856707895.0 / 18014398509481984.0;
445 const real Ep2_Inf = 8319337573440941.0 / 1125899906842624.0;
448 const real Ep2r_Inf = 4875967449235915.0 / 36028797018963968.0;
451 const real EpPi_Inf = 6513525919879993.0 / 281474976710656.0;
454 const real Ep2Pi_Inf = 4710234414611993.0 / 8796093022208.0;
458 const real EpPid2_Inf = 5416116035097439.0 / 1125899906842624.0;
462 const real EpPid4_Inf = 4938827609611434.0 / 2251799813685248.0;