C-XSC - A C++ Class Library for Extended Scientific Computing
2.5.4
|
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: cdot.cpp,v 1.25 2014/01/30 17:23:43 cxsc Exp $ */ 00025 00026 #include "cdot.hpp" 00027 #include "ioflags.hpp" 00028 00029 namespace cxsc { 00030 00031 //cdotprecision cdotakku[MAXCDOTAKKU]; 00032 00033 // ---- Ausgabefunkt. --------------------------------------- 00034 00035 std::ostream & operator << (std::ostream &s, const cdotprecision& a) throw() 00036 { 00037 s << '(' 00038 << a.re << ',' 00039 << a.im 00040 << ')'; 00041 return s; 00042 } 00043 std::string & operator << (std::string &s, const cdotprecision& a) throw() 00044 { 00045 s += '('; 00046 s << a.re; 00047 s += ','; 00048 s << a.im; 00049 s += ')'; 00050 return s; 00051 } 00052 00053 std::istream & operator >> (std::istream &s, cdotprecision &a) throw() 00054 { 00055 char c; 00056 00057 skipeolnflag = inpdotflag = true; 00058 c = skipwhitespacessinglechar (s, '('); 00059 if (inpdotflag) 00060 s.putback(c); 00061 00062 s >> a.re; 00063 00064 skipeolnflag = inpdotflag = true; 00065 c = skipwhitespacessinglechar (s, ','); 00066 if (inpdotflag) 00067 s.putback(c); 00068 00069 s >> a.im; 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 return s; 00080 } 00081 00082 00083 00084 std::string & operator >> (std::string &s, cdotprecision &a) throw() 00085 { 00086 s = skipwhitespacessinglechar (s, '('); 00087 s >> a.re; 00088 s = skipwhitespacessinglechar (s, ','); 00089 s >> a.im; 00090 s = skipwhitespaces (s); 00091 00092 if (s[0] == ')') 00093 s.erase(0,1); 00094 00095 return s; 00096 } 00097 00098 void operator >>(const std::string &s,cdotprecision &a) throw() 00099 { 00100 std::string r(s); 00101 r>>a; 00102 } 00103 00104 void operator >>(const char *s,cdotprecision &a) throw() 00105 { 00106 std::string r(s); 00107 r>>a; 00108 } 00109 00110 void rnd(const cdotprecision &a,complex &b,rndtype r) throw() 00111 { 00112 Re(b)=rnd(a.re,r); 00113 Im(b)=rnd(a.im,r); 00114 } 00115 00116 void rnd(const cdotprecision &a,complex &b,complex &c) throw() 00117 { 00118 rnd(a,b,RND_DOWN); 00119 rnd(a,c,RND_UP); 00120 } 00121 00122 void rnd (const cdotprecision& d, cinterval& x) throw() 00123 { 00124 complex a,b; 00125 rnd(d,a,b); 00126 x = cinterval(a,b); 00127 } 00128 00129 complex rnd(const cdotprecision &a,rndtype r) throw() 00130 { 00131 complex b; 00132 rnd(a,b,r); 00133 return b; 00134 } 00135 00136 void accumulate(cdotprecision & a, const complex & b, const complex & c) throw() 00137 { 00138 c_padd(a.re.ptr(),a.im.ptr(), *(a_cmpx*)&b,*(a_cmpx*)&c); 00139 } 00140 00141 } // namespace cxsc 00142