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 #ifndef _CXSC_CDOT_HPP_INCLUDED
00027 #define _CXSC_CDOT_HPP_INCLUDED
00028
00029 #include <iostream>
00030 #include <string>
00031 #include "dot.hpp"
00032 #include "complex.hpp"
00033 #include "l_real.hpp"
00034 #include "l_complex.hpp"
00035 #include "cinterval.hpp"
00036
00037 namespace cxsc {
00038
00039 class l_complex;
00040
00041
00042
00043
00044
00045
00046
00048
00060 class cdotprecision
00061 {
00062 private:
00063
00064 dotprecision re,im;
00065 int k;
00066
00067 public:
00068
00070 cdotprecision() : k(0) {}
00072 inline cdotprecision(const dotprecision&, const dotprecision&);
00074 inline cdotprecision(const real &, const real &);
00076 inline cdotprecision(const cdotprecision&);
00078 inline cdotprecision(const l_real &, const l_real &);
00080 inline cdotprecision(const l_complex &);
00082 explicit inline cdotprecision(const real &r);
00084 explicit inline cdotprecision(const complex &c);
00086 explicit inline cdotprecision(const dotprecision &r);
00088 explicit inline cdotprecision(const l_real &r);
00089
00091 inline int get_k() const { return k; }
00093 inline void set_k(unsigned int i) { k=i; re.set_k(i); im.set_k(i); }
00095 inline int get_dotprec() const { return k; }
00097 inline void set_dotprec(unsigned int i) { k=i; re.set_k(i); im.set_k(i); }
00098
00100 inline cdotprecision& operator= (const real & a);
00102 inline cdotprecision& operator= (const complex & a);
00104 inline cdotprecision& operator= (const dotprecision & a);
00106 inline cdotprecision& operator= (const cdotprecision & a);
00108 inline cdotprecision& operator= (const l_real & a);
00109
00110
00111
00112
00113
00115 friend inline cdotprecision _cdotprecision(const dotprecision&);
00117 friend inline cdotprecision _cdotprecision(const real&);
00119 friend inline cdotprecision _cdotprecision(const l_real&);
00121 friend inline cdotprecision _cdotprecision(const complex&);
00123 friend inline cdotprecision _cdotprecision(const dotprecision&, const dotprecision&);
00125 friend inline cdotprecision _cdotprecision(const real&,const real&);
00127 friend inline cdotprecision _cdotprecision(const l_real&, const l_real&);
00129 friend inline cdotprecision _cdotprecision(const l_complex&);
00130
00131
00133 friend std::istream& operator >> (std::istream& s, cdotprecision& a) throw();
00135 friend std::ostream& operator << (std::ostream& s, const cdotprecision& a) throw();
00137 friend std::string& operator >> (std::string& s, cdotprecision& a) throw();
00139 friend std::string& operator << (std::string& s, const cdotprecision& a) throw();
00141 friend void operator >> (const std::string &s,cdotprecision& a) throw();
00143 friend void operator >> (const char *s ,cdotprecision& a) throw();
00144
00145
00147 friend inline cdotprecision operator -(const cdotprecision &) throw();
00149 friend inline cdotprecision operator +(const cdotprecision &) throw();
00150
00152 friend inline cdotprecision operator +(const cdotprecision &,const cdotprecision &) throw();
00154 friend inline cdotprecision operator -(const cdotprecision &,const cdotprecision &) throw();
00155
00157 friend inline cdotprecision operator +(const cdotprecision &,const complex &) throw();
00159 friend inline cdotprecision operator +(const complex &,const cdotprecision &) throw();
00161 friend inline cdotprecision operator -(const cdotprecision &,const complex &) throw();
00163 friend inline cdotprecision operator -(const complex &,const cdotprecision &) throw();
00164
00166 friend inline cdotprecision operator +(const cdotprecision &,const dotprecision &) throw();
00168 friend inline cdotprecision operator +(const dotprecision &,const cdotprecision &) throw();
00170 friend inline cdotprecision operator -(const cdotprecision &,const dotprecision &) throw();
00172 friend inline cdotprecision operator -(const dotprecision &,const cdotprecision &) throw();
00173
00175 friend inline cdotprecision operator +(const cdotprecision &,const real &) throw();
00177 friend inline cdotprecision operator +(const real &,const cdotprecision &) throw();
00179 friend inline cdotprecision operator -(const cdotprecision &,const real &) throw();
00181 friend inline cdotprecision operator -(const real &,const cdotprecision &) throw();
00182
00184 friend inline cdotprecision operator +(const cdotprecision &, const l_real &) throw();
00186 friend inline cdotprecision operator +(const l_real &, const cdotprecision &) throw();
00188 friend inline cdotprecision operator -(const cdotprecision &, const l_real &) throw();
00190 friend inline cdotprecision operator -(const l_real &, const cdotprecision &) throw();
00191
00193 friend inline cdotprecision & operator +=(cdotprecision &,const cdotprecision &) throw();
00195 friend inline cdotprecision & operator -=(cdotprecision &,const cdotprecision &) throw();
00197 friend inline cdotprecision & operator +=(cdotprecision &,const complex &) throw();
00199 friend inline cdotprecision & operator -=(cdotprecision &,const complex &) throw();
00201 friend inline cdotprecision & operator +=(cdotprecision &,const real &) throw();
00203 friend inline cdotprecision & operator -=(cdotprecision &,const real &) throw();
00205 friend inline cdotprecision & operator +=(cdotprecision &,const l_real &) throw();
00207 friend inline cdotprecision & operator -=(cdotprecision &,const l_real &) throw();
00208
00210 friend inline cdotprecision & operator +=(cdotprecision &,const dotprecision &) throw();
00212 friend inline cdotprecision & operator -=(cdotprecision &,const dotprecision &) throw();
00213
00214
00215
00217 friend inline bool operator ==(const cdotprecision &,const cdotprecision &) throw();
00219 friend inline bool operator !=(const cdotprecision &,const cdotprecision &) throw();
00220
00222 friend inline bool operator ==(const dotprecision &,const cdotprecision &) throw();
00224 friend inline bool operator !=(const dotprecision &,const cdotprecision &) throw();
00225
00227 friend inline bool operator ==(const cdotprecision &,const dotprecision &) throw();
00229 friend inline bool operator !=(const cdotprecision &,const dotprecision &) throw();
00230
00232 friend inline bool operator ==(const complex &,const cdotprecision &) throw();
00234 friend inline bool operator !=(const complex &,const cdotprecision &) throw();
00235
00237 friend inline bool operator ==(const cdotprecision &,const complex &) throw();
00239 friend inline bool operator !=(const cdotprecision &,const complex &) throw();
00240
00242 friend inline bool operator ==(const real &,const cdotprecision &) throw();
00244 friend inline bool operator !=(const real &,const cdotprecision &) throw();
00245
00247 friend inline bool operator ==(const cdotprecision &,const real &) throw();
00249 friend inline bool operator !=(const cdotprecision &,const real &) throw();
00250
00252 friend inline bool operator ==(const cdotprecision &, const l_real &) throw();
00254 friend inline bool operator ==(const l_real &, const cdotprecision &) throw();
00256 friend inline bool operator !=(const cdotprecision &, const l_real &) throw();
00258 friend inline bool operator !=(const l_real &, const cdotprecision &) throw();
00259
00261 friend inline bool operator !(const cdotprecision&) throw();
00262
00263
00264
00266 friend inline dotprecision & Re(cdotprecision& a);
00268 friend inline dotprecision & Im(cdotprecision& a) throw();
00270 friend inline const dotprecision & Re(const cdotprecision& a);
00272 friend inline const dotprecision & Im(const cdotprecision& a) throw();
00274 friend inline cdotprecision& SetRe (cdotprecision& a, const dotprecision& b) throw();
00276 friend inline cdotprecision& SetIm (cdotprecision& a, const dotprecision& b) throw();
00277
00279 friend inline cdotprecision conj(const cdotprecision &a) throw();
00280
00282 friend void rnd(const cdotprecision &,complex &,rndtype ) throw();
00284 friend void rnd(const cdotprecision &,complex &,complex &) throw();
00286 friend void rnd (const cdotprecision&, cinterval&) throw();
00288 friend complex rnd(const cdotprecision &,rndtype) throw();
00289
00291 friend void accumulate (cdotprecision&, const complex&, const complex&) throw();
00293 friend inline void accumulate (cdotprecision&, const complex&, const real&) throw();
00295 friend inline void accumulate (cdotprecision&, const real&, const complex&) throw();
00297 friend inline void accumulate (cdotprecision&, const real&, const real&) throw();
00298 };
00299
00300
00301
00302
00303
00304
00305
00306 inline cdotprecision _cdotprecision(const l_complex&);
00307
00308 std::istream& operator >> (std::istream& s, cdotprecision& a) throw();
00309 std::ostream& operator << (std::ostream& s, const cdotprecision& a) throw();
00310 std::string& operator >> (std::string& s, cdotprecision& a) throw();
00311 std::string& operator << (std::string& s, const cdotprecision& a) throw();
00312 void operator >> (const std::string &s,cdotprecision& a) throw();
00313 void operator >> (const char *s ,cdotprecision& a) throw();
00314
00315 void rnd(const cdotprecision &,complex &,rndtype = RND_NEXT) throw();
00316 void rnd(const cdotprecision &,complex &,complex &) throw();
00317 void rnd(const cdotprecision&, cinterval&) throw();
00318 complex rnd(const cdotprecision &,rndtype = RND_NEXT) throw();
00319
00320 void accumulate (cdotprecision&, const complex&, const complex&) throw();
00321
00322
00323
00324
00325
00326
00327
00328
00330 inline cdotprecision & operator += (cdotprecision &cd, const l_complex &lc) throw();
00331 inline cdotprecision & operator -= (cdotprecision &cd, const l_complex &lc) throw();
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344 }
00345
00346
00347
00348
00349
00350
00351
00352
00353 #include "cdot.inl"
00354
00355 #endif // _CXSC_CDOT_HPP_INCLUDED
00356