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