C-XSC - A C++ Class Library for Extended Scientific Computing  2.5.4
cidot.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: cidot.cpp,v 1.23 2014/01/30 17:23:43 cxsc Exp $ */
00025 
00026 #include "cidot.hpp"
00027 #include "ioflags.hpp"
00028 
00029 namespace cxsc {
00030 
00031 //cidotprecision cidotakku[MAXCIDOTAKKU];
00032 
00033 // ---- Ausgabefunkt. ---------------------------------------
00034 
00035 std::ostream & operator << (std::ostream &s, const cidotprecision& a) throw()
00036 {
00037    s << '(' << SaveOpt         
00038      << '[' << RndDown << a.reinf << ',' << RndUp << a.resup << ']' << ','  
00039      << '[' << RndDown << a.iminf << ',' << RndUp << a.imsup << ']' 
00040      << ')' << RestoreOpt;
00041      
00042    return s;
00043 }
00044 std::string & operator << (std::string &s, const cidotprecision &a) throw()
00045 {
00046    s+="([";
00047    s << SaveOpt << RndDown << a.reinf;
00048    s+=',';
00049    s << RndUp << a.resup;
00050    s+="],[";
00051    s << RndDown << a.iminf;
00052    s+=',';
00053    s << RndUp << a.imsup << RestoreOpt;
00054    s+="])";
00055    return s;
00056 }
00057 
00058 std::istream & operator >> (std::istream &s, cidotprecision &a) throw(ERROR_CIDOTPRECISION_EMPTY_INTERVAL)
00059 {
00060    char c;
00061 
00062    skipwhitespacesandputback (s, '(');
00063    skipwhitespacesandputback (s, '[');
00064    s >> SaveOpt >> RndDown >> a.reinf;
00065    skipwhitespacesandputback (s, ',');
00066    s >> RndUp >>a.resup;
00067    skipwhitespacesandputback (s, ']');
00068    skipwhitespacesandputback (s, ',');
00069    skipwhitespacesandputback (s, '[');
00070    s >> RndDown >> a.iminf;
00071    skipwhitespacesandputback (s, ',');
00072    s >> RndUp >> a.imsup >> RestoreOpt;
00073 
00074    if (!waseolnflag) 
00075    {
00076       skipeolnflag = false, inpdotflag = true;
00077       c = skipwhitespaces (s);
00078       if (inpdotflag && c != ']') 
00079          s.putback(c);
00080    }
00081    if (!waseolnflag) 
00082    {
00083       skipeolnflag = false, inpdotflag = true;
00084       c = skipwhitespaces (s);
00085       if (inpdotflag && c != ')') 
00086          s.putback(c);
00087    }
00088 
00089    if (a.reinf > a.resup || a.iminf > a.imsup) 
00090       cxscthrow(ERROR_CIDOTPRECISION_EMPTY_INTERVAL("std::istream & operator >> (std::istream &s, cidotprecision &a)"));
00091       
00092    return s;
00093 }
00094 
00095 std::string & operator >> (std::string &s, cidotprecision &a) throw(ERROR_CIDOTPRECISION_EMPTY_INTERVAL)
00096 {
00097    s = skipwhitespacessinglechar (s, '(');
00098    s = skipwhitespacessinglechar (s, '[');
00099    s = s >> SaveOpt >> RndDown >> a.reinf;
00100    s = skipwhitespacessinglechar (s, ',');
00101    s = s >> RndUp >> a.resup;
00102    s = skipwhitespacessinglechar (s, ']');
00103    s = skipwhitespacessinglechar (s, ',');
00104    s = skipwhitespacessinglechar (s, '[');
00105    s = s >> RndDown >> a.iminf;
00106    s = skipwhitespacessinglechar (s, ',');
00107    s = s >> RndUp >> a.iminf >> RestoreOpt;
00108    s = skipwhitespaces (s);
00109    if (s[0] == ']') 
00110       s.erase(0,1);
00111    s = skipwhitespaces (s);
00112    if (s[0] == ')') 
00113       s.erase(0,1);
00114 
00115    if (a.reinf > a.resup || a.iminf > a.imsup) 
00116       cxscthrow(ERROR_CIDOTPRECISION_EMPTY_INTERVAL("std::string & operator >> (std::string &s, cidotprecision &a)"));
00117 
00118    return s;
00119 }
00120 
00121 void operator >>(const std::string &s,cidotprecision &a) throw(ERROR_CIDOTPRECISION_EMPTY_INTERVAL)
00122 {
00123    std::string r(s);
00124    r>>a;
00125 }
00126 void operator >>(const char *s,cidotprecision &a) throw(ERROR_CIDOTPRECISION_EMPTY_INTERVAL)
00127 {
00128    std::string r(s);
00129    r>>a;
00130 }
00131 
00132 
00133 void accumulate(cidotprecision & a,const cinterval & b,const cinterval & c) throw()
00134 {
00135    z_padd(
00136       a.reinf.ptr(),a.iminf.ptr(),
00137       a.resup.ptr(),a.imsup.ptr(),
00138       *(a_cinv*)&b,*(a_cinv*)&c);      
00139 }
00140 
00141 } // namespace cxsc
00142