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 #include "idot.hpp"
00027 #include "ioflags.hpp"
00028
00029 namespace cxsc {
00030
00031
00032
00033
00034 std::ostream & operator << (std::ostream &s, const idotprecision& a) throw()
00035 {
00036 s << '[' << SaveOpt << RndDown
00037 << a.inf << ',' << RndUp
00038 << a.sup << RestoreOpt
00039 << ']';
00040 return s;
00041 }
00042 std::string & operator << (std::string &s, const idotprecision& a) throw()
00043 {
00044 s += '[';
00045 s << SaveOpt << RndDown
00046 << a.inf;
00047 s += ',';
00048 s << RndUp
00049 << a.sup << RestoreOpt;
00050 s += ']';
00051 return s;
00052 }
00053
00054 std::istream & operator >> (std::istream &s, idotprecision &a) throw()
00055 {
00056 char c;
00057
00058 skipeolnflag = inpdotflag = true;
00059 c = skipwhitespacessinglechar (s, '[');
00060 if (inpdotflag)
00061 s.putback(c);
00062
00063 s >> SaveOpt >> RndDown >> a.inf;
00064
00065 skipeolnflag = inpdotflag = true;
00066 c = skipwhitespacessinglechar (s, ',');
00067 if (inpdotflag) s.putback(c);
00068
00069 s >> RndUp >> a.sup >> RestoreOpt;
00070
00071 if (!waseolnflag)
00072 {
00073 skipeolnflag = false, inpdotflag = true;
00074 c = skipwhitespaces (s);
00075 if (inpdotflag && c != ']')
00076 s.putback(c);
00077 }
00078
00079
00080
00081
00082 return s;
00083 }
00084
00085
00086
00087 std::string & operator >> (std::string &s, idotprecision &a) throw()
00088 {
00089 s = skipwhitespacessinglechar (s, '[');
00090 s >> SaveOpt >> RndDown >> a.inf;
00091 s = skipwhitespacessinglechar (s, ',');
00092 s >> RndUp >> a.sup >> RestoreOpt;
00093 s = skipwhitespaces (s);
00094
00095 if (s[0] == ']')
00096 s.erase(0,1);
00097
00098
00099
00100
00101 return s;
00102 }
00103
00104 void operator >>(const std::string &s,idotprecision &a) throw()
00105 {
00106 std::string r(s);
00107 r>>a;
00108 }
00109
00110 void operator >>(const char *s,idotprecision &a) throw()
00111 {
00112 std::string r(s);
00113 r>>a;
00114 }
00115
00116 void rnd(const idotprecision &a,interval &b) throw()
00117 {
00118 Inf(b)=rnd(a.inf,RND_DOWN);
00119 Sup(b)=rnd(a.sup,RND_UP);
00120 }
00121
00122 interval rnd(const idotprecision &a) throw()
00123 {
00124 interval b;
00125 rnd(a,b);
00126 return b;
00127 }
00128
00129 void accumulate(idotprecision & a, const interval & b, const interval & c) throw()
00130 {
00131 i_padd(a.inf.ptr(),a.sup.ptr(), *(a_intv*)&b,*(a_intv*)&c);
00132 }
00133
00134 }
00135