C-XSC - A C++ Class Library for Extended Scientific Computing
2.5.4
|
00001 /* 00002 ** CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4) 00003 ** 00004 ** Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik, 00005 ** Universitaet Karlsruhe, Germany 00006 ** (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie 00007 ** Universitaet Wuppertal, Germany 00008 ** 00009 ** This library is free software; you can redistribute it and/or 00010 ** modify it under the terms of the GNU Library General Public 00011 ** License as published by the Free Software Foundation; either 00012 ** version 2 of the License, or (at your option) any later version. 00013 ** 00014 ** This library is distributed in the hope that it will be useful, 00015 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 ** Library General Public License for more details. 00018 ** 00019 ** You should have received a copy of the GNU Library General Public 00020 ** License along with this library; if not, write to the Free 00021 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 */ 00023 00024 /* CVS $Id: cdot.hpp,v 1.35 2014/01/30 17:23:43 cxsc Exp $ */ 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; // forward declaration 00040 00041 // --------------------------------------------------------------------------- 00042 // ---- ---- 00043 // ---- class cdotprecision (declaration) ---- 00044 // ---- ---- 00045 // --------------------------------------------------------------------------- 00046 00048 00060 class cdotprecision 00061 { 00062 private: 00063 // ---- Datenelemente --------------------------------------- 00064 dotprecision re,im; 00065 int k; 00066 00067 public: 00068 // ---- Constructors --------------------------------------- 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 // ---- Destruktor ---- 00111 // ~cdotprecision() {} unnoetig 00112 00113 // ---- Typwandlungen ---- 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 // ---- Ausgabefunkt. --------------------------------------- 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 // ---- Standardfunkt ---- (arithmetische Operatoren) 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 // ---- Vergleichsop. ---- 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 // ---- Funktionen ---- 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 // ---- friend functions of class cdotprecision (not inline) ---- 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 // ---- global functions associated with class cdotprecision ---- 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 // ---- global CDotprecision Akku's ---- 00336 // ---- ---- 00337 // --------------------------------------------------------------------------- 00338 00339 //#define MAXCDOTAKKU (MAXDOTAKKU / 2) 00340 //extern cdotprecision cdotakku[MAXCDOTAKKU]; 00341 00342 // --------------------------------------------------------------------------- 00343 00344 } // namespace cxsc 00345 00346 00347 // --------------------------------------------------------------------------- 00348 // ---- ---- 00349 // ---- include definitions of inline functions ---- 00350 // ---- ---- 00351 // --------------------------------------------------------------------------- 00352 00353 #include "cdot.inl" 00354 00355 #endif // _CXSC_CDOT_HPP_INCLUDED 00356