C-XSC - A C++ Class Library for Extended Scientific Computing 2.5.4
idot.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: idot.cpp,v 1.23 2014/01/30 17:23:45 cxsc Exp $ */
25
26#include "idot.hpp"
27#include "ioflags.hpp"
28
29namespace cxsc {
30
31//idotprecision idotakku[MAXIDOTAKKU];
32// ---- Ausgabefunkt. ---------------------------------------
33
34std::ostream & operator << (std::ostream &s, const idotprecision& a) noexcept
35{
36 s << '[' << SaveOpt << RndDown
37 << a.inf << ',' << RndUp
38 << a.sup << RestoreOpt
39 << ']';
40 return s;
41}
42std::string & operator << (std::string &s, const idotprecision& a) noexcept
43{
44 s += '[';
45 s << SaveOpt << RndDown
46 << a.inf;
47 s += ',';
48 s << RndUp
49 << a.sup << RestoreOpt;
50 s += ']';
51 return s;
52}
53
54std::istream & operator >> (std::istream &s, idotprecision &a) noexcept
55{
56 char c;
57
58 skipeolnflag = inpdotflag = true;
59 c = skipwhitespacessinglechar (s, '[');
60 if (inpdotflag)
61 s.putback(c);
62
63 s >> SaveOpt >> RndDown >> a.inf;
64
65 skipeolnflag = inpdotflag = true;
66 c = skipwhitespacessinglechar (s, ',');
67 if (inpdotflag) s.putback(c);
68
69 s >> RndUp >> a.sup >> RestoreOpt;
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 /*if (a.inf > a.sup) {
80 errmon (ERR_INTERVAL(EMPTY));
81 } */
82 return s;
83}
84
85
86
87std::string & operator >> (std::string &s, idotprecision &a) noexcept
88{
89 s = skipwhitespacessinglechar (s, '[');
90 s >> SaveOpt >> RndDown >> a.inf;
91 s = skipwhitespacessinglechar (s, ',');
92 s >> RndUp >> a.sup >> RestoreOpt;
93 s = skipwhitespaces (s);
94
95 if (s[0] == ']')
96 s.erase(0,1);
97
98 /*if (a.inf > a.sup) {
99 errmon (ERR_INTERVAL(EMPTY));
100 } */
101 return s;
102}
103
104void operator >>(const std::string &s,idotprecision &a) noexcept
105{
106 std::string r(s);
107 r>>a;
108}
109
110void operator >>(const char *s,idotprecision &a) noexcept
111{
112 std::string r(s);
113 r>>a;
114}
115
116void rnd(const idotprecision &a,interval &b) noexcept
117{
118 Inf(b)=rnd(a.inf,RND_DOWN);
119 Sup(b)=rnd(a.sup,RND_UP);
120}
121
122interval rnd(const idotprecision &a) noexcept
123{
124 interval b;
125 rnd(a,b);
126 return b;
127}
128
129void accumulate(idotprecision & a, const interval & b, const interval & c) noexcept
130{
131 i_padd(a.inf.ptr(),a.sup.ptr(), *(a_intv*)&b,*(a_intv*)&c);
132}
133
134} // namespace cxsc
135
The Data Type idotprecision.
Definition idot.hpp:48
The Scalar Type interval.
Definition interval.hpp:55
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition cdot.cpp:29