C-XSC - A C++ Class Library for Extended Scientific Computing  2.5.4
cdot.hpp
1 /*
2 ** CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4)
3 **
4 ** Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik,
5 ** Universitaet Karlsruhe, Germany
6 ** (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie
7 ** Universitaet Wuppertal, Germany
8 **
9 ** This library is free software; you can redistribute it and/or
10 ** modify it under the terms of the GNU Library General Public
11 ** License as published by the Free Software Foundation; either
12 ** version 2 of the License, or (at your option) any later version.
13 **
14 ** This library is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ** Library General Public License for more details.
18 **
19 ** You should have received a copy of the GNU Library General Public
20 ** License along with this library; if not, write to the Free
21 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23 
24 /* CVS $Id: cdot.hpp,v 1.35 2014/01/30 17:23:43 cxsc Exp $ */
25 
26 #ifndef _CXSC_CDOT_HPP_INCLUDED
27 #define _CXSC_CDOT_HPP_INCLUDED
28 
29 #include <iostream>
30 #include <string>
31 #include "dot.hpp"
32 #include "complex.hpp"
33 #include "l_real.hpp"
34 #include "l_complex.hpp"
35 #include "cinterval.hpp"
36 
37 namespace cxsc {
38 
39 class l_complex; // forward declaration
40 
41 // ---------------------------------------------------------------------------
42 // ---- ----
43 // ---- class cdotprecision (declaration) ----
44 // ---- ----
45 // ---------------------------------------------------------------------------
46 
48 
61 {
62  private:
63  // ---- Datenelemente ---------------------------------------
64  dotprecision re,im;
65  int k;
66 
67  public:
68  // ---- Constructors ---------------------------------------
70  cdotprecision() : k(0) {}
72  inline cdotprecision(const dotprecision&, const dotprecision&);
74  inline cdotprecision(const real &, const real &);
76  inline cdotprecision(const cdotprecision&);
78  inline cdotprecision(const l_real &, const l_real &);
80  inline cdotprecision(const l_complex &);
82  explicit inline cdotprecision(const real &r);
84  explicit inline cdotprecision(const complex &c);
86  explicit inline cdotprecision(const dotprecision &r);
88  explicit inline cdotprecision(const l_real &r);
89 
91  inline int get_k() const { return k; }
93  inline void set_k(unsigned int i) { k=i; re.set_k(i); im.set_k(i); }
95  inline int get_dotprec() const { return k; }
97  inline void set_dotprec(unsigned int i) { k=i; re.set_k(i); im.set_k(i); }
98 
100  inline cdotprecision& operator= (const real & a);
102  inline cdotprecision& operator= (const complex & a);
104  inline cdotprecision& operator= (const dotprecision & a);
106  inline cdotprecision& operator= (const cdotprecision & a);
108  inline cdotprecision& operator= (const l_real & a);
109 
110  // ---- Destruktor ----
111  // ~cdotprecision() {} unnoetig
112 
113  // ---- Typwandlungen ----
115  friend inline cdotprecision _cdotprecision(const dotprecision&);
117  friend inline cdotprecision _cdotprecision(const real&);
119  friend inline cdotprecision _cdotprecision(const l_real&);
121  friend inline cdotprecision _cdotprecision(const complex&);
123  friend inline cdotprecision _cdotprecision(const dotprecision&, const dotprecision&);
125  friend inline cdotprecision _cdotprecision(const real&,const real&);
127  friend inline cdotprecision _cdotprecision(const l_real&, const l_real&);
129  friend inline cdotprecision _cdotprecision(const l_complex&);
130 
131  // ---- Ausgabefunkt. ---------------------------------------
133  friend std::istream& operator >> (std::istream& s, cdotprecision& a) throw();
135  friend std::ostream& operator << (std::ostream& s, const cdotprecision& a) throw();
137  friend std::string& operator >> (std::string& s, cdotprecision& a) throw();
139  friend std::string& operator << (std::string& s, const cdotprecision& a) throw();
141  friend void operator >> (const std::string &s,cdotprecision& a) throw();
143  friend void operator >> (const char *s ,cdotprecision& a) throw();
144 
145  // ---- Standardfunkt ---- (arithmetische Operatoren)
147  friend inline cdotprecision operator -(const cdotprecision &) throw();
149  friend inline cdotprecision operator +(const cdotprecision &) throw();
150 
152  friend inline cdotprecision operator +(const cdotprecision &,const cdotprecision &) throw();
154  friend inline cdotprecision operator -(const cdotprecision &,const cdotprecision &) throw();
155 
157  friend inline cdotprecision operator +(const cdotprecision &,const complex &) throw();
159  friend inline cdotprecision operator +(const complex &,const cdotprecision &) throw();
161  friend inline cdotprecision operator -(const cdotprecision &,const complex &) throw();
163  friend inline cdotprecision operator -(const complex &,const cdotprecision &) throw();
164 
166  friend inline cdotprecision operator +(const cdotprecision &,const dotprecision &) throw();
168  friend inline cdotprecision operator +(const dotprecision &,const cdotprecision &) throw();
170  friend inline cdotprecision operator -(const cdotprecision &,const dotprecision &) throw();
172  friend inline cdotprecision operator -(const dotprecision &,const cdotprecision &) throw();
173 
175  friend inline cdotprecision operator +(const cdotprecision &,const real &) throw();
177  friend inline cdotprecision operator +(const real &,const cdotprecision &) throw();
179  friend inline cdotprecision operator -(const cdotprecision &,const real &) throw();
181  friend inline cdotprecision operator -(const real &,const cdotprecision &) throw();
182 
184  friend inline cdotprecision operator +(const cdotprecision &, const l_real &) throw();
186  friend inline cdotprecision operator +(const l_real &, const cdotprecision &) throw();
188  friend inline cdotprecision operator -(const cdotprecision &, const l_real &) throw();
190  friend inline cdotprecision operator -(const l_real &, const cdotprecision &) throw();
191 
193  friend inline cdotprecision & operator +=(cdotprecision &,const cdotprecision &) throw();
195  friend inline cdotprecision & operator -=(cdotprecision &,const cdotprecision &) throw();
197  friend inline cdotprecision & operator +=(cdotprecision &,const complex &) throw();
199  friend inline cdotprecision & operator -=(cdotprecision &,const complex &) throw();
201  friend inline cdotprecision & operator +=(cdotprecision &,const real &) throw();
203  friend inline cdotprecision & operator -=(cdotprecision &,const real &) throw();
205  friend inline cdotprecision & operator +=(cdotprecision &,const l_real &) throw();
207  friend inline cdotprecision & operator -=(cdotprecision &,const l_real &) throw();
208 
210  friend inline cdotprecision & operator +=(cdotprecision &,const dotprecision &) throw();
212  friend inline cdotprecision & operator -=(cdotprecision &,const dotprecision &) throw();
213 
214  // ---- Vergleichsop. ----
215 
217  friend inline bool operator ==(const cdotprecision &,const cdotprecision &) throw();
219  friend inline bool operator !=(const cdotprecision &,const cdotprecision &) throw();
220 
222  friend inline bool operator ==(const dotprecision &,const cdotprecision &) throw();
224  friend inline bool operator !=(const dotprecision &,const cdotprecision &) throw();
225 
227  friend inline bool operator ==(const cdotprecision &,const dotprecision &) throw();
229  friend inline bool operator !=(const cdotprecision &,const dotprecision &) throw();
230 
232  friend inline bool operator ==(const complex &,const cdotprecision &) throw();
234  friend inline bool operator !=(const complex &,const cdotprecision &) throw();
235 
237  friend inline bool operator ==(const cdotprecision &,const complex &) throw();
239  friend inline bool operator !=(const cdotprecision &,const complex &) throw();
240 
242  friend inline bool operator ==(const real &,const cdotprecision &) throw();
244  friend inline bool operator !=(const real &,const cdotprecision &) throw();
245 
247  friend inline bool operator ==(const cdotprecision &,const real &) throw();
249  friend inline bool operator !=(const cdotprecision &,const real &) throw();
250 
252  friend inline bool operator ==(const cdotprecision &, const l_real &) throw();
254  friend inline bool operator ==(const l_real &, const cdotprecision &) throw();
256  friend inline bool operator !=(const cdotprecision &, const l_real &) throw();
258  friend inline bool operator !=(const l_real &, const cdotprecision &) throw();
259 
261  friend inline bool operator !(const cdotprecision&) throw();
262 
263  // ---- Funktionen ----
264 
266  friend inline dotprecision & Re(cdotprecision& a);
268  friend inline dotprecision & Im(cdotprecision& a) throw();
270  friend inline const dotprecision & Re(const cdotprecision& a);
272  friend inline const dotprecision & Im(const cdotprecision& a) throw();
274  friend inline cdotprecision& SetRe (cdotprecision& a, const dotprecision& b) throw();
276  friend inline cdotprecision& SetIm (cdotprecision& a, const dotprecision& b) throw();
277 
279  friend inline cdotprecision conj(const cdotprecision &a) throw();
280 
282  friend void rnd(const cdotprecision &,complex &,rndtype ) throw();
284  friend void rnd(const cdotprecision &,complex &,complex &) throw();
286  friend void rnd (const cdotprecision&, cinterval&) throw();
288  friend complex rnd(const cdotprecision &,rndtype) throw();
289 
291  friend void accumulate (cdotprecision&, const complex&, const complex&) throw();
293  friend inline void accumulate (cdotprecision&, const complex&, const real&) throw();
295  friend inline void accumulate (cdotprecision&, const real&, const complex&) throw();
297  friend inline void accumulate (cdotprecision&, const real&, const real&) throw();
298 };
299 
300 // ---------------------------------------------------------------------------
301 // ---- ----
302 // ---- friend functions of class cdotprecision (not inline) ----
303 // ---- ----
304 // ---------------------------------------------------------------------------
305 
306 inline cdotprecision _cdotprecision(const l_complex&);
307 
308 std::istream& operator >> (std::istream& s, cdotprecision& a) throw();
309 std::ostream& operator << (std::ostream& s, const cdotprecision& a) throw();
310 std::string& operator >> (std::string& s, cdotprecision& a) throw();
311 std::string& operator << (std::string& s, const cdotprecision& a) throw();
312 void operator >> (const std::string &s,cdotprecision& a) throw();
313 void operator >> (const char *s ,cdotprecision& a) throw();
314 
315 void rnd(const cdotprecision &,complex &,rndtype = RND_NEXT) throw();
316 void rnd(const cdotprecision &,complex &,complex &) throw();
317 void rnd(const cdotprecision&, cinterval&) throw();
318 complex rnd(const cdotprecision &,rndtype = RND_NEXT) throw();
319 
320 void accumulate (cdotprecision&, const complex&, const complex&) throw();
321 
322 
323 // ---------------------------------------------------------------------------
324 // ---- ----
325 // ---- global functions associated with class cdotprecision ----
326 // ---- ----
327 // ---------------------------------------------------------------------------
328 
330 inline cdotprecision & operator += (cdotprecision &cd, const l_complex &lc) throw();
331 inline cdotprecision & operator -= (cdotprecision &cd, const l_complex &lc) throw();
332 
333 // ---------------------------------------------------------------------------
334 // ---- ----
335 // ---- global CDotprecision Akku's ----
336 // ---- ----
337 // ---------------------------------------------------------------------------
338 
339 //#define MAXCDOTAKKU (MAXDOTAKKU / 2)
340 //extern cdotprecision cdotakku[MAXCDOTAKKU];
341 
342 // ---------------------------------------------------------------------------
343 
344 } // namespace cxsc
345 
346 
347 // ---------------------------------------------------------------------------
348 // ---- ----
349 // ---- include definitions of inline functions ----
350 // ---- ----
351 // ---------------------------------------------------------------------------
352 
353 #include "cdot.inl"
354 
355 #endif // _CXSC_CDOT_HPP_INCLUDED
356 
void set_k(unsigned int i)
Set precision for computation of dot products.
Definition: dot.hpp:131
friend std::ostream & operator<<(std::ostream &s, const cdotprecision &a)
Implementation of standard output method.
Definition: cdot.cpp:35
friend cdotprecision operator+(const cdotprecision &)
Implementation of standard algebraic positive sign operation.
Definition: cdot.inl:169
friend std::istream & operator>>(std::istream &s, cdotprecision &a)
Implementation of standard input method.
Definition: cdot.cpp:53
The Multiple-Precision Data Type l_real.
Definition: l_real.hpp:77
The Data Type dotprecision.
Definition: dot.hpp:111
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition: cdot.cpp:29
void set_k(unsigned int i)
Set precision for computation of dot products.
Definition: cdot.hpp:93
friend dotprecision & Re(cdotprecision &a)
Returns the real part of the complex dotprecision value.
Definition: cdot.inl:297
friend void rnd(const cdotprecision &, complex &, rndtype)
Converting the exact complex dotprecision value with one rounding into a complex value.
Definition: cdot.cpp:110
friend cdotprecision & SetIm(cdotprecision &a, const dotprecision &b)
Sets the imaginary part of a complex dotprecision value.
Definition: cdot.inl:323
cdotprecision & operator=(const real &a)
Implementation of standard assigning operator.
Definition: cdot.inl:60
friend cdotprecision conj(const cdotprecision &a)
Returns the conjugated complex dotprecision value.
Definition: cdot.inl:329
friend cdotprecision operator-(const cdotprecision &)
Implementation of standard algebraic negative sign operation.
Definition: cdot.inl:165
friend cdotprecision & SetRe(cdotprecision &a, const dotprecision &b)
Sets the real part of a complex dotprecision value.
Definition: cdot.inl:317
friend cdotprecision & operator+=(cdotprecision &, const cdotprecision &)
Implementation of standard algebraic addition and allocation operation.
Definition: cdot.inl:215
friend bool operator!=(const cdotprecision &, const cdotprecision &)
Implementation of standard negated equality operation.
Definition: cdot.inl:262
int get_dotprec() const
Get currently set precision for computation of dot products.
Definition: cdot.hpp:95
The Data Type cdotprecision.
Definition: cdot.hpp:60
friend dotprecision & Im(cdotprecision &a)
Returns the imaginary part of the complex dotprecision value.
Definition: cdot.inl:302
The Scalar Type cinterval.
Definition: cinterval.hpp:54
int get_k() const
Get currently set precision for computation of dot products.
Definition: cdot.hpp:91
The Multiple-Precision Data Type l_complex.
Definition: l_complex.hpp:45
The Scalar Type complex.
Definition: complex.hpp:49
friend bool operator!(const cdotprecision &)
Implementation of standard negation operation.
Definition: cdot.inl:334
friend cdotprecision & operator-=(cdotprecision &, const cdotprecision &)
Implementation of standard algebraic subtraction and allocation operation.
Definition: cdot.inl:217
friend cdotprecision _cdotprecision(const dotprecision &)
Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC...
Definition: cdot.inl:90
cdotprecision()
Constructor of class cdotprecision.
Definition: cdot.hpp:70
The Scalar Type real.
Definition: real.hpp:113
friend void accumulate(cdotprecision &, const complex &, const complex &)
The accurate scalar product of the last two arguments added to the value of the first argument...
Definition: cdot.cpp:136
void set_dotprec(unsigned int i)
Set precision for computation of dot products.
Definition: cdot.hpp:97
friend bool operator==(const cdotprecision &, const cdotprecision &)
Implementation of standard equality operation.
Definition: cdot.inl:261