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
37namespace cxsc {
38
39class 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) noexcept;
135 friend std::ostream& operator << (std::ostream& s, const cdotprecision& a) noexcept;
137 friend std::string& operator >> (std::string& s, cdotprecision& a) noexcept;
139 friend std::string& operator << (std::string& s, const cdotprecision& a) noexcept;
141 friend void operator >> (const std::string &s,cdotprecision& a) noexcept;
143 friend void operator >> (const char *s ,cdotprecision& a) noexcept;
144
145 // ---- Standardfunkt ---- (arithmetische Operatoren)
147 friend inline cdotprecision operator -(const cdotprecision &) noexcept;
149 friend inline cdotprecision operator +(const cdotprecision &) noexcept;
150
152 friend inline cdotprecision operator +(const cdotprecision &,const cdotprecision &) noexcept;
154 friend inline cdotprecision operator -(const cdotprecision &,const cdotprecision &) noexcept;
155
157 friend inline cdotprecision operator +(const cdotprecision &,const complex &) noexcept;
159 friend inline cdotprecision operator +(const complex &,const cdotprecision &) noexcept;
161 friend inline cdotprecision operator -(const cdotprecision &,const complex &) noexcept;
163 friend inline cdotprecision operator -(const complex &,const cdotprecision &) noexcept;
164
166 friend inline cdotprecision operator +(const cdotprecision &,const dotprecision &) noexcept;
168 friend inline cdotprecision operator +(const dotprecision &,const cdotprecision &) noexcept;
170 friend inline cdotprecision operator -(const cdotprecision &,const dotprecision &) noexcept;
172 friend inline cdotprecision operator -(const dotprecision &,const cdotprecision &) noexcept;
173
175 friend inline cdotprecision operator +(const cdotprecision &,const real &) noexcept;
177 friend inline cdotprecision operator +(const real &,const cdotprecision &) noexcept;
179 friend inline cdotprecision operator -(const cdotprecision &,const real &) noexcept;
181 friend inline cdotprecision operator -(const real &,const cdotprecision &) noexcept;
182
184 friend inline cdotprecision operator +(const cdotprecision &, const l_real &) noexcept;
186 friend inline cdotprecision operator +(const l_real &, const cdotprecision &) noexcept;
188 friend inline cdotprecision operator -(const cdotprecision &, const l_real &) noexcept;
190 friend inline cdotprecision operator -(const l_real &, const cdotprecision &) noexcept;
191
193 friend inline cdotprecision & operator +=(cdotprecision &,const cdotprecision &) noexcept;
195 friend inline cdotprecision & operator -=(cdotprecision &,const cdotprecision &) noexcept;
197 friend inline cdotprecision & operator +=(cdotprecision &,const complex &) noexcept;
199 friend inline cdotprecision & operator -=(cdotprecision &,const complex &) noexcept;
201 friend inline cdotprecision & operator +=(cdotprecision &,const real &) noexcept;
203 friend inline cdotprecision & operator -=(cdotprecision &,const real &) noexcept;
205 friend inline cdotprecision & operator +=(cdotprecision &,const l_real &) noexcept;
207 friend inline cdotprecision & operator -=(cdotprecision &,const l_real &) noexcept;
208
210 friend inline cdotprecision & operator +=(cdotprecision &,const dotprecision &) noexcept;
212 friend inline cdotprecision & operator -=(cdotprecision &,const dotprecision &) noexcept;
213
214 // ---- Vergleichsop. ----
215
217 friend inline bool operator ==(const cdotprecision &,const cdotprecision &) noexcept;
219 friend inline bool operator !=(const cdotprecision &,const cdotprecision &) noexcept;
220
222 friend inline bool operator ==(const dotprecision &,const cdotprecision &) noexcept;
224 friend inline bool operator !=(const dotprecision &,const cdotprecision &) noexcept;
225
227 friend inline bool operator ==(const cdotprecision &,const dotprecision &) noexcept;
229 friend inline bool operator !=(const cdotprecision &,const dotprecision &) noexcept;
230
232 friend inline bool operator ==(const complex &,const cdotprecision &) noexcept;
234 friend inline bool operator !=(const complex &,const cdotprecision &) noexcept;
235
237 friend inline bool operator ==(const cdotprecision &,const complex &) noexcept;
239 friend inline bool operator !=(const cdotprecision &,const complex &) noexcept;
240
242 friend inline bool operator ==(const real &,const cdotprecision &) noexcept;
244 friend inline bool operator !=(const real &,const cdotprecision &) noexcept;
245
247 friend inline bool operator ==(const cdotprecision &,const real &) noexcept;
249 friend inline bool operator !=(const cdotprecision &,const real &) noexcept;
250
252 friend inline bool operator ==(const cdotprecision &, const l_real &) noexcept;
254 friend inline bool operator ==(const l_real &, const cdotprecision &) noexcept;
256 friend inline bool operator !=(const cdotprecision &, const l_real &) noexcept;
258 friend inline bool operator !=(const l_real &, const cdotprecision &) noexcept;
259
261 friend inline bool operator !(const cdotprecision&) noexcept;
262
263 // ---- Funktionen ----
264
266 friend inline dotprecision & Re(cdotprecision& a);
268 friend inline dotprecision & Im(cdotprecision& a) noexcept;
270 friend inline const dotprecision & Re(const cdotprecision& a);
272 friend inline const dotprecision & Im(const cdotprecision& a) noexcept;
274 friend inline cdotprecision& SetRe (cdotprecision& a, const dotprecision& b) noexcept;
276 friend inline cdotprecision& SetIm (cdotprecision& a, const dotprecision& b) noexcept;
277
279 friend inline cdotprecision conj(const cdotprecision &a) noexcept;
280
282 friend void rnd(const cdotprecision &,complex &,rndtype ) noexcept;
284 friend void rnd(const cdotprecision &,complex &,complex &) noexcept;
286 friend void rnd (const cdotprecision&, cinterval&) noexcept;
288 friend complex rnd(const cdotprecision &,rndtype) noexcept;
289
291 friend void accumulate (cdotprecision&, const complex&, const complex&) noexcept;
293 friend inline void accumulate (cdotprecision&, const complex&, const real&) noexcept;
295 friend inline void accumulate (cdotprecision&, const real&, const complex&) noexcept;
297 friend inline void accumulate (cdotprecision&, const real&, const real&) noexcept;
298};
299
300// ---------------------------------------------------------------------------
301// ---- ----
302// ---- friend functions of class cdotprecision (not inline) ----
303// ---- ----
304// ---------------------------------------------------------------------------
305
306inline cdotprecision _cdotprecision(const l_complex&);
307
308std::istream& operator >> (std::istream& s, cdotprecision& a) noexcept;
309std::ostream& operator << (std::ostream& s, const cdotprecision& a) noexcept;
310std::string& operator >> (std::string& s, cdotprecision& a) noexcept;
311std::string& operator << (std::string& s, const cdotprecision& a) noexcept;
312void operator >> (const std::string &s,cdotprecision& a) noexcept;
313void operator >> (const char *s ,cdotprecision& a) noexcept;
314
315void rnd(const cdotprecision &,complex &,rndtype = RND_NEXT) noexcept;
316void rnd(const cdotprecision &,complex &,complex &) noexcept;
317void rnd(const cdotprecision&, cinterval&) noexcept;
318complex rnd(const cdotprecision &,rndtype = RND_NEXT) noexcept;
319
320void accumulate (cdotprecision&, const complex&, const complex&) noexcept;
321
322
323// ---------------------------------------------------------------------------
324// ---- ----
325// ---- global functions associated with class cdotprecision ----
326// ---- ----
327// ---------------------------------------------------------------------------
328
330inline cdotprecision & operator += (cdotprecision &cd, const l_complex &lc) noexcept;
331inline cdotprecision & operator -= (cdotprecision &cd, const l_complex &lc) noexcept;
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
The Data Type cdotprecision.
Definition cdot.hpp:61
int get_dotprec() const
Get currently set precision for computation of dot products.
Definition cdot.hpp:95
void set_k(unsigned int i)
Set precision for computation of dot products.
Definition cdot.hpp:93
void set_dotprec(unsigned int i)
Set precision for computation of dot products.
Definition cdot.hpp:97
int get_k() const
Get currently set precision for computation of dot products.
Definition cdot.hpp:91
friend cdotprecision & SetIm(cdotprecision &a, const dotprecision &b) noexcept
Sets the imaginary part of a complex dotprecision value.
Definition cdot.inl:323
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
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) noexcept
Converting the exact complex dotprecision value with one rounding into a complex value.
Definition cdot.cpp:110
friend bool operator!=(const cdotprecision &, const cdotprecision &) noexcept
Implementation of standard negated equality operation.
Definition cdot.inl:262
friend cdotprecision operator-(const cdotprecision &) noexcept
Implementation of standard algebraic negative sign operation.
Definition cdot.inl:165
friend cdotprecision conj(const cdotprecision &a) noexcept
Returns the conjugated complex dotprecision value.
Definition cdot.inl:329
friend cdotprecision & SetRe(cdotprecision &a, const dotprecision &b) noexcept
Sets the real part of a complex dotprecision value.
Definition cdot.inl:317
friend cdotprecision & operator+=(cdotprecision &, const cdotprecision &) noexcept
Implementation of standard algebraic addition and allocation operation.
Definition cdot.inl:215
cdotprecision()
Constructor of class cdotprecision.
Definition cdot.hpp:70
friend std::istream & operator>>(std::istream &s, cdotprecision &a) noexcept
Implementation of standard input method.
Definition cdot.cpp:53
friend dotprecision & Im(cdotprecision &a) noexcept
Returns the imaginary part of the complex dotprecision value.
Definition cdot.inl:302
friend cdotprecision operator+(const cdotprecision &) noexcept
Implementation of standard algebraic positive sign operation.
Definition cdot.inl:169
cdotprecision & operator=(const real &a)
Implementation of standard assigning operator.
Definition cdot.inl:60
friend bool operator==(const cdotprecision &, const cdotprecision &) noexcept
Implementation of standard equality operation.
Definition cdot.inl:261
friend std::ostream & operator<<(std::ostream &s, const cdotprecision &a) noexcept
Implementation of standard output method.
Definition cdot.cpp:35
friend bool operator!(const cdotprecision &) noexcept
Implementation of standard negation operation.
Definition cdot.inl:334
friend cdotprecision & operator-=(cdotprecision &, const cdotprecision &) noexcept
Implementation of standard algebraic subtraction and allocation operation.
Definition cdot.inl:217
friend void accumulate(cdotprecision &, const complex &, const complex &) noexcept
The accurate scalar product of the last two arguments added to the value of the first argument.
Definition cdot.cpp:136
The Scalar Type cinterval.
Definition cinterval.hpp:55
The Scalar Type complex.
Definition complex.hpp:50
The Data Type dotprecision.
Definition dot.hpp:112
void set_k(unsigned int i)
Set precision for computation of dot products.
Definition dot.hpp:131
The Multiple-Precision Data Type l_complex.
Definition l_complex.hpp:46
The Multiple-Precision Data Type l_real.
Definition l_real.hpp:78
The Scalar Type real.
Definition real.hpp:114
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition cdot.cpp:29
cdotprecision & operator+=(cdotprecision &cd, const l_complex &lc) noexcept
Implementation of standard algebraic addition and allocation operation.
Definition cdot.inl:251
cdotprecision _cdotprecision(const l_complex &)
Definition cdot.inl:158