C-XSC - A C++ Class Library for Extended Scientific Computing 2.5.4
cdot.cpp
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.cpp,v 1.25 2014/01/30 17:23:43 cxsc Exp $ */
25
26#include "cdot.hpp"
27#include "ioflags.hpp"
28
29namespace cxsc {
30
31//cdotprecision cdotakku[MAXCDOTAKKU];
32
33// ---- Ausgabefunkt. ---------------------------------------
34
35std::ostream & operator << (std::ostream &s, const cdotprecision& a) noexcept
36{
37 s << '('
38 << a.re << ','
39 << a.im
40 << ')';
41 return s;
42}
43std::string & operator << (std::string &s, const cdotprecision& a) noexcept
44{
45 s += '(';
46 s << a.re;
47 s += ',';
48 s << a.im;
49 s += ')';
50 return s;
51}
52
53std::istream & operator >> (std::istream &s, cdotprecision &a) noexcept
54{
55 char c;
56
57 skipeolnflag = inpdotflag = true;
58 c = skipwhitespacessinglechar (s, '(');
59 if (inpdotflag)
60 s.putback(c);
61
62 s >> a.re;
63
64 skipeolnflag = inpdotflag = true;
65 c = skipwhitespacessinglechar (s, ',');
66 if (inpdotflag)
67 s.putback(c);
68
69 s >> a.im;
70
71 if (!waseolnflag)
72 {
73 skipeolnflag = false, inpdotflag = true;
74 c = skipwhitespaces (s);
75 if (inpdotflag && c != ')')
76 s.putback(c);
77 }
78
79 return s;
80}
81
82
83
84std::string & operator >> (std::string &s, cdotprecision &a) noexcept
85{
86 s = skipwhitespacessinglechar (s, '(');
87 s >> a.re;
88 s = skipwhitespacessinglechar (s, ',');
89 s >> a.im;
90 s = skipwhitespaces (s);
91
92 if (s[0] == ')')
93 s.erase(0,1);
94
95 return s;
96}
97
98void operator >>(const std::string &s,cdotprecision &a) noexcept
99{
100 std::string r(s);
101 r>>a;
102}
103
104void operator >>(const char *s,cdotprecision &a) noexcept
105{
106 std::string r(s);
107 r>>a;
108}
109
110void rnd(const cdotprecision &a,complex &b,rndtype r) noexcept
111{
112 Re(b)=rnd(a.re,r);
113 Im(b)=rnd(a.im,r);
114}
115
116void rnd(const cdotprecision &a,complex &b,complex &c) noexcept
117{
118 rnd(a,b,RND_DOWN);
119 rnd(a,c,RND_UP);
120}
121
122void rnd (const cdotprecision& d, cinterval& x) noexcept
123{
124 complex a,b;
125 rnd(d,a,b);
126 x = cinterval(a,b);
127}
128
129complex rnd(const cdotprecision &a,rndtype r) noexcept
130{
131 complex b;
132 rnd(a,b,r);
133 return b;
134}
135
136void accumulate(cdotprecision & a, const complex & b, const complex & c) noexcept
137{
138 c_padd(a.re.ptr(),a.im.ptr(), *(a_cmpx*)&b,*(a_cmpx*)&c);
139}
140
141} // namespace cxsc
142
The Data Type cdotprecision.
Definition cdot.hpp:61
The Scalar Type cinterval.
Definition cinterval.hpp:55
The Scalar Type complex.
Definition complex.hpp:50
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition cdot.cpp:29