ViennaCL - The Vienna Computing Library: viennacl/meta/tag_of.hpp Source File

ViennaCL - The Vienna Computing Library 1.7.1 Free open-source GPU-accelerated linear algebra and solver library. |

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tag_of.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_META_TAGOF_HPP_
2 #define VIENNACL_META_TAGOF_HPP_
3
4 /* =========================================================================
5 Copyright (c) 2010-2016, Institute for Microelectronics,
6 Institute for Analysis and Scientific Computing,
7 TU Wien.
8 Portions of this software are copyright by UChicago Argonne, LLC.
9
10 -----------------
11 ViennaCL - The Vienna Computing Library
12 -----------------
13
14 Project Head: Karl Rupp rupp@iue.tuwien.ac.at
15
16 (A list of authors and contributors can be found in the manual)
17
18 License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20
21
26 #include <vector>
27 #include <map>
28
29 #include "viennacl/forwards.h"
30
31 #ifdef VIENNACL_WITH_UBLAS
32 #include <boost/numeric/ublas/matrix_sparse.hpp>
33 #include <boost/numeric/ublas/matrix.hpp>
34 #include <boost/numeric/ublas/vector.hpp>
35 #endif
36
37 #ifdef VIENNACL_WITH_ARMADILLO
38 #include <armadillo>
39 #endif
40
41 #ifdef VIENNACL_WITH_EIGEN
42 #include <Eigen/Core>
43 #include <Eigen/Sparse>
44 #endif
45
46 #ifdef VIENNACL_WITH_MTL4
47 #include <boost/numeric/mtl/mtl.hpp>
48 #endif
49
50 namespace viennacl
51 {
52
53 // ----------------------------------------------------
54 // TAGS
55 //
57 struct tag_none {};
59 struct tag_mtl4 {};
61 struct tag_eigen {};
63 struct tag_ublas {};
65 struct tag_stl {};
67 struct tag_viennacl {};
68
69 namespace traits
70 {
71 // ----------------------------------------------------
72 // GENERIC BASE
73 //
83 template< typename T, typename Active = void >
84 struct tag_of;
85
87 template< typename Sequence, typename Active >
88 struct tag_of
89 {
90 typedef viennacl::tag_none type;
91 };
92
93 #ifdef VIENNACL_WITH_MTL4
94 // ----------------------------------------------------
95 // MTL4
96 //
97 template<typename ScalarType>
98 struct tag_of< mtl::dense_vector<ScalarType> >
99 {
100 typedef viennacl::tag_mtl4 type;
101 };
102
103 template<typename ScalarType>
104 struct tag_of< mtl::compressed2D<ScalarType> >
105 {
106 typedef viennacl::tag_mtl4 type;
107 };
108
109 template<typename ScalarType, typename T>
110 struct tag_of< mtl::dense2D<ScalarType, T> >
111 {
112 typedef viennacl::tag_mtl4 type;
113 };
114 #endif
115
116
117 #ifdef VIENNACL_WITH_EIGEN
118 // ----------------------------------------------------
119 // Eigen
120 //
121 template<>
122 struct tag_of< Eigen::VectorXf >
123 {
124 typedef viennacl::tag_eigen type;
125 };
126
127 template<>
128 struct tag_of< Eigen::VectorXd >
129 {
130 typedef viennacl::tag_eigen type;
131 };
132
133 template<>
134 struct tag_of< Eigen::MatrixXf >
135 {
136 typedef viennacl::tag_eigen type;
137 };
138
139 template<>
140 struct tag_of< Eigen::MatrixXd >
141 {
142 typedef viennacl::tag_eigen type;
143 };
144
145 template<typename ScalarType, int option>
146 struct tag_of< Eigen::SparseMatrix<ScalarType, option> >
147 {
148 typedef viennacl::tag_eigen type;
149 };
150
151 #endif
152
153 #ifdef VIENNACL_WITH_UBLAS
154 // ----------------------------------------------------
155 // UBLAS
156 //
157 template< typename T >
158 struct tag_of< boost::numeric::ublas::vector<T> >
159 {
160 typedef viennacl::tag_ublas type;
161 };
162
163 template< typename T >
164 struct tag_of< boost::numeric::ublas::matrix<T> >
165 {
166 typedef viennacl::tag_ublas type;
167 };
168
169 template< typename T1, typename T2 >
170 struct tag_of< boost::numeric::ublas::matrix_unary2<T1,T2> >
171 {
172 typedef viennacl::tag_ublas type;
173 };
174
175 template< typename T1, typename T2 >
176 struct tag_of< boost::numeric::ublas::compressed_matrix<T1,T2> >
177 {
178 typedef viennacl::tag_ublas type;
179 };
180
181 #endif
182
183 // ----------------------------------------------------
184 // STL types
185 //
186
187 //vector
188 template< typename T, typename A >
189 struct tag_of< std::vector<T, A> >
190 {
191 typedef viennacl::tag_stl type;
192 };
193
194 //dense matrix
195 template< typename T, typename A >
196 struct tag_of< std::vector<std::vector<T, A>, A> >
197 {
198 typedef viennacl::tag_stl type;
199 };
200
201 //sparse matrix (vector of maps)
202 template< typename KEY, typename DATA, typename COMPARE, typename AMAP, typename AVEC>
203 struct tag_of< std::vector<std::map<KEY, DATA, COMPARE, AMAP>, AVEC> >
204 {
205 typedef viennacl::tag_stl type;
206 };
207
208
209 // ----------------------------------------------------
210 // VIENNACL
211 //
212 template< typename T, unsigned int alignment >
213 struct tag_of< viennacl::vector<T, alignment> >
214 {
215 typedef viennacl::tag_viennacl type;
216 };
217
218 template< typename T, typename F, unsigned int alignment >
219 struct tag_of< viennacl::matrix<T, F, alignment> >
220 {
221 typedef viennacl::tag_viennacl type;
222 };
223
224 template< typename T1, typename T2, typename OP >
225 struct tag_of< viennacl::matrix_expression<T1,T2,OP> >
226 {
227 typedef viennacl::tag_viennacl type;
228 };
229
230 template< typename T >
231 struct tag_of< viennacl::matrix_range<T> >
232 {
233 typedef viennacl::tag_viennacl type;
234 };
235
236 template< typename T, unsigned int I>
237 struct tag_of< viennacl::compressed_matrix<T,I> >
238 {
239 typedef viennacl::tag_viennacl type;
240 };
241
242 template< typename T, unsigned int I>
243 struct tag_of< viennacl::coordinate_matrix<T,I> >
244 {
245 typedef viennacl::tag_viennacl type;
246 };
247
248 template< typename T, unsigned int I>
249 struct tag_of< viennacl::ell_matrix<T,I> >
250 {
251 typedef viennacl::tag_viennacl type;
252 };
253
254 template< typename T, typename I>
255 struct tag_of< viennacl::sliced_ell_matrix<T,I> >
256 {
257 typedef viennacl::tag_viennacl type;
258 };
259
260
261 template< typename T, unsigned int I>
262 struct tag_of< viennacl::hyb_matrix<T,I> >
263 {
264 typedef viennacl::tag_viennacl type;
265 };
266
267 template< typename T, unsigned int I>
268 struct tag_of< viennacl::circulant_matrix<T,I> >
269 {
270 typedef viennacl::tag_viennacl type;
271 };
272
273 template< typename T, unsigned int I>
274 struct tag_of< viennacl::hankel_matrix<T,I> >
275 {
276 typedef viennacl::tag_viennacl type;
277 };
278
279 template< typename T, unsigned int I>
280 struct tag_of< viennacl::toeplitz_matrix<T,I> >
281 {
282 typedef viennacl::tag_viennacl type;
283 };
284
285 template< typename T, unsigned int I>
286 struct tag_of< viennacl::vandermonde_matrix<T,I> >
287 {
288 typedef viennacl::tag_viennacl type;
289 };
292 // ----------------------------------------------------
293 } // end namespace traits
294
295
300 template<typename Tag>
301 struct is_mtl4
302 {
303 enum { value = false };
304 };
305
307 template<>
308 struct is_mtl4< viennacl::tag_mtl4 >
309 {
310 enum { value = true };
311 };
318 template<typename Tag>
319 struct is_eigen
320 {
321 enum { value = false };
322 };
323
325 template<>
326 struct is_eigen< viennacl::tag_eigen >
327 {
328 enum { value = true };
329 };
337 template<typename Tag>
338 struct is_ublas
339 {
340 enum { value = false };
341 };
342
344 template<>
345 struct is_ublas< viennacl::tag_ublas >
346 {
347 enum { value = true };
348 };
355 template<typename Tag>
356 struct is_stl
357 {
358 enum { value = false };
359 };
360
362 template<>
363 struct is_stl< viennacl::tag_stl >
364 {
365 enum { value = true };
366 };
374 template<typename Tag>
375 struct is_viennacl
376 {
377 enum { value = false };
378 };
379
381 template<>
382 struct is_viennacl< viennacl::tag_viennacl >
383 {
384 enum { value = true };
385 };
388 } // end namespace viennacl
389
390 #endif
viennacl::is_mtl4
Meta function which checks whether a tag is tag_mtl4.
Definition: tag_of.hpp:301
viennacl::traits::tag_of
Generic base for wrapping other linear algebra packages.
Definition: tag_of.hpp:84
viennacl::is_stl::value
Definition: tag_of.hpp:358
viennacl::is_stl
Meta function which checks whether a tag is tag_ublas.
Definition: tag_of.hpp:356
viennacl::is_ublas
Meta function which checks whether a tag is tag_ublas.
Definition: tag_of.hpp:338
viennacl::tag_none
A tag class for identifying 'unknown' types.
Definition: tag_of.hpp:57
forwards.h
This file provides the forward declarations for the main types used within ViennaCL.
viennacl::tag_ublas
A tag class for identifying types from uBLAS.
Definition: tag_of.hpp:63
viennacl::is_viennacl
Meta function which checks whether a tag is tag_viennacl.
Definition: tag_of.hpp:375
viennacl::is_mtl4::value
Definition: tag_of.hpp:303
viennacl::tag_viennacl
A tag class for identifying types from ViennaCL.
Definition: tag_of.hpp:67
viennacl::is_ublas::value
Definition: tag_of.hpp:340
viennacl::tag_stl
A tag class for identifying types from the C++ STL.
Definition: tag_of.hpp:65
viennacl::is_eigen::value
Definition: tag_of.hpp:321
viennacl::tag_eigen
A tag class for identifying types from Eigen.
Definition: tag_of.hpp:61
viennacl::tag_mtl4
A tag class for identifying types from MTL4.
Definition: tag_of.hpp:59
viennacl::is_eigen
Meta function which checks whether a tag is tag_eigen.
Definition: tag_of.hpp:319
viennacl::is_viennacl::value
Definition: tag_of.hpp:377