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 "cdot.hpp"
00027 #include "ioflags.hpp"
00028
00029 namespace cxsc {
00030
00031
00032
00033
00034
00035 std::ostream & operator << (std::ostream &s, const cdotprecision& a) throw()
00036 {
00037 s << '('
00038 << a.re << ','
00039 << a.im
00040 << ')';
00041 return s;
00042 }
00043 std::string & operator << (std::string &s, const cdotprecision& a) throw()
00044 {
00045 s += '(';
00046 s << a.re;
00047 s += ',';
00048 s << a.im;
00049 s += ')';
00050 return s;
00051 }
00052
00053 std::istream & operator >> (std::istream &s, cdotprecision &a) throw()
00054 {
00055 char c;
00056
00057 skipeolnflag = inpdotflag = true;
00058 c = skipwhitespacessinglechar (s, '(');
00059 if (inpdotflag)
00060 s.putback(c);
00061
00062 s >> a.re;
00063
00064 skipeolnflag = inpdotflag = true;
00065 c = skipwhitespacessinglechar (s, ',');
00066 if (inpdotflag)
00067 s.putback(c);
00068
00069 s >> a.im;
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 return s;
00080 }
00081
00082
00083
00084 std::string & operator >> (std::string &s, cdotprecision &a) throw()
00085 {
00086 s = skipwhitespacessinglechar (s, '(');
00087 s >> a.re;
00088 s = skipwhitespacessinglechar (s, ',');
00089 s >> a.im;
00090 s = skipwhitespaces (s);
00091
00092 if (s[0] == ')')
00093 s.erase(0,1);
00094
00095 return s;
00096 }
00097
00098 void operator >>(const std::string &s,cdotprecision &a) throw()
00099 {
00100 std::string r(s);
00101 r>>a;
00102 }
00103
00104 void operator >>(const char *s,cdotprecision &a) throw()
00105 {
00106 std::string r(s);
00107 r>>a;
00108 }
00109
00110 void rnd(const cdotprecision &a,complex &b,rndtype r) throw()
00111 {
00112 Re(b)=rnd(a.re,r);
00113 Im(b)=rnd(a.im,r);
00114 }
00115
00116 void rnd(const cdotprecision &a,complex &b,complex &c) throw()
00117 {
00118 rnd(a,b,RND_DOWN);
00119 rnd(a,c,RND_UP);
00120 }
00121
00122 void rnd (const cdotprecision& d, cinterval& x) throw()
00123 {
00124 complex a,b;
00125 rnd(d,a,b);
00126 x = cinterval(a,b);
00127 }
00128
00129 complex rnd(const cdotprecision &a,rndtype r) throw()
00130 {
00131 complex b;
00132 rnd(a,b,r);
00133 return b;
00134 }
00135
00136 void accumulate(cdotprecision & a, const complex & b, const complex & c) throw()
00137 {
00138 c_padd(a.re.ptr(),a.im.ptr(), *(a_cmpx*)&b,*(a_cmpx*)&c);
00139 }
00140
00141 }
00142