C-XSC - A C++ Class Library for Extended Scientific Computing  2.5.4
idot.cpp
00001 /*
00002 **  CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4)
00003 **
00004 **  Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik,
00005 **                          Universitaet Karlsruhe, Germany
00006 **            (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie
00007 **                          Universitaet Wuppertal, Germany   
00008 **
00009 **  This library is free software; you can redistribute it and/or
00010 **  modify it under the terms of the GNU Library General Public
00011 **  License as published by the Free Software Foundation; either
00012 **  version 2 of the License, or (at your option) any later version.
00013 **
00014 **  This library is distributed in the hope that it will be useful,
00015 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 **  Library General Public License for more details.
00018 **
00019 **  You should have received a copy of the GNU Library General Public
00020 **  License along with this library; if not, write to the Free
00021 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 */
00023 
00024 /* CVS $Id: idot.cpp,v 1.23 2014/01/30 17:23:45 cxsc Exp $ */
00025 
00026 #include "idot.hpp"
00027 #include "ioflags.hpp"
00028 
00029 namespace cxsc {
00030 
00031 //idotprecision idotakku[MAXIDOTAKKU]; 
00032 // ---- Ausgabefunkt. ---------------------------------------
00033 
00034 std::ostream & operator << (std::ostream &s, const idotprecision& a) throw()
00035 {
00036    s << '['          << SaveOpt << RndDown  
00037      << a.inf << ',' << RndUp 
00038      << a.sup        << RestoreOpt 
00039      << ']';
00040    return s;
00041 }
00042 std::string & operator << (std::string &s, const idotprecision& a) throw()
00043 {
00044    s += '[';
00045    s << SaveOpt << RndDown  
00046      << a.inf;
00047    s += ',';
00048    s << RndUp 
00049      << a.sup   << RestoreOpt;
00050    s += ']';
00051    return s;
00052 }
00053 
00054 std::istream & operator >> (std::istream &s, idotprecision &a) throw()
00055 {
00056    char c;
00057 
00058    skipeolnflag = inpdotflag = true;
00059    c = skipwhitespacessinglechar (s, '[');
00060    if (inpdotflag)
00061       s.putback(c);
00062 
00063    s >> SaveOpt >> RndDown >> a.inf;
00064 
00065    skipeolnflag = inpdotflag = true;
00066    c = skipwhitespacessinglechar (s, ',');
00067    if (inpdotflag) s.putback(c);
00068 
00069    s >> RndUp >> a.sup >> RestoreOpt;
00070 
00071    if (!waseolnflag)
00072    {
00073       skipeolnflag = false, inpdotflag = true;
00074       c = skipwhitespaces (s);
00075       if (inpdotflag && c != ']')
00076          s.putback(c);
00077    }
00078 
00079    /*if (a.inf > a.sup) {
00080       errmon (ERR_INTERVAL(EMPTY));
00081    } */
00082    return s;
00083 }
00084         
00085 
00086 
00087 std::string & operator >> (std::string &s, idotprecision &a) throw()
00088 {
00089    s = skipwhitespacessinglechar (s, '[');
00090    s >> SaveOpt >> RndDown >> a.inf;
00091    s = skipwhitespacessinglechar (s, ',');
00092    s >> RndUp >> a.sup >> RestoreOpt;
00093    s = skipwhitespaces (s);
00094 
00095    if (s[0] == ']')
00096       s.erase(0,1);
00097 
00098     /*if (a.inf > a.sup) {
00099       errmon (ERR_INTERVAL(EMPTY));
00100     } */
00101    return s;
00102 }
00103 
00104 void operator >>(const std::string &s,idotprecision &a) throw()
00105 {
00106    std::string r(s);
00107    r>>a;
00108 }
00109 
00110 void operator >>(const char *s,idotprecision &a) throw()
00111 {
00112    std::string r(s);
00113    r>>a;
00114 }                          
00115 
00116 void rnd(const idotprecision &a,interval &b) throw()
00117 {
00118    Inf(b)=rnd(a.inf,RND_DOWN);
00119    Sup(b)=rnd(a.sup,RND_UP);
00120 }
00121 
00122 interval rnd(const idotprecision &a) throw()
00123 {
00124    interval b;
00125    rnd(a,b);
00126    return b;
00127 }
00128 
00129 void accumulate(idotprecision & a, const interval & b, const interval & c) throw()
00130 {
00131    i_padd(a.inf.ptr(),a.sup.ptr(), *(a_intv*)&b,*(a_intv*)&c);
00132 }
00133 
00134 } // namespace cxsc
00135