realroot_doc 0.1.1
/Users/mourrain/Devel/mmx/realroot/include/realroot/texp_ringof.hpp
Go to the documentation of this file.
00001 #ifndef realroot_ARITHM_TRAITS_RINGOF_H
00002 #define realroot_ARITHM_TRAITS_RINGOF_H
00003 
00004 #include <realroot/texp_sup.hpp>
00005 
00006 namespace mmx {
00007 
00008 namespace texp {
00009  
00010   template<class X, class Y>
00011   struct ringof_ { typedef null_t T; };
00012   
00013   template<>
00014   struct ringof_<int, unsigned int> { typedef int T; };
00015   template<>
00016   struct ringof_<unsigned int, int> { typedef int T; };
00017   template<>
00018   struct ringof_<double,int> { typedef double T; };
00019   template<> 
00020   struct ringof_<int,double> { typedef double T; };
00021 
00022 
00023   template<class K, class X, class Y>
00024   struct kernel_ringof { typedef null_t T; };
00025   template<class K>
00026   struct kernel_ringof< K, typename K::integer, typename K::ieee  > 
00027   { typedef typename K::ieee T; };
00028   template<class K>
00029   struct kernel_ringof< K, typename K::ieee, typename K::integer > 
00030   { typedef typename K::ieee T; };
00031   template<class K>
00032   struct kernel_ringof< K, typename K::integer, typename K::rational  > 
00033   { typedef typename K::rational T; };
00034   template<class K>
00035   struct kernel_ringof< K, typename K::rational, typename K::integer > 
00036   { typedef typename K::rational T; };
00037   template<class K>
00038   struct kernel_ringof< K, typename K::integer, typename K::floating  > 
00039   { typedef typename K::floating T; };
00040   template<class K>
00041   struct kernel_ringof< K, typename K::floating, typename K::integer > 
00042   { typedef typename K::floating T; };
00043   template<class K>
00044   struct kernel_ringof< K, typename K::floating, typename K::rational >
00045   { typedef typename K::rational T; };
00046   template<class K>
00047   struct kernel_ringof< K, typename K::rational, typename K::floating >
00048   { typedef typename K::rational T; };
00049   template<class K>
00050   struct kernel_ringof< K, typename K::floating, typename K::ieee >
00051   { typedef typename K::floating T; };
00052   template<class K>
00053   struct kernel_ringof< K, typename K::ieee, typename K::floating >
00054   { typedef typename K::floating T; };
00055   template<class K>
00056   struct kernel_ringof< K, typename K::rational, typename K::ieee  > 
00057   { typedef typename K::rational T; };
00058   template<class K>
00059   struct kernel_ringof< K, typename K::ieee, typename K::rational > 
00060   { typedef typename K::rational T; };
00061   
00062   /*
00063   template<class X>
00064   struct ringof_<double, X >
00065   {
00066   typedef typename kernel_ringof< typename kernelof<X>::T, double, X >::T KX;
00067     };
00068   */
00069 
00071   template<class X, class Y> 
00072   struct ringof
00073   {
00076       typedef typename ucstref<X>::T                _X;
00077       typedef typename ucstref<Y>::T                _Y;
00078       typedef typename kernel_ringof< typename kernelof<X>::T,_X,_Y>::T   KXY;
00079       typedef typename kernel_ringof< typename kernelof<Y>::T,_Y,_X>::T   KYX;
00080       typedef typename sfirstnn< typename ringof_<_X,_Y>::T, 
00081                                  KXY, KYX, typename sup<X,Y>::T >::T T;
00082     };
00083 }
00084 }// end namespace mmx
00085 
00086 #endif