synaps/usolve/NumberTraits.h

00001 #ifndef SYNAPS_ARITHM_NUMBER_TRAITS_H
00002 #define SYNAPS_ARITHM_NUMBER_TRAITS_H
00003 
00004 #include <synaps/init.h>
00005 #include <synaps/base/type.h>
00006 #include <synaps/arithm/Abs.h>
00007 #include <synaps/arithm/pow.h>
00008 #include <synaps/arithm/inv.h>
00009 #include <synaps/arithm/sign.h>
00010 #include <synaps/arithm/traits.h>
00011 #include <synaps/arithm/functions.h>
00012 #include <synaps/arithm/Interval.h>
00013 
00014 #include <synaps/arithm/gmp.h>
00015 
00016 //#include <synaps/numerics/Various_defs.h>
00017 
00018 __BEGIN_NAMESPACE_SYNAPS
00019 
00020 
00036 template < typename RT_ >
00037 struct NumberTraits {
00038   typedef typename kernelof< RT_ >::T             K;
00039   typedef typename K::integer                     RT; 
00040   typedef typename K::rational                    FT;
00041   typedef typename K::ieee                        XT;
00042   typedef Interval< FT >                          FIT;
00043   typedef Interval< XT >                          XIT;
00044   typedef NumberTraits<RT>                        self_t;
00045   
00046   typedef typename hasfunction<RT>::gcd Has_gcd;
00047   typedef typename hasfunction<RT>::isqrt Has_isqrt;
00048   typedef typename hasfunction<RT>::sqrt Has_sqrt;
00049   
00050   typedef typename isexact<RT>::T          Is_exact;
00051   typedef typename isring<RT>::T          Is_Ring_type;
00052   typedef typename isfield<RT>::T         Is_Field_type;
00053 };
00054 
00055 template<> 
00056 struct NumberTraits<double> : NumberTraits<GMP::integer> 
00057 { 
00058 };
00059 
00060 
00061 
00069 template < typename T >  inline T
00070 isqrt(const T& a)
00071 {
00072   assert (a > 0);
00073   return T(std::floor(std::sqrt(to_double(a))));
00074 };
00075 
00076 
00077 
00078 __END_NAMESPACE_SYNAPS
00079 
00080 #endif // SYNAPS_NUMERICS_NUMBER_TRAITS_H
00081 

SYNAPS DOCUMENTATION
logo