dot.hpp

00001 /*
00002 **  CXSC is a C++ library for eXtended Scientific Computing (V 2.5.1)
00003 **
00004 **  Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik,
00005 **                          Universitaet Karlsruhe, Germany
00006 **            (C) 2000-2011 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: dot.hpp,v 1.30 2011/06/07 15:17:38 cxsc Exp $ */
00025 
00026 #ifndef _CXSC_DOT_HPP_INCLUDED
00027 #define _CXSC_DOT_HPP_INCLUDED
00028 
00029 #include <iostream>
00030 #include <string> 
00031 
00032 #include "compiler.h"
00033 #include "RtsTyp.h"
00034 
00035 namespace cxsc {
00036 
00037 
00038 // ---- RTS - Definitionen ----
00039     
00040 
00041   // Form des dotprec. Akkus:
00042   //      Pointer auf a_btyp
00043   //  ist Pointer auf long
00044 typedef  d_otpr   Dotprecision;
00045 
00046 // ----------------------------
00047 } // namespace cxsc 
00048 
00049 #include "real.hpp"
00050 #include "ioflags.hpp"
00051 
00052 namespace cxsc {
00053 
00054 class dotprecision;
00055 class idotprecision;
00056 
00057 
00058 //----------------------------------------------------------------------
00059 // global verfgbare Dotprecision Variablen
00060 //
00061 //  dotakku[0..3] stehen fuer Matrix, Langzahl u.a. Pakete zur
00062 //                Verfuegung
00063 //  dotakku[4]    wird in den skalaren Paketen intern verwendet
00064 
00065 //#define MAXDOTAKKU      5
00066 //extern dotprecision dotakku[MAXDOTAKKU];
00067 
00068 //Global precision for operators
00069 #ifdef CXSC_USE_TLS_PREC
00070 
00071 #ifdef _WIN32
00072 extern __declspec(thread) unsigned int opdotprec;
00073 #else
00074 extern __thread unsigned int opdotprec;
00075 #endif
00076 
00077 #else
00078 
00079 extern unsigned int opdotprec;
00080 
00081 #endif
00082 
00083 
00084 
00086 
00098 class dotprecision
00099 {
00100    private:
00101       // ---- Dataelements  -----------------------------------------
00102       Dotprecision akku;
00104       real err;
00106       int k;
00107 
00108    public:
00109       // ---- Constructors  -----------------------------------------
00111       dotprecision(void)                 throw();
00113       dotprecision(const dotprecision &) throw();
00114       
00116       inline int get_k() const { return k; }
00118       inline void set_k(unsigned int i) { k=i; }
00120       inline int get_dotprec() const { return k; }
00122       inline void set_dotprec(unsigned int i) { k=i; }
00124       inline real get_err() const { return err; }
00126       inline void set_err(real e) { err = e; }
00127 
00129       dotprecision & operator =(const dotprecision &) throw();
00131       dotprecision & operator =(const real &)         throw();
00133       dotprecision & operator =(const l_real &)       throw(); // in l_real.cpp
00134 
00135       // ---- Typecasts     -----------------------------------------
00137       explicit dotprecision(const real &)         throw();
00139       explicit dotprecision(const l_real &) throw();
00141 
00146       friend inline dotprecision _dotprecision(const real &d) throw();
00147 
00148       // ---- Destruktor    -----------------------------------------
00149       ~dotprecision(void) ;
00150 
00151       // ---- Input/Output  -----------------------------------------
00153       friend std::string  & operator <<(std::string &,const dotprecision &) throw();
00155       friend std::string  & operator >>(std::string &,dotprecision &)       throw();
00157       friend void           operator >>(const std::string &,dotprecision &) throw();
00159       friend void           operator >>(const char *,dotprecision &)        throw();
00161       friend std::ostream & operator <<(std::ostream &,const dotprecision &) throw();
00163       friend std::istream & operator >>(std::istream &,dotprecision &)      throw();
00164 
00165       // ---- Std.Operators -----------------------------------------
00167       friend  dotprecision operator -(const dotprecision &) throw();
00169       friend  dotprecision operator +(const dotprecision &) throw();
00170 
00172       friend  dotprecision operator +(const dotprecision &,const dotprecision &) throw();
00174       friend  dotprecision operator -(const dotprecision &,const dotprecision &) throw();
00176       friend inline idotprecision operator |(const dotprecision &,const dotprecision &) throw();
00177 
00179       friend  dotprecision operator +(const dotprecision &,const real &) throw();
00181       friend  dotprecision operator +(const real &,const dotprecision &) throw();
00183       friend  dotprecision operator -(const dotprecision &,const real &) throw();
00185       friend  dotprecision operator -(const real &,const dotprecision &) throw();
00187       friend inline idotprecision operator |(const real &,const dotprecision &) throw();
00189       friend inline idotprecision operator |(const dotprecision &,const real &) throw();
00190 
00192       friend dotprecision & operator +=(dotprecision &,const dotprecision &) throw();
00194       friend dotprecision & operator -=(dotprecision &,const dotprecision &) throw();
00195 
00197       friend dotprecision & operator +=(dotprecision &,const real &) throw();
00199       friend dotprecision & operator -=(dotprecision &,const real &) throw();
00200 
00201       // ---- Comp.Operat. ------------------------------------------
00203       friend bool operator  !(const dotprecision &) throw();
00204 //      operator void *() const throw() { if(sign(*this)) return (void *)1; else return 0;}
00205 
00207       friend bool operator ==(const dotprecision &,const dotprecision &) throw();
00209       friend bool operator !=(const dotprecision &,const dotprecision &) throw();
00211       friend bool operator  <(const dotprecision &,const dotprecision &) throw();
00213       friend bool operator  >(const dotprecision &,const dotprecision &) throw();
00215       friend bool operator <=(const dotprecision &,const dotprecision &) throw();
00217       friend bool operator >=(const dotprecision &,const dotprecision &) throw();
00218 
00220       friend bool operator ==(const real &,const dotprecision &) throw();
00222       friend bool operator !=(const real &,const dotprecision &) throw();
00224       friend bool operator  <(const real &,const dotprecision &) throw();
00226       friend bool operator  >(const real &,const dotprecision &) throw();
00228       friend bool operator <=(const real &,const dotprecision &) throw();
00230       friend bool operator >=(const real &,const dotprecision &) throw();
00231 
00233       friend bool operator ==(const dotprecision &,const real &) throw();
00235       friend bool operator !=(const dotprecision &,const real &) throw();
00237       friend bool operator  <(const dotprecision &,const real &) throw();
00239       friend bool operator  >(const dotprecision &,const real &) throw();
00241       friend bool operator <=(const dotprecision &,const real &) throw();
00243       friend bool operator >=(const dotprecision &,const real &) throw();
00244 
00245       // ---- Others ------------------------------------------------
00247       friend void rnd (const dotprecision&, real&, rndtype) throw();
00249       friend void rnd (const dotprecision&, real&, real&)              throw();
00251       friend void rnd (const dotprecision&, interval&) throw(); // Blomquist
00253       friend real rnd (const dotprecision&, rndtype)        throw();
00254 
00256       friend dotprecision abs(const dotprecision &) throw();
00258       friend int         sign(const dotprecision &) throw();
00260       friend dotprecision & accumulate (dotprecision&, const real&, const real&) throw();
00261 
00263       friend dotprecision & accumulate_approx (dotprecision&, const real&, const real&) throw();
00264 
00265       template<typename S, typename T>
00266       friend INLINE void addDot( dotprecision&, const S&, const T&);
00267       template<typename S, typename T>
00268       friend INLINE void addDot( cdotprecision&, const S&, const T&);
00269       template<typename S, typename T>
00270       friend INLINE void addDot( cidotprecision&, const S&, const T&);
00271 
00272       template<typename S, typename T>
00273       friend INLINE void addDot_op( dotprecision&, const S&, const T&);
00274       template<typename S, typename T>
00275       friend INLINE void addDot_op( cdotprecision&, const S&, const T&);
00276 
00277       template<typename S>
00278       friend INLINE void addSum( dotprecision&, const S&);
00279 
00280 
00281       // ---- internal functions ------------------------------------
00282       inline Dotprecision* ptr() { return &akku; }
00283 
00284 
00285    private:
00286       dotprecision & negdot(void) throw(); // Negates current dotprecision
00287 };
00288 
00289 
00290 
00291       inline dotprecision _dotprecision(const real &d) throw() { return dotprecision(d); }
00292       std::string  & operator <<(std::string &,const dotprecision &) throw();
00293       std::string  & operator >>(std::string &,dotprecision &)       throw();
00294       void           operator >>(const std::string &,dotprecision &) throw();
00295       void           operator >>(const char *,dotprecision &)        throw();
00296       std::ostream & operator <<(std::ostream &,const dotprecision &) throw();
00297       std::istream & operator >>(std::istream &,dotprecision &)      throw();
00298       dotprecision operator -(const dotprecision &) throw();
00299       dotprecision operator +(const dotprecision &) throw();
00300       dotprecision operator +(const dotprecision &,const dotprecision &) throw();
00301       dotprecision operator -(const dotprecision &,const dotprecision &) throw();
00302       inline idotprecision operator |(const dotprecision &,const dotprecision &) throw();
00303       dotprecision operator +(const dotprecision &,const real &) throw();
00304       dotprecision operator +(const real &,const dotprecision &) throw();
00305       dotprecision operator -(const dotprecision &,const real &) throw();
00306       dotprecision operator -(const real &,const dotprecision &) throw();
00307       inline idotprecision operator |(const real &,const dotprecision &) throw();
00308       inline idotprecision operator |(const dotprecision &,const real &) throw();
00309       dotprecision & operator +=(dotprecision &,const dotprecision &) throw();
00310       dotprecision & operator -=(dotprecision &,const dotprecision &) throw();
00311       dotprecision & operator +=(dotprecision &,const real &) throw();
00312       dotprecision & operator -=(dotprecision &,const real &) throw();
00313       bool operator  !(const dotprecision &) throw();
00314       bool operator ==(const dotprecision &,const dotprecision &) throw();
00315       bool operator !=(const dotprecision &,const dotprecision &) throw();
00316       bool operator  <(const dotprecision &,const dotprecision &) throw();
00317       bool operator  >(const dotprecision &,const dotprecision &) throw();
00318       bool operator <=(const dotprecision &,const dotprecision &) throw();
00319       bool operator >=(const dotprecision &,const dotprecision &) throw();
00320       bool operator ==(const real &,const dotprecision &) throw();
00321       bool operator !=(const real &,const dotprecision &) throw();
00322       bool operator  <(const real &,const dotprecision &) throw();
00323       bool operator  >(const real &,const dotprecision &) throw();
00324       bool operator <=(const real &,const dotprecision &) throw();
00325       bool operator >=(const real &,const dotprecision &) throw();
00326       bool operator ==(const dotprecision &,const real &) throw();
00327       bool operator !=(const dotprecision &,const real &) throw();
00328       bool operator  <(const dotprecision &,const real &) throw();
00329       bool operator  >(const dotprecision &,const real &) throw();
00330       bool operator <=(const dotprecision &,const real &) throw();
00331       bool operator >=(const dotprecision &,const real &) throw();
00332       void rnd (const dotprecision&, real&, rndtype = RND_NEXT) throw();
00333       void rnd (const dotprecision&, real&, real&)              throw();
00334       void rnd (const dotprecision&, interval&) throw();
00335       real rnd (const dotprecision&, rndtype = RND_NEXT)        throw();
00336       dotprecision abs(const dotprecision &) throw();
00337       int         sign(const dotprecision &) throw();
00338       dotprecision & accumulate (dotprecision&, const real&, const real&) throw();
00339 
00340 
00341 } // namespace cxsc 
00342 
00343 
00344 #endif // _CXSC_DOT_HPP_INCLUDED

Generated on Thu Jun 9 11:20:44 2011 for C-XSC - A C++ Class Library for Extended Scientific Computing by  doxygen 1.4.6