• Main Page
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

/data/development/ViennaCL/ViennaCL-1.1.2/viennacl/linalg/tag_of.hpp

Go to the documentation of this file.
00001 /* =======================================================================
00002    Copyright (c) 2010, Institute for Microelectronics, TU Vienna.
00003    http://www.iue.tuwien.ac.at
00004                              -----------------
00005                      ViennaCL - The Vienna Computing Library
00006                              -----------------
00007                             
00008    authors:    Karl Rupp                          rupp@iue.tuwien.ac.at
00009                Florian Rudolf                     flo.rudy+viennacl@gmail.com
00010                Josef Weinbub                      weinbub@iue.tuwien.ac.at
00011 
00012    license:    MIT (X11), see file LICENSE in the ViennaCL base directory
00013 ======================================================================= */
00014 
00015 
00016 #ifndef _VIENNACL_TAGOF_HPP_
00017 #define _VIENNACL_TAGOF_HPP_
00018 
00023 #ifdef VIENNACL_HAVE_UBLAS  
00024 #include <boost/numeric/ublas/matrix_sparse.hpp>
00025 #include <boost/numeric/ublas/matrix.hpp>
00026 #include <boost/numeric/ublas/vector.hpp>
00027 #endif
00028 
00029 #ifdef VIENNACL_HAVE_EIGEN  
00030 #include <Eigen/Core>
00031 #include <Eigen/Sparse>
00032 #endif
00033 
00034 #ifdef VIENNACL_HAVE_MTL4
00035 #include <boost/numeric/mtl/mtl.hpp>
00036 #endif
00037 
00038 namespace viennacl
00039 {
00040 
00041   // ----------------------------------------------------
00042   // TAGS
00043   //
00044   struct tag_none     {};
00045   struct tag_mtl4     {};
00046   struct tag_eigen    {};
00047   struct tag_ublas    {};
00048   struct tag_stl      {};
00049   struct tag_viennacl {};
00050 
00051   namespace traits
00052   {
00053     // ----------------------------------------------------
00054     // GENERIC BASE
00055     //
00065     template< typename T, typename Active = void >
00066     struct tag_of;
00067    
00068     template < typename Sequence, typename Active >
00069     struct tag_of
00070     {
00071       typedef viennacl::tag_none  type;
00072     };
00073     
00074     #ifdef VIENNACL_HAVE_MTL4
00075     // ----------------------------------------------------
00076     // MTL4
00077     //
00078     template <typename ScalarType>
00079     struct tag_of< mtl::dense_vector<ScalarType> >
00080     {
00081       typedef viennacl::tag_mtl4  type;
00082     };
00083 
00084     template <typename ScalarType>
00085     struct tag_of< mtl::compressed2D<ScalarType> >
00086     {
00087       typedef viennacl::tag_mtl4  type;
00088     };
00089 
00090     template <typename ScalarType, typename T>
00091     struct tag_of< mtl::dense2D<ScalarType, T> >
00092     {
00093       typedef viennacl::tag_mtl4  type;
00094     };
00095     #endif
00096     
00097     
00098     #ifdef VIENNACL_HAVE_EIGEN
00099     // ----------------------------------------------------
00100     // Eigen
00101     //
00102     template <>
00103     struct tag_of< Eigen::VectorXf >
00104     {
00105       typedef viennacl::tag_eigen  type;
00106     };
00107 
00108     template <>
00109     struct tag_of< Eigen::VectorXd >
00110     {
00111       typedef viennacl::tag_eigen  type;
00112     };
00113 
00114     template <>
00115     struct tag_of< Eigen::MatrixXf >
00116     {
00117       typedef viennacl::tag_eigen  type;
00118     };
00119 
00120     template <>
00121     struct tag_of< Eigen::MatrixXd >
00122     {
00123       typedef viennacl::tag_eigen  type;
00124     };
00125 
00126     template <typename ScalarType, int option>
00127     struct tag_of< Eigen::SparseMatrix<ScalarType, option> >
00128     {
00129       typedef viennacl::tag_eigen  type;
00130     };
00131     
00132     #endif
00133     
00134     #ifdef VIENNACL_HAVE_UBLAS
00135     // ----------------------------------------------------
00136     // UBLAS
00137     //
00138     template< typename T >
00139     struct tag_of< boost::numeric::ublas::vector<T> >
00140     {
00141       typedef viennacl::tag_ublas  type;
00142     };
00143 
00144     template< typename T >
00145     struct tag_of< boost::numeric::ublas::matrix<T> >
00146     {
00147       typedef viennacl::tag_ublas  type;
00148     };
00149 
00150     template< typename T1, typename T2 >
00151     struct tag_of< boost::numeric::ublas::matrix_unary2<T1,T2> >
00152     {
00153       typedef viennacl::tag_ublas  type;
00154     };
00155 
00156     template< typename T1, typename T2 >
00157     struct tag_of< boost::numeric::ublas::compressed_matrix<T1,T2> >
00158     {
00159       typedef viennacl::tag_ublas  type;
00160     };
00161     
00162     #endif
00163 
00164     // ----------------------------------------------------
00165     // STL types
00166     //
00167     
00168     //vector
00169     template< typename T, typename A >
00170     struct tag_of< std::vector<T, A> >
00171     {
00172       typedef viennacl::tag_stl  type;
00173     };
00174 
00175     //dense matrix
00176     template< typename T, typename A >
00177     struct tag_of< std::vector<std::vector<T, A>, A> >
00178     {
00179       typedef viennacl::tag_stl  type;
00180     };
00181 
00182     //sparse matrix (vector of maps)
00183     template< typename KEY, typename DATA, typename COMPARE, typename AMAP, typename AVEC>
00184     struct tag_of< std::vector<std::map<KEY, DATA, COMPARE, AMAP>, AVEC> >
00185     {
00186       typedef viennacl::tag_stl  type;
00187     };
00188     
00189     
00190     // ----------------------------------------------------
00191     // VIENNACL
00192     //
00193     template< typename T, unsigned int alignment >
00194     struct tag_of< viennacl::vector<T, alignment> >
00195     {
00196       typedef viennacl::tag_viennacl  type;
00197     };
00198 
00199     template< typename T, typename F, unsigned int alignment >
00200     struct tag_of< viennacl::matrix<T, F, alignment> >
00201     {
00202       typedef viennacl::tag_viennacl  type;
00203     };
00204 
00205     template< typename T1, typename T2, typename OP >
00206     struct tag_of< viennacl::matrix_expression<T1,T2,OP> >
00207     {
00208       typedef viennacl::tag_viennacl  type;
00209     };
00210 
00211     template< typename T, unsigned int I>
00212     struct tag_of< viennacl::compressed_matrix<T,I> >
00213     {
00214       typedef viennacl::tag_viennacl  type;
00215     };
00216 
00217     template< typename T, unsigned int I>
00218     struct tag_of< viennacl::coordinate_matrix<T,I> >
00219     {
00220       typedef viennacl::tag_viennacl  type;
00221     };
00222     // ----------------------------------------------------
00223   } // end namespace traits
00224 
00225 
00230   template <typename Tag>
00231   struct is_mtl4
00232   {
00233      enum { value = false };  
00234   };
00235 
00236   template <>
00237   struct is_mtl4< viennacl::tag_mtl4 >
00238   {
00239      enum { value = true };  
00240   };
00241 
00246   template <typename Tag>
00247   struct is_eigen
00248   {
00249      enum { value = false };  
00250   };
00251 
00252   template <>
00253   struct is_eigen< viennacl::tag_eigen >
00254   {
00255      enum { value = true };  
00256   };
00257 
00258 
00263   template <typename Tag>
00264   struct is_ublas
00265   {
00266      enum { value = false };  
00267   };
00268 
00269   template <>
00270   struct is_ublas< viennacl::tag_ublas >
00271   {
00272      enum { value = true };  
00273   };
00274 
00279   template <typename Tag>
00280   struct is_stl
00281   {
00282      enum { value = false };  
00283   };
00284 
00285   template <>
00286   struct is_stl< viennacl::tag_stl >
00287   {
00288      enum { value = true };  
00289   };
00290 
00291   
00296   template <typename Tag>
00297   struct is_viennacl
00298   {
00299      enum { value = false };  
00300   };
00301 
00302   template <>
00303   struct is_viennacl< viennacl::tag_viennacl >
00304   {
00305      enum { value = true };  
00306   };
00307 
00308 } // end namespace viennacl
00309 
00310 #endif

Generated on Sat May 21 2011 20:36:50 for ViennaCL - The Vienna Computing Library by  doxygen 1.7.1