realroot_doc 0.1.1
/Users/mourrain/Devel/mmx/realroot/include/realroot/texp_fieldof.hpp
Go to the documentation of this file.
00001 #ifndef realroot_ARITHM_TRAITS_FIELDOF_H
00002 #define realroot_ARITHM_TRAITS_FIELDOF_H
00003 
00004 #include <realroot/texp_sup.hpp>
00005 #include <complex>
00006 namespace mmx {
00007 
00008 namespace texp {
00009 
00010   template<class X, class Y>
00011   struct fieldof_ { typedef texp::null_t T; };
00012   
00013 
00014   template<>
00015   struct fieldof_<int, unsigned int> { typedef double T; };
00016   template<>
00017   struct fieldof_<unsigned int, int> { typedef double T; };
00018   template<>
00019   struct fieldof_<double,int> { typedef double T; };
00020   template<> 
00021   struct fieldof_<int,double> { typedef double T; };
00022   template<>
00023   struct fieldof_<double,unsigned int> { typedef double T; };
00024   template<> 
00025   struct fieldof_<unsigned int,double> { typedef double T; };
00026   
00027 
00028   template<class K, class X, class Y>
00029   struct kernel_fieldof { typedef typename K::rational T; };
00030   template<class K>
00031   struct kernel_fieldof< K, typename K::floating, typename K::ieee > 
00032   { typedef typename K::floating T; };
00033   template<class K>
00034   struct kernel_fieldof< K, typename K::ieee, typename K::floating > 
00035   { typedef typename K::floating T; };
00036   
00037   template<class X, class Y> struct kernel_fieldof<null_t,X,Y> { typedef null_t T; };
00038 
00040   template<class X, class Y> 
00041   struct fieldof
00042   {
00043     typedef typename ucstref<X>::T                _X;
00044     typedef typename ucstref<Y>::T                _Y;
00045     typedef typename kernel_fieldof< typename kernelof<X>::T,_X,_Y>::T   KXY;
00046     typedef typename kernel_fieldof< typename kernelof<Y>::T,_Y,_X>::T   KYX;
00047     typedef typename texp::sfirstnn< typename fieldof_<_X,_Y>::T, KXY, KYX, typename sup<X,Y>::T >::T T;
00048   };
00049   
00050   template<class X, class Y>
00051   struct fieldof_< std::complex<X>, std::complex<Y> > { typedef std::complex<typename fieldof<X,Y>::T > T; };
00052   template<class X>
00053   struct fieldof_< std::complex<X>, std::complex<X> > { typedef std::complex<X> T; };
00054 }
00055 }// end namespace mmx
00056 
00057 #endif