1 #ifndef VIENNACL_META_RESULT_OF_HPP_
2 #define VIENNACL_META_RESULT_OF_HPP_
31 #ifdef VIENNACL_WITH_UBLAS
32 #include <boost/numeric/ublas/matrix_sparse.hpp>
33 #include <boost/numeric/ublas/matrix.hpp>
36 #ifdef VIENNACL_WITH_EIGEN
38 #include <Eigen/Sparse>
41 #ifdef VIENNACL_WITH_MTL4
42 #include <boost/numeric/mtl/mtl.hpp>
45 #ifdef VIENNACL_WITH_OPENCL
47 #include <OpenCL/cl.h>
67 typedef typename T::ERROR_ARGUMENT_PROVIDED_IS_NOT_A_VECTOR_OR_A_MATRIX
error_type;
73 struct alignment<const T>
75 enum {
value = alignment<T>::value };
78 template <
typename SCALARTYPE,
unsigned int ALIGNMENT>
79 struct alignment< vector<SCALARTYPE, ALIGNMENT> >
81 enum {
value = ALIGNMENT };
85 struct alignment< vector_range<T> >
87 enum {
value = alignment<T>::value };
91 struct alignment< vector_slice<T> >
93 enum {
value = alignment<T>::value };
97 template <
typename LHS,
typename RHS,
typename OP>
98 struct alignment< vector_expression<LHS, RHS, OP> >
100 enum {
value = alignment<LHS>::value };
105 template <
typename SCALARTYPE,
typename F,
unsigned int ALIGNMENT>
106 struct alignment< matrix<SCALARTYPE, F, ALIGNMENT> >
108 enum {
value = ALIGNMENT };
111 template <
typename T>
112 struct alignment< matrix_range<T> >
114 enum {
value = alignment<T>::value };
117 template <
typename T>
118 struct alignment< matrix_slice<T> >
120 enum {
value = alignment<T>::value };
123 template <
typename LHS,
typename RHS>
124 struct alignment< matrix_expression<LHS, RHS, op_trans> >
126 enum {
value = alignment<LHS>::value };
134 template <
typename T>
137 typedef typename T::ERROR_ARGUMENT_PROVIDED_IS_NOT_A_MATRIX
type;
141 template <
typename T>
147 template <
typename SCALARTYPE,
typename F,
unsigned int ALIGNMENT>
148 struct orientation_functor<
matrix<SCALARTYPE, F, ALIGNMENT> >
153 template <
typename T>
154 struct orientation_functor< matrix_range<T> >
156 typedef typename orientation_functor<T>::type
type;
159 template <
typename T>
160 struct orientation_functor< matrix_slice<T> >
162 typedef typename orientation_functor<T>::type
type;
165 template <
typename SCALARTYPE,
typename F>
166 struct orientation_functor< matrix_base<SCALARTYPE, F> >
171 template <
typename LHS,
typename RHS>
172 struct orientation_functor< matrix_expression<LHS, RHS, op_trans> >
174 typedef typename orientation_functor<LHS>::type
type;
183 template <
typename T>
186 typedef typename T::size_type
type;
190 template <
typename T,
typename SizeType>
193 typedef SizeType
type;
196 #ifdef VIENNACL_WITH_EIGEN
197 template <
class T,
int a,
int b,
int c,
int d,
int e>
198 struct size_type< Eigen::Matrix<T, a, b, c, d, e> >
204 struct size_type<Eigen::VectorXf>
210 struct size_type<Eigen::VectorXd>
215 template <
typename T,
int options>
216 struct size_type<Eigen::SparseMatrix<T, options> >
227 template <
typename T>
230 typedef typename T::value_type
type;
234 #ifdef VIENNACL_WITH_EIGEN
238 typedef Eigen::MatrixXf::RealScalar
type;
242 struct value_type<Eigen::MatrixXd>
244 typedef Eigen::MatrixXd::RealScalar
type;
247 template <
typename ScalarType,
int option>
248 struct value_type<Eigen::SparseMatrix<ScalarType, option> >
250 typedef ScalarType
type;
254 struct value_type<Eigen::VectorXf>
256 typedef Eigen::VectorXf::RealScalar
type;
260 struct value_type<Eigen::VectorXd>
262 typedef Eigen::VectorXd::RealScalar
type;
273 template <
typename T>
276 typedef typename T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T
type;
280 template <
typename T>
287 struct cpu_value_type<char>
293 struct cpu_value_type<unsigned char>
295 typedef unsigned char type;
299 struct cpu_value_type<short>
305 struct cpu_value_type<unsigned short>
307 typedef unsigned short type;
311 struct cpu_value_type<int>
317 struct cpu_value_type<unsigned int>
319 typedef unsigned int type;
323 struct cpu_value_type<long>
329 struct cpu_value_type<unsigned long>
331 typedef unsigned long type;
336 struct cpu_value_type<float>
342 struct cpu_value_type<double>
347 template <
typename T>
348 struct cpu_value_type<viennacl::scalar<T> >
353 template <
typename T>
354 struct cpu_value_type<viennacl::vector_base<T> >
359 template <
typename T>
360 struct cpu_value_type<viennacl::implicit_vector_base<T> >
366 template <
typename T,
unsigned int ALIGNMENT>
367 struct cpu_value_type<viennacl::vector<T, ALIGNMENT> >
372 template <
typename T>
373 struct cpu_value_type<viennacl::vector_range<T> >
375 typedef typename cpu_value_type<T>::type
type;
378 template <
typename T>
379 struct cpu_value_type<viennacl::vector_slice<T> >
381 typedef typename cpu_value_type<T>::type
type;
384 template <
typename T1,
typename T2,
typename OP>
385 struct cpu_value_type<viennacl::vector_expression<const T1, const T2, OP> >
387 typedef typename cpu_value_type<T1>::type
type;
390 template <
typename T1,
typename T2,
typename OP>
391 struct cpu_value_type<const viennacl::vector_expression<const T1, const T2, OP> >
393 typedef typename cpu_value_type<T1>::type
type;
397 template <
typename T,
typename F>
398 struct cpu_value_type<viennacl::matrix_base<T, F> >
403 template <
typename T>
404 struct cpu_value_type<viennacl::implicit_matrix_base<T> >
410 template <
typename T,
typename F,
unsigned int ALIGNMENT>
411 struct cpu_value_type<viennacl::matrix<T, F, ALIGNMENT> >
416 template <
typename T>
417 struct cpu_value_type<viennacl::matrix_range<T> >
419 typedef typename cpu_value_type<T>::type
type;
422 template <
typename T>
423 struct cpu_value_type<viennacl::matrix_slice<T> >
425 typedef typename cpu_value_type<T>::type
type;
428 template <
typename T,
unsigned int ALIGNMENT>
429 struct cpu_value_type<viennacl::compressed_matrix<T, ALIGNMENT> >
431 typedef typename cpu_value_type<T>::type
type;
434 template <
typename T>
435 struct cpu_value_type<viennacl::compressed_compressed_matrix<T> >
437 typedef typename cpu_value_type<T>::type
type;
440 template <
typename T,
unsigned int ALIGNMENT>
441 struct cpu_value_type<viennacl::coordinate_matrix<T, ALIGNMENT> >
443 typedef typename cpu_value_type<T>::type
type;
446 template <
typename T,
unsigned int ALIGNMENT>
447 struct cpu_value_type<viennacl::ell_matrix<T, ALIGNMENT> >
449 typedef typename cpu_value_type<T>::type
type;
452 template <
typename T,
unsigned int ALIGNMENT>
453 struct cpu_value_type<viennacl::hyb_matrix<T, ALIGNMENT> >
455 typedef typename cpu_value_type<T>::type
type;
458 template <
typename T,
unsigned int ALIGNMENT>
459 struct cpu_value_type<viennacl::circulant_matrix<T, ALIGNMENT> >
461 typedef typename cpu_value_type<T>::type
type;
464 template <
typename T,
unsigned int ALIGNMENT>
465 struct cpu_value_type<viennacl::hankel_matrix<T, ALIGNMENT> >
467 typedef typename cpu_value_type<T>::type
type;
470 template <
typename T,
unsigned int ALIGNMENT>
471 struct cpu_value_type<viennacl::toeplitz_matrix<T, ALIGNMENT> >
473 typedef typename cpu_value_type<T>::type
type;
476 template <
typename T,
unsigned int ALIGNMENT>
477 struct cpu_value_type<viennacl::vandermonde_matrix<T, ALIGNMENT> >
479 typedef typename cpu_value_type<T>::type
type;
482 template <
typename T1,
typename T2,
typename OP>
483 struct cpu_value_type<viennacl::matrix_expression<T1, T2, OP> >
485 typedef typename cpu_value_type<T1>::type
type;
493 template <
typename T>
494 struct vector_for_matrix
496 typedef typename T::ERROR_CANNOT_DEDUCE_VECTOR_FOR_MATRIX_TYPE type;
500 template <
typename T,
typename F,
unsigned int A>
501 struct vector_for_matrix< viennacl::matrix<T, F, A> >
506 template <
typename T,
unsigned int A>
507 struct vector_for_matrix< viennacl::compressed_matrix<T, A> >
512 template <
typename T,
unsigned int A>
513 struct vector_for_matrix< viennacl::coordinate_matrix<T, A> >
518 #ifdef VIENNACL_WITH_UBLAS
520 template <
typename T,
typename F,
typename A>
521 struct vector_for_matrix< boost::numeric::ublas::matrix<T, F, A> >
523 typedef boost::numeric::ublas::vector<T> type;
526 template <
typename T,
typename U, vcl_
size_t A,
typename B,
typename C>
527 struct vector_for_matrix< boost::numeric::ublas::compressed_matrix<T, U, A, B, C> >
529 typedef boost::numeric::ublas::vector<T> type;
532 template <
typename T,
typename U, vcl_
size_t A,
typename B,
typename C>
533 struct vector_for_matrix< boost::numeric::ublas::coordinate_matrix<T, U, A, B, C> >
535 typedef boost::numeric::ublas::vector<T> type;
540 template <
typename T>
541 struct reference_if_nonscalar
546 #define VIENNACL_REFERENCE_IF_NONSCALAR_INT(TNAME) \
547 template <> struct reference_if_nonscalar<TNAME> { typedef TNAME type; }; \
548 template <> struct reference_if_nonscalar<const TNAME> { typedef const TNAME type; }; \
549 template <> struct reference_if_nonscalar<unsigned TNAME> { typedef unsigned TNAME type; }; \
550 template <> struct reference_if_nonscalar<const unsigned TNAME> { typedef const unsigned TNAME type; };
552 VIENNACL_REFERENCE_IF_NONSCALAR_INT(
char)
553 VIENNACL_REFERENCE_IF_NONSCALAR_INT(
short)
554 VIENNACL_REFERENCE_IF_NONSCALAR_INT(
int)
555 VIENNACL_REFERENCE_IF_NONSCALAR_INT(
long)
557 #undef VIENNACL_REFERENCE_IF_NONSCALAR_INT
560 struct reference_if_nonscalar<float>
566 struct reference_if_nonscalar<const float>
568 typedef const float type;
572 struct reference_if_nonscalar<double>
578 struct reference_if_nonscalar<const double>
580 typedef const double type;
594 #ifdef VIENNACL_WITH_OPENCL
599 struct cl_type<double>{
typedef cl_double
type; };
602 struct cl_type<int>{
typedef cl_int
type; };
605 struct cl_type<unsigned int>{
typedef cl_uint
type; };
608 struct cl_type<long>{
typedef cl_long
type; };
611 struct cl_type<unsigned long>{
typedef cl_ulong
type; };
614 struct cl_type<short>{
typedef cl_short
type; };
617 struct cl_type<unsigned short>{
typedef cl_ushort
type; };
620 struct cl_type<char>{
typedef cl_char
type; };
623 struct cl_type<unsigned char>{
typedef cl_uchar
type; };
std::size_t vcl_size_t
Definition: forwards.h:58
Metafunction for deducing the OpenCL type for a numeric type, e.g. float -> cl_float.
Definition: result_of.hpp:588
This file provides the forward declarations for the main types used within ViennaCL.
A dense matrix class.
Definition: forwards.h:293
Retrieves the alignment from a vector. Deprecated - will be replaced by a pure runtime facility in th...
Definition: result_of.hpp:65
Definition: result_of.hpp:68
T::ERROR_ARGUMENT_PROVIDED_IS_NOT_A_VECTOR_OR_A_MATRIX error_type
Definition: result_of.hpp:67
Generic helper function for retrieving the value_type associated with type T.
Definition: result_of.hpp:228
Common base class for dense vectors, vector ranges, and vector slices.
Definition: forwards.h:205
T::value_type type
Definition: result_of.hpp:230
A vector class representing a linear memory sequence on the GPU. Inspired by boost::numeric::ublas::v...
Definition: forwards.h:208
Returns the orientation functor tag (either row_major or column_major) of a matrix.
Definition: result_of.hpp:135
T type
Definition: result_of.hpp:590
T::ERROR_ARGUMENT_PROVIDED_IS_NOT_A_MATRIX type
Definition: result_of.hpp:137
T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T type
Definition: result_of.hpp:276
Helper meta function for retrieving the main RAM-based value type. Particularly important to obtain T...
Definition: result_of.hpp:274
T::size_type type
Definition: result_of.hpp:186
Generic meta-function for retrieving the size_type associated with type T.
Definition: result_of.hpp:184