|
ViennaCL - The Vienna Computing Library
1.4.2
|
00001 #ifndef VIENNACL_META_TAGOF_HPP_ 00002 #define VIENNACL_META_TAGOF_HPP_ 00003 00004 /* ========================================================================= 00005 Copyright (c) 2010-2013, Institute for Microelectronics, 00006 Institute for Analysis and Scientific Computing, 00007 TU Wien. 00008 Portions of this software are copyright by UChicago Argonne, LLC. 00009 00010 ----------------- 00011 ViennaCL - The Vienna Computing Library 00012 ----------------- 00013 00014 Project Head: Karl Rupp rupp@iue.tuwien.ac.at 00015 00016 (A list of authors and contributors can be found in the PDF manual) 00017 00018 License: MIT (X11), see file LICENSE in the base directory 00019 ============================================================================= */ 00020 00021 00026 #ifdef VIENNACL_WITH_UBLAS 00027 #include <boost/numeric/ublas/matrix_sparse.hpp> 00028 #include <boost/numeric/ublas/matrix.hpp> 00029 #include <boost/numeric/ublas/vector.hpp> 00030 #endif 00031 00032 #ifdef VIENNACL_WITH_EIGEN 00033 #include <Eigen/Core> 00034 #include <Eigen/Sparse> 00035 #endif 00036 00037 #ifdef VIENNACL_WITH_MTL4 00038 #include <boost/numeric/mtl/mtl.hpp> 00039 #endif 00040 00041 namespace viennacl 00042 { 00043 00044 // ---------------------------------------------------- 00045 // TAGS 00046 // 00047 struct tag_none {}; 00048 struct tag_mtl4 {}; 00049 struct tag_eigen {}; 00050 struct tag_ublas {}; 00051 struct tag_stl {}; 00052 struct tag_viennacl {}; 00053 00054 namespace traits 00055 { 00056 // ---------------------------------------------------- 00057 // GENERIC BASE 00058 // 00068 template< typename T, typename Active = void > 00069 struct tag_of; 00070 00071 template < typename Sequence, typename Active > 00072 struct tag_of 00073 { 00074 typedef viennacl::tag_none type; 00075 }; 00076 00077 #ifdef VIENNACL_WITH_MTL4 00078 // ---------------------------------------------------- 00079 // MTL4 00080 // 00081 template <typename ScalarType> 00082 struct tag_of< mtl::dense_vector<ScalarType> > 00083 { 00084 typedef viennacl::tag_mtl4 type; 00085 }; 00086 00087 template <typename ScalarType> 00088 struct tag_of< mtl::compressed2D<ScalarType> > 00089 { 00090 typedef viennacl::tag_mtl4 type; 00091 }; 00092 00093 template <typename ScalarType, typename T> 00094 struct tag_of< mtl::dense2D<ScalarType, T> > 00095 { 00096 typedef viennacl::tag_mtl4 type; 00097 }; 00098 #endif 00099 00100 00101 #ifdef VIENNACL_WITH_EIGEN 00102 // ---------------------------------------------------- 00103 // Eigen 00104 // 00105 template <> 00106 struct tag_of< Eigen::VectorXf > 00107 { 00108 typedef viennacl::tag_eigen type; 00109 }; 00110 00111 template <> 00112 struct tag_of< Eigen::VectorXd > 00113 { 00114 typedef viennacl::tag_eigen type; 00115 }; 00116 00117 template <> 00118 struct tag_of< Eigen::MatrixXf > 00119 { 00120 typedef viennacl::tag_eigen type; 00121 }; 00122 00123 template <> 00124 struct tag_of< Eigen::MatrixXd > 00125 { 00126 typedef viennacl::tag_eigen type; 00127 }; 00128 00129 template <typename ScalarType, int option> 00130 struct tag_of< Eigen::SparseMatrix<ScalarType, option> > 00131 { 00132 typedef viennacl::tag_eigen type; 00133 }; 00134 00135 #endif 00136 00137 #ifdef VIENNACL_WITH_UBLAS 00138 // ---------------------------------------------------- 00139 // UBLAS 00140 // 00141 template< typename T > 00142 struct tag_of< boost::numeric::ublas::vector<T> > 00143 { 00144 typedef viennacl::tag_ublas type; 00145 }; 00146 00147 template< typename T > 00148 struct tag_of< boost::numeric::ublas::matrix<T> > 00149 { 00150 typedef viennacl::tag_ublas type; 00151 }; 00152 00153 template< typename T1, typename T2 > 00154 struct tag_of< boost::numeric::ublas::matrix_unary2<T1,T2> > 00155 { 00156 typedef viennacl::tag_ublas type; 00157 }; 00158 00159 template< typename T1, typename T2 > 00160 struct tag_of< boost::numeric::ublas::compressed_matrix<T1,T2> > 00161 { 00162 typedef viennacl::tag_ublas type; 00163 }; 00164 00165 #endif 00166 00167 // ---------------------------------------------------- 00168 // STL types 00169 // 00170 00171 //vector 00172 template< typename T, typename A > 00173 struct tag_of< std::vector<T, A> > 00174 { 00175 typedef viennacl::tag_stl type; 00176 }; 00177 00178 //dense matrix 00179 template< typename T, typename A > 00180 struct tag_of< std::vector<std::vector<T, A>, A> > 00181 { 00182 typedef viennacl::tag_stl type; 00183 }; 00184 00185 //sparse matrix (vector of maps) 00186 template< typename KEY, typename DATA, typename COMPARE, typename AMAP, typename AVEC> 00187 struct tag_of< std::vector<std::map<KEY, DATA, COMPARE, AMAP>, AVEC> > 00188 { 00189 typedef viennacl::tag_stl type; 00190 }; 00191 00192 00193 // ---------------------------------------------------- 00194 // VIENNACL 00195 // 00196 template< typename T, unsigned int alignment > 00197 struct tag_of< viennacl::vector<T, alignment> > 00198 { 00199 typedef viennacl::tag_viennacl type; 00200 }; 00201 00202 template< typename T, typename F, unsigned int alignment > 00203 struct tag_of< viennacl::matrix<T, F, alignment> > 00204 { 00205 typedef viennacl::tag_viennacl type; 00206 }; 00207 00208 template< typename T1, typename T2, typename OP > 00209 struct tag_of< viennacl::matrix_expression<T1,T2,OP> > 00210 { 00211 typedef viennacl::tag_viennacl type; 00212 }; 00213 00214 template< typename T > 00215 struct tag_of< viennacl::matrix_range<T> > 00216 { 00217 typedef viennacl::tag_viennacl type; 00218 }; 00219 00220 template< typename T, unsigned int I> 00221 struct tag_of< viennacl::compressed_matrix<T,I> > 00222 { 00223 typedef viennacl::tag_viennacl type; 00224 }; 00225 00226 template< typename T, unsigned int I> 00227 struct tag_of< viennacl::coordinate_matrix<T,I> > 00228 { 00229 typedef viennacl::tag_viennacl type; 00230 }; 00231 00232 template< typename T, unsigned int I> 00233 struct tag_of< viennacl::ell_matrix<T,I> > 00234 { 00235 typedef viennacl::tag_viennacl type; 00236 }; 00237 00238 template< typename T, unsigned int I> 00239 struct tag_of< viennacl::hyb_matrix<T,I> > 00240 { 00241 typedef viennacl::tag_viennacl type; 00242 }; 00243 00244 template< typename T, unsigned int I> 00245 struct tag_of< viennacl::circulant_matrix<T,I> > 00246 { 00247 typedef viennacl::tag_viennacl type; 00248 }; 00249 00250 template< typename T, unsigned int I> 00251 struct tag_of< viennacl::hankel_matrix<T,I> > 00252 { 00253 typedef viennacl::tag_viennacl type; 00254 }; 00255 00256 template< typename T, unsigned int I> 00257 struct tag_of< viennacl::toeplitz_matrix<T,I> > 00258 { 00259 typedef viennacl::tag_viennacl type; 00260 }; 00261 00262 template< typename T, unsigned int I> 00263 struct tag_of< viennacl::vandermonde_matrix<T,I> > 00264 { 00265 typedef viennacl::tag_viennacl type; 00266 }; 00267 00268 00269 // ---------------------------------------------------- 00270 } // end namespace traits 00271 00272 00277 template <typename Tag> 00278 struct is_mtl4 00279 { 00280 enum { value = false }; 00281 }; 00282 00283 template <> 00284 struct is_mtl4< viennacl::tag_mtl4 > 00285 { 00286 enum { value = true }; 00287 }; 00288 00293 template <typename Tag> 00294 struct is_eigen 00295 { 00296 enum { value = false }; 00297 }; 00298 00299 template <> 00300 struct is_eigen< viennacl::tag_eigen > 00301 { 00302 enum { value = true }; 00303 }; 00304 00305 00310 template <typename Tag> 00311 struct is_ublas 00312 { 00313 enum { value = false }; 00314 }; 00315 00316 template <> 00317 struct is_ublas< viennacl::tag_ublas > 00318 { 00319 enum { value = true }; 00320 }; 00321 00326 template <typename Tag> 00327 struct is_stl 00328 { 00329 enum { value = false }; 00330 }; 00331 00332 template <> 00333 struct is_stl< viennacl::tag_stl > 00334 { 00335 enum { value = true }; 00336 }; 00337 00338 00343 template <typename Tag> 00344 struct is_viennacl 00345 { 00346 enum { value = false }; 00347 }; 00348 00349 template <> 00350 struct is_viennacl< viennacl::tag_viennacl > 00351 { 00352 enum { value = true }; 00353 }; 00354 00355 } // end namespace viennacl 00356 00357 #endif
1.7.6.1