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 NumericT,
unsigned int AlignmentV>
79 struct alignment< vector<NumericT, AlignmentV> >
81 enum {
value = AlignmentV };
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 NumericT,
typename F,
unsigned int AlignmentV>
106 struct alignment< matrix<NumericT, F, AlignmentV> >
108 enum {
value = AlignmentV };
112 struct alignment< matrix_range<T> >
114 enum {
value = alignment<T>::value };
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 };
137 typedef typename T::size_type
type;
141 template<
typename T,
typename SizeType>
144 typedef SizeType
type;
152 struct difference_type
154 typedef typename T::difference_type type;
158 #ifdef VIENNACL_WITH_EIGEN
159 template<
class T,
int a,
int b,
int c,
int d,
int e>
160 struct size_type< Eigen::Matrix<T, a, b, c, d, e> >
166 struct size_type<Eigen::VectorXf>
172 struct size_type<Eigen::VectorXd>
177 template<
typename T,
int options>
178 struct size_type<Eigen::SparseMatrix<T, options> >
192 typedef typename T::value_type
type;
196 #ifdef VIENNACL_WITH_EIGEN
200 typedef Eigen::MatrixXf::RealScalar
type;
204 struct value_type<Eigen::MatrixXd>
206 typedef Eigen::MatrixXd::RealScalar
type;
209 template<
typename ScalarType,
int option>
210 struct value_type<Eigen::SparseMatrix<ScalarType, option> >
216 struct value_type<Eigen::VectorXf>
218 typedef Eigen::VectorXf::RealScalar
type;
222 struct value_type<Eigen::VectorXd>
224 typedef Eigen::VectorXd::RealScalar
type;
238 typedef typename T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T
type;
249 struct cpu_value_type<char>
255 struct cpu_value_type<unsigned char>
257 typedef unsigned char type;
261 struct cpu_value_type<short>
267 struct cpu_value_type<unsigned short>
269 typedef unsigned short type;
273 struct cpu_value_type<int>
279 struct cpu_value_type<unsigned int>
281 typedef unsigned int type;
285 struct cpu_value_type<long>
291 struct cpu_value_type<unsigned long>
293 typedef unsigned long type;
298 struct cpu_value_type<float>
304 struct cpu_value_type<double>
310 struct cpu_value_type<
viennacl::scalar<T> >
316 struct cpu_value_type<
viennacl::vector_base<T> >
322 struct cpu_value_type<
viennacl::implicit_vector_base<T> >
328 template<
typename T,
unsigned int AlignmentV>
329 struct cpu_value_type<
viennacl::vector<T, AlignmentV> >
335 struct cpu_value_type<
viennacl::vector_range<T> >
337 typedef typename cpu_value_type<T>::type
type;
341 struct cpu_value_type<
viennacl::vector_slice<T> >
343 typedef typename cpu_value_type<T>::type
type;
346 template<
typename T1,
typename T2,
typename OP>
347 struct cpu_value_type<
viennacl::vector_expression<const T1, const T2, OP> >
349 typedef typename cpu_value_type<T1>::type
type;
352 template<
typename T1,
typename T2,
typename OP>
353 struct cpu_value_type<const
viennacl::vector_expression<const T1, const T2, OP> >
355 typedef typename cpu_value_type<T1>::type
type;
360 struct cpu_value_type<
viennacl::matrix_base<T> >
366 struct cpu_value_type<
viennacl::implicit_matrix_base<T> >
372 template<
typename T,
typename F,
unsigned int AlignmentV>
373 struct cpu_value_type<
viennacl::matrix<T, F, AlignmentV> >
379 struct cpu_value_type<
viennacl::matrix_range<T> >
381 typedef typename cpu_value_type<T>::type
type;
385 struct cpu_value_type<
viennacl::matrix_slice<T> >
387 typedef typename cpu_value_type<T>::type
type;
390 template<
typename T,
unsigned int AlignmentV>
391 struct cpu_value_type<
viennacl::compressed_matrix<T, AlignmentV> >
393 typedef typename cpu_value_type<T>::type
type;
397 struct cpu_value_type<
viennacl::compressed_compressed_matrix<T> >
399 typedef typename cpu_value_type<T>::type
type;
402 template<
typename T,
unsigned int AlignmentV>
403 struct cpu_value_type<
viennacl::coordinate_matrix<T, AlignmentV> >
405 typedef typename cpu_value_type<T>::type
type;
408 template<
typename T,
unsigned int AlignmentV>
409 struct cpu_value_type<
viennacl::ell_matrix<T, AlignmentV> >
411 typedef typename cpu_value_type<T>::type
type;
414 template<
typename T,
typename IndexT>
415 struct cpu_value_type<
viennacl::sliced_ell_matrix<T, IndexT> >
417 typedef typename cpu_value_type<T>::type
type;
420 template<
typename T,
unsigned int AlignmentV>
421 struct cpu_value_type<
viennacl::hyb_matrix<T, AlignmentV> >
423 typedef typename cpu_value_type<T>::type
type;
426 template<
typename T,
unsigned int AlignmentV>
427 struct cpu_value_type<
viennacl::circulant_matrix<T, AlignmentV> >
429 typedef typename cpu_value_type<T>::type
type;
432 template<
typename T,
unsigned int AlignmentV>
433 struct cpu_value_type<
viennacl::hankel_matrix<T, AlignmentV> >
435 typedef typename cpu_value_type<T>::type
type;
438 template<
typename T,
unsigned int AlignmentV>
439 struct cpu_value_type<
viennacl::toeplitz_matrix<T, AlignmentV> >
441 typedef typename cpu_value_type<T>::type
type;
444 template<
typename T,
unsigned int AlignmentV>
445 struct cpu_value_type<
viennacl::vandermonde_matrix<T, AlignmentV> >
447 typedef typename cpu_value_type<T>::type
type;
450 template<
typename T1,
typename T2,
typename OP>
451 struct cpu_value_type<
viennacl::matrix_expression<T1, T2, OP> >
453 typedef typename cpu_value_type<T1>::type
type;
462 struct vector_for_matrix
464 typedef typename T::ERROR_CANNOT_DEDUCE_VECTOR_FOR_MATRIX_TYPE type;
468 template<
typename T,
typename F,
unsigned int A>
469 struct vector_for_matrix<
viennacl::matrix<T, F, A> >
474 template<
typename T,
unsigned int A>
475 struct vector_for_matrix<
viennacl::compressed_matrix<T, A> >
480 template<
typename T,
unsigned int A>
481 struct vector_for_matrix<
viennacl::coordinate_matrix<T, A> >
486 #ifdef VIENNACL_WITH_UBLAS
488 template<
typename T,
typename F,
typename A>
489 struct vector_for_matrix< boost::numeric::ublas::matrix<T, F, A> >
491 typedef boost::numeric::ublas::vector<T> type;
494 template<
typename T,
typename U, vcl_
size_t A,
typename B,
typename C>
495 struct vector_for_matrix< boost::numeric::ublas::compressed_matrix<T, U, A, B, C> >
497 typedef boost::numeric::ublas::vector<T> type;
500 template<
typename T,
typename U, vcl_
size_t A,
typename B,
typename C>
501 struct vector_for_matrix< boost::numeric::ublas::coordinate_matrix<T, U, A, B, C> >
503 typedef boost::numeric::ublas::vector<T> type;
508 struct reference_if_nonscalar
513 #define VIENNACL_REFERENCE_IF_NONSCALAR_INT(TNAME) \
514 template<> struct reference_if_nonscalar<TNAME> { typedef TNAME type; }; \
515 template<> struct reference_if_nonscalar<const TNAME> { typedef const TNAME type; }; \
516 template<> struct reference_if_nonscalar<unsigned TNAME> { typedef unsigned TNAME type; }; \
517 template<> struct reference_if_nonscalar<const unsigned TNAME> { typedef const unsigned TNAME type; };
519 VIENNACL_REFERENCE_IF_NONSCALAR_INT(
char)
520 VIENNACL_REFERENCE_IF_NONSCALAR_INT(
short)
521 VIENNACL_REFERENCE_IF_NONSCALAR_INT(
int)
522 VIENNACL_REFERENCE_IF_NONSCALAR_INT(
long)
524 #undef VIENNACL_REFERENCE_IF_NONSCALAR_INT
527 struct reference_if_nonscalar<float>
533 struct reference_if_nonscalar<const float>
535 typedef const float type;
539 struct reference_if_nonscalar<double>
545 struct reference_if_nonscalar<const double>
547 typedef const double type;
561 #ifdef VIENNACL_WITH_OPENCL
566 struct cl_type<double>{
typedef cl_double
type; };
569 struct cl_type<int>{
typedef cl_int
type; };
572 struct cl_type<unsigned int>{
typedef cl_uint
type; };
575 struct cl_type<long>{
typedef cl_long
type; };
578 struct cl_type<unsigned long>{
typedef cl_ulong
type; };
581 struct cl_type<short>{
typedef cl_short
type; };
584 struct cl_type<unsigned short>{
typedef cl_ushort
type; };
587 struct cl_type<char>{
typedef cl_char
type; };
590 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...
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
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