00001 #ifndef VIENNACL_META_TAGOF_HPP_
00002 #define VIENNACL_META_TAGOF_HPP_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00025 #ifdef VIENNACL_HAVE_UBLAS
00026 #include <boost/numeric/ublas/matrix_sparse.hpp>
00027 #include <boost/numeric/ublas/matrix.hpp>
00028 #include <boost/numeric/ublas/vector.hpp>
00029 #endif
00030
00031 #ifdef VIENNACL_HAVE_EIGEN
00032 #include <Eigen/Core>
00033 #include <Eigen/Sparse>
00034 #endif
00035
00036 #ifdef VIENNACL_HAVE_MTL4
00037 #include <boost/numeric/mtl/mtl.hpp>
00038 #endif
00039
00040 namespace viennacl
00041 {
00042
00043
00044
00045
00046 struct tag_none {};
00047 struct tag_mtl4 {};
00048 struct tag_eigen {};
00049 struct tag_ublas {};
00050 struct tag_stl {};
00051 struct tag_viennacl {};
00052
00053 namespace traits
00054 {
00055
00056
00057
00067 template< typename T, typename Active = void >
00068 struct tag_of;
00069
00070 template < typename Sequence, typename Active >
00071 struct tag_of
00072 {
00073 typedef viennacl::tag_none type;
00074 };
00075
00076 #ifdef VIENNACL_HAVE_MTL4
00077
00078
00079
00080 template <typename ScalarType>
00081 struct tag_of< mtl::dense_vector<ScalarType> >
00082 {
00083 typedef viennacl::tag_mtl4 type;
00084 };
00085
00086 template <typename ScalarType>
00087 struct tag_of< mtl::compressed2D<ScalarType> >
00088 {
00089 typedef viennacl::tag_mtl4 type;
00090 };
00091
00092 template <typename ScalarType, typename T>
00093 struct tag_of< mtl::dense2D<ScalarType, T> >
00094 {
00095 typedef viennacl::tag_mtl4 type;
00096 };
00097 #endif
00098
00099
00100 #ifdef VIENNACL_HAVE_EIGEN
00101
00102
00103
00104 template <>
00105 struct tag_of< Eigen::VectorXf >
00106 {
00107 typedef viennacl::tag_eigen type;
00108 };
00109
00110 template <>
00111 struct tag_of< Eigen::VectorXd >
00112 {
00113 typedef viennacl::tag_eigen type;
00114 };
00115
00116 template <>
00117 struct tag_of< Eigen::MatrixXf >
00118 {
00119 typedef viennacl::tag_eigen type;
00120 };
00121
00122 template <>
00123 struct tag_of< Eigen::MatrixXd >
00124 {
00125 typedef viennacl::tag_eigen type;
00126 };
00127
00128 template <typename ScalarType, int option>
00129 struct tag_of< Eigen::SparseMatrix<ScalarType, option> >
00130 {
00131 typedef viennacl::tag_eigen type;
00132 };
00133
00134 #endif
00135
00136 #ifdef VIENNACL_HAVE_UBLAS
00137
00138
00139
00140 template< typename T >
00141 struct tag_of< boost::numeric::ublas::vector<T> >
00142 {
00143 typedef viennacl::tag_ublas type;
00144 };
00145
00146 template< typename T >
00147 struct tag_of< boost::numeric::ublas::matrix<T> >
00148 {
00149 typedef viennacl::tag_ublas type;
00150 };
00151
00152 template< typename T1, typename T2 >
00153 struct tag_of< boost::numeric::ublas::matrix_unary2<T1,T2> >
00154 {
00155 typedef viennacl::tag_ublas type;
00156 };
00157
00158 template< typename T1, typename T2 >
00159 struct tag_of< boost::numeric::ublas::compressed_matrix<T1,T2> >
00160 {
00161 typedef viennacl::tag_ublas type;
00162 };
00163
00164 #endif
00165
00166
00167
00168
00169
00170
00171 template< typename T, typename A >
00172 struct tag_of< std::vector<T, A> >
00173 {
00174 typedef viennacl::tag_stl type;
00175 };
00176
00177
00178 template< typename T, typename A >
00179 struct tag_of< std::vector<std::vector<T, A>, A> >
00180 {
00181 typedef viennacl::tag_stl type;
00182 };
00183
00184
00185 template< typename KEY, typename DATA, typename COMPARE, typename AMAP, typename AVEC>
00186 struct tag_of< std::vector<std::map<KEY, DATA, COMPARE, AMAP>, AVEC> >
00187 {
00188 typedef viennacl::tag_stl type;
00189 };
00190
00191
00192
00193
00194
00195 template< typename T, unsigned int alignment >
00196 struct tag_of< viennacl::vector<T, alignment> >
00197 {
00198 typedef viennacl::tag_viennacl type;
00199 };
00200
00201 template< typename T, typename F, unsigned int alignment >
00202 struct tag_of< viennacl::matrix<T, F, alignment> >
00203 {
00204 typedef viennacl::tag_viennacl type;
00205 };
00206
00207 template< typename T1, typename T2, typename OP >
00208 struct tag_of< viennacl::matrix_expression<T1,T2,OP> >
00209 {
00210 typedef viennacl::tag_viennacl type;
00211 };
00212
00213 template< typename T >
00214 struct tag_of< viennacl::matrix_range<T> >
00215 {
00216 typedef viennacl::tag_viennacl type;
00217 };
00218
00219 template< typename T, unsigned int I>
00220 struct tag_of< viennacl::compressed_matrix<T,I> >
00221 {
00222 typedef viennacl::tag_viennacl type;
00223 };
00224
00225 template< typename T, unsigned int I>
00226 struct tag_of< viennacl::coordinate_matrix<T,I> >
00227 {
00228 typedef viennacl::tag_viennacl type;
00229 };
00230
00231 template< typename T, unsigned int I>
00232 struct tag_of< viennacl::circulant_matrix<T,I> >
00233 {
00234 typedef viennacl::tag_viennacl type;
00235 };
00236
00237 template< typename T, unsigned int I>
00238 struct tag_of< viennacl::hankel_matrix<T,I> >
00239 {
00240 typedef viennacl::tag_viennacl type;
00241 };
00242
00243 template< typename T, unsigned int I>
00244 struct tag_of< viennacl::toeplitz_matrix<T,I> >
00245 {
00246 typedef viennacl::tag_viennacl type;
00247 };
00248
00249 template< typename T, unsigned int I>
00250 struct tag_of< viennacl::vandermonde_matrix<T,I> >
00251 {
00252 typedef viennacl::tag_viennacl type;
00253 };
00254
00255
00256
00257 }
00258
00259
00264 template <typename Tag>
00265 struct is_mtl4
00266 {
00267 enum { value = false };
00268 };
00269
00270 template <>
00271 struct is_mtl4< viennacl::tag_mtl4 >
00272 {
00273 enum { value = true };
00274 };
00275
00280 template <typename Tag>
00281 struct is_eigen
00282 {
00283 enum { value = false };
00284 };
00285
00286 template <>
00287 struct is_eigen< viennacl::tag_eigen >
00288 {
00289 enum { value = true };
00290 };
00291
00292
00297 template <typename Tag>
00298 struct is_ublas
00299 {
00300 enum { value = false };
00301 };
00302
00303 template <>
00304 struct is_ublas< viennacl::tag_ublas >
00305 {
00306 enum { value = true };
00307 };
00308
00313 template <typename Tag>
00314 struct is_stl
00315 {
00316 enum { value = false };
00317 };
00318
00319 template <>
00320 struct is_stl< viennacl::tag_stl >
00321 {
00322 enum { value = true };
00323 };
00324
00325
00330 template <typename Tag>
00331 struct is_viennacl
00332 {
00333 enum { value = false };
00334 };
00335
00336 template <>
00337 struct is_viennacl< viennacl::tag_viennacl >
00338 {
00339 enum { value = true };
00340 };
00341
00342 }
00343
00344 #endif