basicNumber.h

Go to the documentation of this file.
00001 
00002 #ifndef basicNumber_h
00003 #define basicNumber_h
00004 
00005 
00006 
00007 #include <vector>
00008 #include <iostream>
00009 #include <assert.h>
00010 
00011 
00012 #include "typedefs.h"
00013 #include <math.h>
00014 
00015 #define STR(X) #X
00016 #define SW_STATUS(v1)  STR(v1)
00017 
00018 
00019 
00020 
00021 
00058 template <typename TScalar>
00059 class basicNumber
00060 {
00061 
00062 protected:
00063 
00064           TScalar x;    
00065           TScalar eps;  
00066 
00067  public:
00068 
00071                 typedef TScalar scalarType; // ja? dann sollte man auch fieldScalar als TScalar uebergeben!
00072         
00074                 static  const   basicNumber Zero;//=basicNumber(0);
00075                 
00077                 static  const   basicNumber One;//=basicNumber(1);
00083 
00084                 static inline bool memsetClearAllowed() {       return true; }
00091                 static inline bool wellDefined(unsigned int characteristic);
00096 
00097                 inline   basicNumber();
00098         
00100                 inline basicNumber (TScalar s);
00101         
00103                 inline basicNumber (TScalar epsPrecision, std::string s );
00104         
00106                 inline basicNumber (TScalar s, TScalar t);
00107                 
00109                 inline basicNumber (const  basicNumber & z);
00110         
00115                 inline  unsigned short  getEpsPrecision() const;
00116                 inline  void    setEpsPrecision(int epsPrecision) const {       assert(false);  };
00118                 inline  short   getEpsDegree() const;
00124                 inline  TScalar         getX()          const;  
00125                 inline  TScalar         getEps()        const;  
00126 
00127                 inline  void            setX  (TScalar xxx);    
00128                 inline  void            setEps(TScalar _eps) ;
00129 
00131                 inline  TScalar         getValue(TScalar epsPrecision) const ;
00132 
00134                 inline  void            setValue(TScalar epsPrecision, TScalar coeff) ;
00140                 inline TScalar&         operator[](int i);
00141 
00142                 // inline void          operator+=(const basicNumber &z);
00143 
00149 
00150                 inline  int             nearlyEqual(const basicNumber z) const;
00151         
00152                 inline  bool            isZero()        const;
00153                 inline  bool            isNotZero()     const;
00154 
00155                 inline  bool            operator==( const basicNumber z) const;
00156                 inline  bool            operator!=( const basicNumber z) const;
00157                 
00163                 static size_t   getPairIndex     (const basicNumber a,
00164                                                                 const basicNumber b,
00165                                                                 const TScalar   characteristic);
00166         
00167                 static size_t   getPairIndexByRef(const basicNumber & a, 
00168                                                                 const basicNumber & b,
00169                                                                 const TScalar   & characteristic);
00170         
00171                 static size_t   getSingleIndex  (const basicNumber b,
00172                                                                  const TScalar           characteristic);
00173 
00174                 static size_t   getSingleIndexByRef(const basicNumber &         b,
00175                                                                   const TScalar           & characteristic);
00176 
00177                 static size_t           getMaxSingleIndex(  const TScalar       characteristic);
00178                 static size_t           getMaxPairIndex  (  const TScalar       characteristic);
00181                 void printMultSecure(std::ostream &os)  const;
00182 
00183 };
00184 
00185 
00186 
00187 
00188 
00191 
00194 
00199 template <typename TScalar>
00200 class fieldScalar
00201 {
00202 
00203 protected:
00204 
00205           TScalar x;            
00206 
00207  public:
00208         inline operator int() {return x;}
00209         //inline operator uint16_t() {return x;}
00210         //inline operator const uint16_t() const {return x;}
00211         
00212         //operator uint16_t() {return x;}
00213         //operator uint32_t() {return x;}
00214 
00217                 typedef TScalar scalarType;
00218         
00220                 static  const   fieldScalar Zero;//=fieldScalar(0);
00221                 
00223                 static  const   fieldScalar One;//=fieldScalar(1);
00227 
00228                 static inline bool memsetClearAllowed() {       return true; }
00229 
00238                 static inline bool wellDefined(unsigned int characteristic);
00239         
00240 
00244                 inline   fieldScalar(std::stringstream  & sstream);
00246                 inline   fieldScalar();
00247                 //inline   fieldScalar(int bla):x((TScalar)bla) {};
00248         
00250                 inline fieldScalar (TScalar s);
00251                 inline fieldScalar (TScalar s,TScalar eps) ; //{ s + 0*EPS }
00252         
00254                 inline fieldScalar (TScalar epsPrecision, std::string s );
00255                 
00257                 inline fieldScalar (const  fieldScalar & z);
00258         
00264                 inline  unsigned short  getEpsPrecision() const;
00265 
00267                 inline  short   getEpsDegree() const;
00274                 inline  TScalar         getX()   const;
00275                 inline  TScalar         getEps()  const;
00276 
00277                 inline  void            setX  (TScalar xxx);    
00278                 inline  void            setEps(TScalar _eps) ;
00279 
00280 
00282                 inline  TScalar         getValue(TScalar epsPrecision) const;
00283 
00285                 inline  void            setValue(TScalar _epsExponent, TScalar coeff) ;
00291                 inline TScalar&         operator[](int i);
00292                 //inline void           operator+=(const fieldScalar &z);
00298 
00299                 inline  int             nearlyEqual(const fieldScalar z) const;
00300         
00301                 inline  bool            isZero()         const;
00302                 inline  bool            isNotZero()     const;
00303 
00304                 inline  bool            operator==( const fieldScalar z) const;
00305                 inline  bool            operator!=( const fieldScalar z) const;
00311 
00312                 inline static size_t    getSingleIndex          (const fieldScalar b,    
00313                                                                                  const TScalar  characteristic          );
00314 
00315                 inline static size_t    getSingleIndexByRef     (const fieldScalar & b,  
00316                                                                                 const TScalar   & characteristic        );
00317 
00318                 inline static size_t    getSingleIndex          (const fieldScalar b  );
00319 
00320                 inline static size_t    getSingleIndexByRef     (const fieldScalar & b);
00321 
00322                 inline static size_t    getPairIndex     ( const fieldScalar a,  
00323                                                                          const fieldScalar b, 
00324                                                                          const TScalar  characteristic  );
00325 
00326                 inline static size_t    getPairIndexByRef(const fieldScalar & a,
00327                                                                         const fieldScalar & b,
00328                                                                         const TScalar   &characteristic );
00329 
00330                 static size_t   getMaxSingleIndex(const TScalar characteristic  );
00331 
00332                 static size_t   getMaxPairIndex  (const TScalar characteristic  );
00335         void printMultSecure(std::ostream &os)  const;
00336 };
00337 
00338 
00339         #include "basicNumber.cpp"
00340 
00341 #endif // #ifndef basicNumber_h
Generated on Tue Nov 23 13:10:51 2010 for centerfocus by  doxygen 1.6.3