C-XSC - A C++ Class Library for Extended Scientific Computing 2.5.4
idot.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: idot.hpp,v 1.31 2014/01/30 17:23:45 cxsc Exp $ */
25
26#ifndef _CXSC_IDOT_HPP_INCLUDED
27#define _CXSC_IDOT_HPP_INCLUDED
28
29#include <iostream>
30#include <string>
31#include "dot.hpp"
32#include "interval.hpp"
33
34namespace cxsc {
35
37
48{
49 private:
50 // ---- Datenelemente ---------------------------------------
51 dotprecision inf,sup;
52 int k; //precision
53
54 public:
55 // ---- Constructors ---------------------------------------
57 idotprecision() : k(0) {}
59 inline idotprecision(const dotprecision&, const dotprecision&);
61 inline idotprecision(const idotprecision&);
62
63// explicit inline idotprecision(int n) : inf(n), sup(n) { }
64// explicit inline idotprecision(int a,int b) : inf(a), sup(b) { }
65// explicit inline idotprecision(const float &d) : inf(double(d)), sup(double(d)) { }
66// explicit inline idotprecision(const float &a, const float &b) : inf(double(a)),
67// sup(double(b)) { }
68// explicit inline idotprecision(const double &d) : inf(d), sup(d) { }
69// explicit inline idotprecision(const double &a, const double &b) : inf(a), sup(b) { }
71 explicit inline idotprecision(const real & a) : inf(a), sup(a), k(0) { }
73 explicit inline idotprecision(const real & a,const real & b) : inf(a), sup(b), k(0) { }
75 explicit inline idotprecision(const interval & a) : inf(Inf(a)), sup(Sup(a)), k(0) { }
77 explicit inline idotprecision(const dotprecision &r) : inf(r), sup(r), k(0) { inf.set_k(0); sup.set_k(0); }
79 explicit idotprecision(const l_real &) noexcept; // In l_real.cpp
81 explicit idotprecision(const l_real &,const l_real &); // in l_real.cpp
83 explicit idotprecision(const l_interval &) noexcept; // In l_interval.cpp
84
86 inline int get_k() const { return k; }
88 inline void set_k(unsigned int i) { k=i; inf.set_k(i); sup.set_k(i); }
90 inline int get_dotprec() const { return k; }
92 inline void set_dotprec(unsigned int i) { k=i; inf.set_k(i); sup.set_k(i); }
93
94 // inline idotprecision& operator= (const double& a) { inf=sup=a; return *this; }
96 inline idotprecision& operator= (const real& a) { inf=sup=a; return *this; }
98 inline idotprecision& operator= (const interval& a) { inf=Inf(a); sup=Sup(a); return *this; }
99 // inline idotprecision& operator= (const int& a) { inf=sup=a; return *this; }
101 inline idotprecision& operator= (const dotprecision& a) { inf=sup=a; return *this; }
103 inline idotprecision& operator= (const idotprecision& a){ inf=a.inf; sup=a.sup; return *this; }
105 inline idotprecision& operator= (const l_real & a) { inf=sup=a; return *this; }
107 idotprecision& operator= (const l_interval &) noexcept; // in l_interv.cpp
108
109 // ---- Destruktor ----
110 // ~idotprecision() {} unnoetig
111
112 // ---- Typwandlungen ----
114 friend inline idotprecision _idotprecision(const real &);
116 friend inline idotprecision _idotprecision(const real &,const real &);
118 friend inline idotprecision _unchecked_idotprecision(const real &,const real &);
120 friend inline idotprecision _idotprecision(const dotprecision&);
122 friend inline idotprecision _idotprecision(const dotprecision&, const dotprecision&);
125
127 friend inline idotprecision _idotprecision(const l_real &a) noexcept { return idotprecision(a); }
129 friend inline idotprecision _idotprecision(const l_real &a,const l_real &b) { return idotprecision(a,b); }
130
131
132 // ---- Ausgabefunkt. ---------------------------------------
134 friend std::istream& operator >> (std::istream& s, idotprecision& a) noexcept;
136 friend std::ostream& operator << (std::ostream& s, const idotprecision& a) noexcept;
138 friend std::string& operator >> (std::string& s, idotprecision& a) noexcept;
140 friend std::string& operator << (std::string& s, const idotprecision& a) noexcept;
142 friend void operator >> (const std::string &s,idotprecision& a) noexcept;
144 friend void operator >> (const char *s ,idotprecision& a) noexcept;
145
146 // ---- Standardfunkt ---- (arithmetische Operatoren)
148 friend inline idotprecision operator -(const idotprecision &) noexcept;
150 friend inline idotprecision operator +(const idotprecision &) noexcept;
151
153 friend inline idotprecision operator +(const idotprecision &,const idotprecision &) noexcept;
155 friend inline idotprecision operator -(const idotprecision &,const idotprecision &) noexcept;
157 friend inline idotprecision operator |(const idotprecision &,const idotprecision &) noexcept;
159 friend inline idotprecision operator &(const idotprecision &,const idotprecision &);
160
162 friend inline idotprecision operator +(const idotprecision &,const dotprecision &) noexcept;
164 friend inline idotprecision operator +(const dotprecision &,const idotprecision &) noexcept;
166 friend inline idotprecision operator -(const idotprecision &,const dotprecision &) noexcept;
168 friend inline idotprecision operator -(const dotprecision &,const idotprecision &) noexcept;
170 friend inline idotprecision operator |(const dotprecision &,const idotprecision &) noexcept;
172 friend inline idotprecision operator |(const idotprecision &,const dotprecision &) noexcept;
174 friend inline idotprecision operator |(const dotprecision &,const dotprecision &) noexcept;
176 friend inline idotprecision operator &(const dotprecision &,const idotprecision &);
178 friend inline idotprecision operator &(const idotprecision &,const dotprecision &);
179
181 friend inline idotprecision operator +(const idotprecision &,const long &) noexcept;
183 friend inline idotprecision operator +(const long &,const idotprecision &) noexcept;
185 friend inline idotprecision operator -(const idotprecision &,const long &) noexcept;
187 friend inline idotprecision operator -(const long &,const idotprecision &) noexcept;
189 friend inline idotprecision operator |(const long &,const idotprecision &) noexcept;
191 friend inline idotprecision operator |(const idotprecision &,const long &) noexcept;
193 friend inline idotprecision operator &(const long &,const idotprecision &);
195 friend inline idotprecision operator &(const idotprecision &,const long &);
196
198 friend inline idotprecision operator +(const idotprecision &,const real &) noexcept;
200 friend inline idotprecision operator +(const real &,const idotprecision &) noexcept;
202 friend inline idotprecision operator -(const idotprecision &,const real &) noexcept;
204 friend inline idotprecision operator -(const real &,const idotprecision &) noexcept;
206 friend inline idotprecision operator |(const real &,const idotprecision &) noexcept;
208 friend inline idotprecision operator |(const idotprecision &,const real &) noexcept;
210 friend inline idotprecision operator &(const real &,const idotprecision &);
212 friend inline idotprecision operator &(const idotprecision &,const real &);
213
215 friend idotprecision operator +(const idotprecision &,const l_real &) noexcept;
217 friend idotprecision operator +(const l_real &,const idotprecision &) noexcept;
219 friend idotprecision operator -(const idotprecision &,const l_real &) noexcept;
221 friend idotprecision operator -(const l_real &,const idotprecision &) noexcept;
223 friend idotprecision operator |(const l_real &,const idotprecision &) noexcept;
225 friend idotprecision operator |(const idotprecision &,const l_real &) noexcept;
227 friend idotprecision operator &(const l_real &,const idotprecision &);
229 friend idotprecision operator &(const idotprecision &,const l_real &);
230
232 friend inline idotprecision operator +(const idotprecision &,const interval &) noexcept;
234 friend inline idotprecision operator +(const interval &,const idotprecision &) noexcept;
236 friend inline idotprecision operator -(const idotprecision &,const interval &) noexcept;
238 friend inline idotprecision operator -(const interval &,const idotprecision &) noexcept;
240 friend inline idotprecision operator |(const interval &,const idotprecision &) noexcept;
242 friend inline idotprecision operator |(const idotprecision &,const interval &) noexcept;
244 friend inline idotprecision operator &(const interval &,const idotprecision &);
246 friend inline idotprecision operator &(const idotprecision &,const interval &);
247
249 friend inline idotprecision & operator +=(idotprecision &,const idotprecision &) noexcept;
251 friend inline idotprecision & operator -=(idotprecision &,const idotprecision &) noexcept;
253 friend inline idotprecision & operator +=(idotprecision &,const interval &) noexcept;
255 friend inline idotprecision & operator -=(idotprecision &,const interval &) noexcept;
257 friend inline idotprecision & operator +=(idotprecision &,const real &) noexcept;
259 friend inline idotprecision & operator -=(idotprecision &,const real &) noexcept;
261 friend idotprecision & operator +=(idotprecision &,const l_real &) noexcept;
263 friend idotprecision & operator -=(idotprecision &,const l_real &) noexcept;
265 friend inline idotprecision & operator +=(idotprecision &,const l_interval &) noexcept;
267 friend inline idotprecision & operator -=(idotprecision &,const l_interval &) noexcept;
268
270 friend inline idotprecision & operator |=(idotprecision &,const idotprecision &) noexcept;
272 friend inline idotprecision & operator &=(idotprecision &,const idotprecision &);
273
275 friend inline idotprecision & operator +=(idotprecision &,const dotprecision &) noexcept;
277 friend inline idotprecision & operator -=(idotprecision &,const dotprecision &) noexcept;
278
280 friend inline idotprecision & operator |=(idotprecision &,const dotprecision &) noexcept;
282 friend inline idotprecision & operator &=(idotprecision &,const dotprecision &);
283
284// friend inline idotprecision & operator |=(idotprecision & i,const long & l) noexcept { return i|=_dotprecision(l); }
285// friend inline idotprecision & operator &=(idotprecision & i,const long & l) { return i&=_dotprecision(l); }
287 friend inline idotprecision & operator |=(idotprecision & i,const real & l) noexcept { return i|=dotprecision(l); }
289 friend inline idotprecision & operator &=(idotprecision & i,const real & l) { return i&=dotprecision(l); }
290
292 friend idotprecision & operator |=(idotprecision & i,const l_real & l) noexcept; // in l_real.cpp
294 friend idotprecision & operator &=(idotprecision & i,const l_real & l); // in l_real.cpp
295
297 friend inline idotprecision & operator |=(idotprecision & i,const l_interval & l) noexcept; // in l_interv.inl
299 friend inline idotprecision & operator &=(idotprecision & i,const l_interval & l); // in l_interv.inl
300
301 // ---- Vergleichsop. ----
302
304 friend inline bool operator ==(const idotprecision &,const idotprecision &) noexcept;
306 friend inline bool operator !=(const idotprecision &,const idotprecision &) noexcept;
307
309 friend inline bool operator ==(const dotprecision &,const idotprecision &) noexcept;
311 friend inline bool operator !=(const dotprecision &,const idotprecision &) noexcept;
312
314 friend inline bool operator ==(const idotprecision &,const dotprecision &) noexcept;
316 friend inline bool operator !=(const idotprecision &,const dotprecision &) noexcept;
317
319 friend inline bool operator ==(const real &,const idotprecision &) noexcept;
321 friend inline bool operator !=(const real &,const idotprecision &) noexcept;
322
324 friend inline bool operator ==(const idotprecision &,const real &) noexcept;
326 friend inline bool operator !=(const idotprecision &,const real &) noexcept;
327
329 friend inline bool operator ==(const interval &,const idotprecision &) noexcept;
331 friend inline bool operator !=(const interval &,const idotprecision &) noexcept;
332
334 friend inline bool operator ==(const idotprecision &,const interval &) noexcept;
336 friend inline bool operator !=(const idotprecision &,const interval &) noexcept;
337
338 // ---- Mengenvergle. ----
339
341 friend inline bool operator <(const idotprecision &,const idotprecision &) noexcept;
343 friend inline bool operator >(const idotprecision &,const idotprecision &) noexcept;
345 friend inline bool operator <=(const idotprecision &,const idotprecision &) noexcept;
347 friend inline bool operator >=(const idotprecision &,const idotprecision &) noexcept;
348
350 friend inline bool operator <(const dotprecision &,const idotprecision &) noexcept;
352 friend inline bool operator >(const dotprecision &,const idotprecision &) noexcept { return false; }
354 friend inline bool operator <=(const dotprecision &,const idotprecision &) noexcept;
356 friend inline bool operator >=(const dotprecision &,const idotprecision &) noexcept;
357
359 friend inline bool operator <(const idotprecision &,const dotprecision &) noexcept { return false; }
361 friend inline bool operator >(const idotprecision &,const dotprecision &) noexcept;
363 friend inline bool operator <=(const idotprecision &,const dotprecision &) noexcept;
365 friend inline bool operator >=(const idotprecision &,const dotprecision &) noexcept;
366
368 friend inline bool operator <(const real &,const idotprecision &) noexcept;
370 friend inline bool operator >(const real &,const idotprecision &) noexcept { return false; }
372 friend inline bool operator <=(const real &,const idotprecision &) noexcept;
374 friend inline bool operator >=(const real &,const idotprecision &) noexcept;
375
377 friend inline bool operator <(const idotprecision &,const real &) noexcept { return false; }
379 friend inline bool operator >(const idotprecision &,const real &) noexcept;
381 friend inline bool operator <=(const idotprecision &,const real &) noexcept;
383 friend inline bool operator >=(const idotprecision &,const real &) noexcept;
384
386 friend inline bool operator <(const interval &,const idotprecision &) noexcept;
388 friend inline bool operator >(const interval &,const idotprecision &) noexcept;
390 friend inline bool operator <=(const interval &,const idotprecision &) noexcept;
392 friend inline bool operator >=(const interval &,const idotprecision &) noexcept;
393
395 friend inline bool operator <(const idotprecision &,const interval &) noexcept;
397 friend inline bool operator >(const idotprecision &,const interval &) noexcept;
399 friend inline bool operator <=(const idotprecision &,const interval &) noexcept;
401 friend inline bool operator >=(const idotprecision &,const interval &) noexcept;
402
404 friend inline bool operator !(const idotprecision&) noexcept;
405// operator void *(void) noexcept { return (void *)(!*this); }
406
407 // ---- Funktionen ----
408
410 friend dotprecision & Inf(idotprecision& a) noexcept { return a.inf; }
412 friend dotprecision & Sup(idotprecision& a) noexcept { return a.sup; }
414 friend const dotprecision & Inf(const idotprecision& a) noexcept { return a.inf; }
416 friend const dotprecision & Sup(const idotprecision& a) noexcept { return a.sup; }
417
419 friend inline idotprecision& SetInf (idotprecision &, const dotprecision &) noexcept;
421 friend inline idotprecision& SetSup (idotprecision &, const dotprecision &) noexcept;
423 friend inline idotprecision& SetInf (idotprecision &, const real &) noexcept;
425 friend inline idotprecision& SetSup (idotprecision &, const real &) noexcept;
427 friend inline idotprecision& UncheckedSetInf (idotprecision &, const dotprecision &) noexcept;
429 friend inline idotprecision& UncheckedSetSup (idotprecision &, const dotprecision &) noexcept;
431 friend inline idotprecision& UncheckedSetInf (idotprecision &, const real &) noexcept;
433 friend inline idotprecision& UncheckedSetSup (idotprecision &, const real &) noexcept;
434
436 friend inline bool IsEmpty (const idotprecision& a) noexcept;
437
439 friend inline idotprecision abs (const idotprecision& a) noexcept;
441 friend inline dotprecision mid (const idotprecision& a) noexcept;
443 friend inline dotprecision diam (const idotprecision& a) noexcept;
444
445 friend void rnd(const idotprecision &,interval &) noexcept;
446 friend interval rnd(const idotprecision &) noexcept;
447
449 friend void accumulate (idotprecision&, const interval&, const interval&) noexcept;
451 friend inline void accumulate (idotprecision&, const interval&, const real&) noexcept;
453 friend inline void accumulate (idotprecision&, const real&, const interval&) noexcept;
455 friend inline void accumulate (idotprecision&, const real&, const real&) noexcept;
456};
457
458//----------------------------------------------------------------------
459// global verfuegbare IDotprecision Akku's
460
461//#define MAXIDOTAKKU 3
462//extern idotprecision idotakku[MAXIDOTAKKU];
463
464//----------------------------------------------------------------------
465
466} // namespace cxsc
467
468#include "idot.inl"
469
470#endif
471
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 Data Type idotprecision.
Definition idot.hpp:48
friend idotprecision _idotprecision(const real &)
Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
Definition idot.inl:51
friend dotprecision & Inf(idotprecision &a) noexcept
Returns the infimum of a dotprecison interval.
Definition idot.hpp:410
friend const dotprecision & Sup(const idotprecision &a) noexcept
Returns the supremum of a dotprecison interval.
Definition idot.hpp:416
friend dotprecision & Sup(idotprecision &a) noexcept
Returns the supremum of a dotprecison interval.
Definition idot.hpp:412
friend const dotprecision & Inf(const idotprecision &a) noexcept
Returns the infimum of a dotprecison interval.
Definition idot.hpp:414
friend bool operator>=(const idotprecision &, const idotprecision &) noexcept
Implementation of standard greater-or-equal-than operation.
Definition idot.inl:333
friend idotprecision operator+(const idotprecision &) noexcept
Implementation of standard algebraic positive sign operation.
Definition idot.inl:110
friend idotprecision abs(const idotprecision &a) noexcept
Returns the absolute value of a dotprecision interval.
Definition idot.inl:479
idotprecision(const dotprecision &r)
Constructor of class idotprecision.
Definition idot.hpp:77
friend bool operator==(const idotprecision &, const idotprecision &) noexcept
Implementation of standard equality operation.
Definition idot.inl:310
friend bool IsEmpty(const idotprecision &a) noexcept
Returns if the dotprecision interval is empty.
Definition idot.inl:477
friend void accumulate(idotprecision &, const interval &, const interval &) noexcept
The accurate scalar product of the last two arguments added to the value of the first argument.
Definition idot.cpp:129
friend idotprecision & operator+=(idotprecision &, const idotprecision &) noexcept
Implementation of standard algebraic addition and allocation operation.
Definition idot.inl:241
friend bool operator<(const idotprecision &, const idotprecision &) noexcept
Implementation of standard less-than operation.
Definition idot.inl:337
friend idotprecision _idotprecision(const l_real &a) noexcept
Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
Definition idot.hpp:127
friend idotprecision operator|(const idotprecision &, const idotprecision &) noexcept
Returns the convex hull of the arguments.
Definition idot.inl:114
friend bool operator!=(const idotprecision &, const idotprecision &) noexcept
Implementation of standard negated equality operation.
Definition idot.inl:311
idotprecision & operator=(const real &a)
Implementation of standard assigning operator.
Definition idot.hpp:96
friend idotprecision & SetInf(idotprecision &, const dotprecision &) noexcept
Returns the dotprecison interval with the new given infimum value.
Definition idot.inl:434
int get_k() const
Get currently set precision for computation of dot products.
Definition idot.hpp:86
friend idotprecision _unchecked_idotprecision(const real &, const real &)
Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
Definition idot.inl:69
friend std::ostream & operator<<(std::ostream &s, const idotprecision &a) noexcept
Implementation of standard output method.
Definition idot.cpp:34
friend bool operator!(const idotprecision &) noexcept
Implementation of standard negation operation.
Definition idot.inl:475
friend idotprecision & UncheckedSetSup(idotprecision &, const dotprecision &) noexcept
Returns the dotprecison interval with the unchecked new given supremum value.
Definition idot.inl:459
friend idotprecision & operator|=(idotprecision &, const idotprecision &) noexcept
Allocates the convex hull of the arguments to the first argument.
Definition idot.inl:271
int get_dotprec() const
Get currently set precision for computation of dot products.
Definition idot.hpp:90
idotprecision(const real &a)
Constructor of class idotprecision.
Definition idot.hpp:71
friend dotprecision mid(const idotprecision &a) noexcept
Returns the middle of the dotprecision interval.
friend idotprecision operator-(const idotprecision &) noexcept
Implementation of standard algebraic negative sign operation.
Definition idot.inl:109
friend dotprecision diam(const idotprecision &a) noexcept
Returns the rounded diameter of the dotprecision interval.
idotprecision(const interval &a)
Constructor of class idotprecision.
Definition idot.hpp:75
friend idotprecision _idotprecision(const l_real &a, const l_real &b)
Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
Definition idot.hpp:129
friend idotprecision & SetSup(idotprecision &, const dotprecision &) noexcept
Returns the dotprecison interval with the new given supremum value.
Definition idot.inl:439
void set_k(unsigned int i)
Set precision for computation of dot products.
Definition idot.hpp:88
friend std::istream & operator>>(std::istream &s, idotprecision &a) noexcept
Implementation of standard input method.
Definition idot.cpp:54
idotprecision()
Constructor of class idotprecision.
Definition idot.hpp:57
friend bool operator<=(const idotprecision &, const idotprecision &) noexcept
Implementation of standard less-or-equal-than operation.
Definition idot.inl:329
friend idotprecision & operator&=(idotprecision &, const idotprecision &)
Allocates the intersection of the arguments to the first argument.
Definition idot.inl:279
friend idotprecision & operator-=(idotprecision &, const idotprecision &) noexcept
Implementation of standard algebraic subtraction and allocation operation.
Definition idot.inl:243
idotprecision(const real &a, const real &b)
Constructor of class idotprecision.
Definition idot.hpp:73
friend idotprecision & UncheckedSetInf(idotprecision &, const dotprecision &) noexcept
Returns the dotprecison interval with the unchecked new given infimum value.
Definition idot.inl:454
friend idotprecision operator&(const idotprecision &, const idotprecision &)
Returns the intersection of the arguments.
Definition idot.inl:162
void set_dotprec(unsigned int i)
Set precision for computation of dot products.
Definition idot.hpp:92
friend bool operator>(const idotprecision &, const idotprecision &) noexcept
Implementation of standard greater-than operation.
Definition idot.inl:341
The Scalar Type interval.
Definition interval.hpp:55
The Multiple-Precision Data Type l_interval.
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