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_ARMADILLO
40 #ifdef VIENNACL_WITH_EIGEN
42 #include <Eigen/Sparse>
45 #ifdef VIENNACL_WITH_MTL4
46 #include <boost/numeric/mtl/mtl.hpp>
49 #ifdef VIENNACL_WITH_OPENCL
51 #include <OpenCL/cl.h>
71 typedef typename T::ERROR_ARGUMENT_PROVIDED_IS_NOT_A_VECTOR_OR_A_MATRIX
error_type;
77 struct alignment<const T>
79 enum {
value = alignment<T>::value };
82 template<
typename NumericT,
unsigned int AlignmentV>
83 struct alignment< vector<
NumericT, AlignmentV> >
85 enum {
value = AlignmentV };
89 struct alignment< vector_range<T> >
91 enum {
value = alignment<T>::value };
95 struct alignment< vector_slice<T> >
97 enum {
value = alignment<T>::value };
101 template<
typename LHS,
typename RHS,
typename OP>
102 struct alignment< vector_expression<LHS, RHS, OP> >
104 enum {
value = alignment<LHS>::value };
109 template<
typename NumericT,
typename F,
unsigned int AlignmentV>
110 struct alignment< matrix<
NumericT, F, AlignmentV> >
112 enum {
value = AlignmentV };
116 struct alignment< matrix_range<T> >
118 enum {
value = alignment<T>::value };
122 struct alignment< matrix_slice<T> >
124 enum {
value = alignment<T>::value };
127 template<
typename LHS,
typename RHS>
128 struct alignment< matrix_expression<LHS, RHS, op_trans> >
130 enum {
value = alignment<LHS>::value };
141 typedef typename T::size_type
type;
145 template<
typename T,
typename SizeType>
148 typedef SizeType
type;
156 struct difference_type
158 typedef typename T::difference_type type;
161 #ifdef VIENNACL_WITH_ARMADILLO
162 template<
typename NumericT>
163 struct size_type<arma::Col<NumericT> > {
typedef vcl_size_t type; };
165 template<
typename NumericT>
166 struct size_type<arma::Mat<NumericT> > {
typedef vcl_size_t type; };
168 template<
typename NumericT>
169 struct size_type<arma::SpMat<NumericT> > {
typedef vcl_size_t type; };
173 #ifdef VIENNACL_WITH_EIGEN
174 template<
class T,
int a,
int b,
int c,
int d,
int e>
175 struct size_type< Eigen::Matrix<T, a, b, c, d, e> >
180 template<
class T,
int a,
int b,
int c,
int d,
int e>
181 struct size_type< Eigen::Map<Eigen::Matrix<T, a, b, c, d, e> > >
187 struct size_type<Eigen::VectorXf>
193 struct size_type<Eigen::VectorXd>
198 template<
typename T,
int options>
199 struct size_type<Eigen::SparseMatrix<T, options> >
213 typedef typename T::value_type
type;
217 #ifdef VIENNACL_WITH_ARMADILLO
218 template<
typename NumericT>
221 template<
typename NumericT>
222 struct value_type<arma::Mat<NumericT> > {
typedef NumericT type; };
224 template<
typename NumericT>
225 struct value_type<arma::SpMat<NumericT> > {
typedef NumericT type; };
229 #ifdef VIENNACL_WITH_EIGEN
231 struct value_type<Eigen::MatrixXf>
233 typedef Eigen::MatrixXf::RealScalar
type;
237 struct value_type<Eigen::MatrixXd>
239 typedef Eigen::MatrixXd::RealScalar
type;
242 template<
typename ScalarType,
int option>
243 struct value_type<Eigen::SparseMatrix<ScalarType, option> >
249 struct value_type<Eigen::VectorXf>
251 typedef Eigen::VectorXf::RealScalar
type;
255 struct value_type<Eigen::VectorXd>
257 typedef Eigen::VectorXd::RealScalar
type;
271 typedef typename T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T
type;
282 struct cpu_value_type<char>
288 struct cpu_value_type<unsigned char>
290 typedef unsigned char type;
294 struct cpu_value_type<short>
300 struct cpu_value_type<unsigned short>
302 typedef unsigned short type;
306 struct cpu_value_type<int>
312 struct cpu_value_type<unsigned int>
314 typedef unsigned int type;
318 struct cpu_value_type<long>
324 struct cpu_value_type<unsigned long>
326 typedef unsigned long type;
331 struct cpu_value_type<float>
337 struct cpu_value_type<double>
343 struct cpu_value_type<viennacl::scalar<T> >
349 struct cpu_value_type<viennacl::vector_base<T> >
355 struct cpu_value_type<viennacl::implicit_vector_base<T> >
361 template<
typename T,
unsigned int AlignmentV>
362 struct cpu_value_type<viennacl::vector<T, AlignmentV> >
368 struct cpu_value_type<viennacl::vector_range<T> >
370 typedef typename cpu_value_type<T>::type
type;
374 struct cpu_value_type<viennacl::vector_slice<T> >
376 typedef typename cpu_value_type<T>::type
type;
379 template<
typename T1,
typename T2,
typename OP>
380 struct cpu_value_type<viennacl::vector_expression<const T1, const T2, OP> >
382 typedef typename cpu_value_type<T1>::type
type;
385 template<
typename T1,
typename T2,
typename OP>
386 struct cpu_value_type<const viennacl::vector_expression<const T1, const T2, OP> >
388 typedef typename cpu_value_type<T1>::type
type;
393 struct cpu_value_type<viennacl::matrix_base<T> >
399 struct cpu_value_type<viennacl::implicit_matrix_base<T> >
405 template<
typename T,
typename F,
unsigned int AlignmentV>
406 struct cpu_value_type<viennacl::matrix<T, F, AlignmentV> >
412 struct cpu_value_type<viennacl::matrix_range<T> >
414 typedef typename cpu_value_type<T>::type
type;
418 struct cpu_value_type<viennacl::matrix_slice<T> >
420 typedef typename cpu_value_type<T>::type
type;
423 template<
typename T,
unsigned int AlignmentV>
424 struct cpu_value_type<viennacl::compressed_matrix<T, AlignmentV> >
426 typedef typename cpu_value_type<T>::type
type;
430 struct cpu_value_type<viennacl::compressed_compressed_matrix<T> >
432 typedef typename cpu_value_type<T>::type
type;
435 template<
typename T,
unsigned int AlignmentV>
436 struct cpu_value_type<viennacl::coordinate_matrix<T, AlignmentV> >
438 typedef typename cpu_value_type<T>::type
type;
441 template<
typename T,
unsigned int AlignmentV>
442 struct cpu_value_type<viennacl::ell_matrix<T, AlignmentV> >
444 typedef typename cpu_value_type<T>::type
type;
447 template<
typename T,
typename IndexT>
448 struct cpu_value_type<viennacl::sliced_ell_matrix<T, IndexT> >
450 typedef typename cpu_value_type<T>::type
type;
453 template<
typename T,
unsigned int AlignmentV>
454 struct cpu_value_type<viennacl::hyb_matrix<T, AlignmentV> >
456 typedef typename cpu_value_type<T>::type
type;
459 template<
typename T,
unsigned int AlignmentV>
460 struct cpu_value_type<viennacl::circulant_matrix<T, AlignmentV> >
462 typedef typename cpu_value_type<T>::type
type;
465 template<
typename T,
unsigned int AlignmentV>
466 struct cpu_value_type<viennacl::hankel_matrix<T, AlignmentV> >
468 typedef typename cpu_value_type<T>::type
type;
471 template<
typename T,
unsigned int AlignmentV>
472 struct cpu_value_type<viennacl::toeplitz_matrix<T, AlignmentV> >
474 typedef typename cpu_value_type<T>::type
type;
477 template<
typename T,
unsigned int AlignmentV>
478 struct cpu_value_type<viennacl::vandermonde_matrix<T, AlignmentV> >
480 typedef typename cpu_value_type<T>::type
type;
483 template<
typename T1,
typename T2,
typename OP>
484 struct cpu_value_type<viennacl::matrix_expression<T1, T2, OP> >
486 typedef typename cpu_value_type<T1>::type
type;
495 struct vector_for_matrix
497 typedef typename T::ERROR_CANNOT_DEDUCE_VECTOR_FOR_MATRIX_TYPE type;
501 template<
typename T,
typename F,
unsigned int A>
502 struct vector_for_matrix< viennacl::matrix<T, F, A> >
507 template<
typename T,
unsigned int A>
508 struct vector_for_matrix< viennacl::compressed_matrix<T, A> >
513 template<
typename T,
unsigned int A>
514 struct vector_for_matrix< viennacl::coordinate_matrix<T, A> >
519 #ifdef VIENNACL_WITH_UBLAS
521 template<
typename T,
typename F,
typename A>
522 struct vector_for_matrix< boost::numeric::ublas::matrix<T, F, A> >
524 typedef boost::numeric::ublas::vector<T> type;
527 template<
typename T,
typename U, vcl_
size_t A,
typename B,
typename C>
528 struct vector_for_matrix< boost::numeric::ublas::compressed_matrix<T, U, A, B, C> >
530 typedef boost::numeric::ublas::vector<T> type;
533 template<
typename T,
typename U, vcl_
size_t A,
typename B,
typename C>
534 struct vector_for_matrix< boost::numeric::ublas::coordinate_matrix<T, U, A, B, C> >
536 typedef boost::numeric::ublas::vector<T> type;
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; };
Metafunction for deducing the OpenCL type for a numeric type, e.g. float -> cl_float.
This file provides the forward declarations for the main types used within ViennaCL.
Retrieves the alignment from a vector. Deprecated - will be replaced by a pure runtime facility in th...
Generic helper function for retrieving the value_type associated with type T.
Common base class for dense vectors, vector ranges, and vector slices.
T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T type
Helper meta function for retrieving the main RAM-based value type. Particularly important to obtain T...
Generic meta-function for retrieving the size_type associated with type T.
T::ERROR_ARGUMENT_PROVIDED_IS_NOT_A_VECTOR_OR_A_MATRIX error_type