/usr/include/viennacl/meta/result_of.hpp is in libviennacl-dev 1.5.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | #ifndef VIENNACL_META_RESULT_OF_HPP_
#define VIENNACL_META_RESULT_OF_HPP_
/* =========================================================================
Copyright (c) 2010-2014, Institute for Microelectronics,
Institute for Analysis and Scientific Computing,
TU Wien.
Portions of this software are copyright by UChicago Argonne, LLC.
-----------------
ViennaCL - The Vienna Computing Library
-----------------
Project Head: Karl Rupp rupp@iue.tuwien.ac.at
(A list of authors and contributors can be found in the PDF manual)
License: MIT (X11), see file LICENSE in the base directory
============================================================================= */
/** @file viennacl/meta/result_of.hpp
@brief A collection of compile time type deductions
*/
#include <string>
#include <fstream>
#include <sstream>
#include "viennacl/forwards.h"
#ifdef VIENNACL_WITH_UBLAS
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#endif
#ifdef VIENNACL_WITH_EIGEN
#include <Eigen/Core>
#include <Eigen/Sparse>
#endif
#ifdef VIENNACL_WITH_MTL4
#include <boost/numeric/mtl/mtl.hpp>
#endif
#ifdef VIENNACL_WITH_OPENCL
#ifdef __APPLE__
#include <OpenCL/cl.h>
#else
#include "CL/cl.h"
#endif
#endif
#include <vector>
#include <map>
namespace viennacl
{
namespace result_of
{
//
// Retrieve alignment from vector
//
/** @brief Retrieves the alignment from a vector. Deprecated - will be replaced by a pure runtime facility in the future. */
template <typename T>
struct alignment
{
typedef typename T::ERROR_ARGUMENT_PROVIDED_IS_NOT_A_VECTOR_OR_A_MATRIX error_type;
enum { value = 1 };
};
/** \cond */
template <typename T>
struct alignment<const T>
{
enum { value = alignment<T>::value };
};
template <typename SCALARTYPE, unsigned int ALIGNMENT>
struct alignment< vector<SCALARTYPE, ALIGNMENT> >
{
enum { value = ALIGNMENT };
};
template <typename T>
struct alignment< vector_range<T> >
{
enum { value = alignment<T>::value };
};
template <typename T>
struct alignment< vector_slice<T> >
{
enum { value = alignment<T>::value };
};
// support for a*x with scalar a and vector x
template <typename LHS, typename RHS, typename OP>
struct alignment< vector_expression<LHS, RHS, OP> >
{
enum { value = alignment<LHS>::value };
};
// Matrices
template <typename SCALARTYPE, typename F, unsigned int ALIGNMENT>
struct alignment< matrix<SCALARTYPE, F, ALIGNMENT> >
{
enum { value = ALIGNMENT };
};
template <typename T>
struct alignment< matrix_range<T> >
{
enum { value = alignment<T>::value };
};
template <typename T>
struct alignment< matrix_slice<T> >
{
enum { value = alignment<T>::value };
};
template <typename LHS, typename RHS>
struct alignment< matrix_expression<LHS, RHS, op_trans> >
{
enum { value = alignment<LHS>::value };
};
/** \endcond */
//
// Majority specifier for matrices (row_major, column_major)
//
/** @brief Returns the orientation functor tag (either row_major or column_major) of a matrix */
template <typename T>
struct orientation_functor
{
typedef typename T::ERROR_ARGUMENT_PROVIDED_IS_NOT_A_MATRIX type;
};
/** \cond */
template <typename T>
struct orientation_functor<const T>
{
typedef typename orientation_functor<T>::type type;
};
template <typename SCALARTYPE, typename F, unsigned int ALIGNMENT>
struct orientation_functor< matrix<SCALARTYPE, F, ALIGNMENT> >
{
typedef F type;
};
template <typename T>
struct orientation_functor< matrix_range<T> >
{
typedef typename orientation_functor<T>::type type;
};
template <typename T>
struct orientation_functor< matrix_slice<T> >
{
typedef typename orientation_functor<T>::type type;
};
template <typename SCALARTYPE, typename F>
struct orientation_functor< matrix_base<SCALARTYPE, F> >
{
typedef F type;
};
template <typename LHS, typename RHS>
struct orientation_functor< matrix_expression<LHS, RHS, op_trans> >
{
typedef typename orientation_functor<LHS>::type type;
};
/** \endcond */
//
// Retrieve size_type
//
/** @brief Generic meta-function for retrieving the size_type associated with type T */
template <typename T>
struct size_type
{
typedef typename T::size_type type;
};
/** \cond */
template <typename T, typename SizeType>
struct size_type< vector_base<T, SizeType> >
{
typedef SizeType type;
};
#ifdef VIENNACL_WITH_EIGEN
template <class T, int a, int b, int c, int d, int e>
struct size_type< Eigen::Matrix<T, a, b, c, d, e> >
{
typedef vcl_size_t type;
};
template <>
struct size_type<Eigen::VectorXf>
{
typedef vcl_size_t type;
};
template <>
struct size_type<Eigen::VectorXd>
{
typedef vcl_size_t type;
};
template <typename T, int options>
struct size_type<Eigen::SparseMatrix<T, options> >
{
typedef vcl_size_t type;
};
#endif
/** \endcond */
//
// Retrieve value_type:
//
/** @brief Generic helper function for retrieving the value_type associated with type T */
template <typename T>
struct value_type
{
typedef typename T::value_type type;
};
/** \cond */
#ifdef VIENNACL_WITH_EIGEN
template <>
struct value_type<Eigen::MatrixXf>
{
typedef Eigen::MatrixXf::RealScalar type;
};
template <>
struct value_type<Eigen::MatrixXd>
{
typedef Eigen::MatrixXd::RealScalar type;
};
template <typename ScalarType, int option>
struct value_type<Eigen::SparseMatrix<ScalarType, option> >
{
typedef ScalarType type;
};
template <>
struct value_type<Eigen::VectorXf>
{
typedef Eigen::VectorXf::RealScalar type;
};
template <>
struct value_type<Eigen::VectorXd>
{
typedef Eigen::VectorXd::RealScalar type;
};
#endif
/** \endcond */
//
// Retrieve cpu value_type:
//
/** @brief Helper meta function for retrieving the main RAM-based value type. Particularly important to obtain T from viennacl::scalar<T> in a generic way. */
template <typename T>
struct cpu_value_type
{
typedef typename T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T type;
};
/** \cond */
template <typename T>
struct cpu_value_type<const T>
{
typedef typename cpu_value_type<T>::type type;
};
template <>
struct cpu_value_type<char>
{
typedef char type;
};
template <>
struct cpu_value_type<unsigned char>
{
typedef unsigned char type;
};
template <>
struct cpu_value_type<short>
{
typedef short type;
};
template <>
struct cpu_value_type<unsigned short>
{
typedef unsigned short type;
};
template <>
struct cpu_value_type<int>
{
typedef int type;
};
template <>
struct cpu_value_type<unsigned int>
{
typedef unsigned int type;
};
template <>
struct cpu_value_type<long>
{
typedef int type;
};
template <>
struct cpu_value_type<unsigned long>
{
typedef unsigned long type;
};
template <>
struct cpu_value_type<float>
{
typedef float type;
};
template <>
struct cpu_value_type<double>
{
typedef double type;
};
template <typename T>
struct cpu_value_type<viennacl::scalar<T> >
{
typedef T type;
};
template <typename T>
struct cpu_value_type<viennacl::vector_base<T> >
{
typedef T type;
};
template <typename T>
struct cpu_value_type<viennacl::implicit_vector_base<T> >
{
typedef T type;
};
template <typename T, unsigned int ALIGNMENT>
struct cpu_value_type<viennacl::vector<T, ALIGNMENT> >
{
typedef T type;
};
template <typename T>
struct cpu_value_type<viennacl::vector_range<T> >
{
typedef typename cpu_value_type<T>::type type;
};
template <typename T>
struct cpu_value_type<viennacl::vector_slice<T> >
{
typedef typename cpu_value_type<T>::type type;
};
template <typename T1, typename T2, typename OP>
struct cpu_value_type<viennacl::vector_expression<const T1, const T2, OP> >
{
typedef typename cpu_value_type<T1>::type type;
};
template <typename T1, typename T2, typename OP>
struct cpu_value_type<const viennacl::vector_expression<const T1, const T2, OP> >
{
typedef typename cpu_value_type<T1>::type type;
};
template <typename T, typename F>
struct cpu_value_type<viennacl::matrix_base<T, F> >
{
typedef T type;
};
template <typename T>
struct cpu_value_type<viennacl::implicit_matrix_base<T> >
{
typedef T type;
};
template <typename T, typename F, unsigned int ALIGNMENT>
struct cpu_value_type<viennacl::matrix<T, F, ALIGNMENT> >
{
typedef T type;
};
template <typename T>
struct cpu_value_type<viennacl::matrix_range<T> >
{
typedef typename cpu_value_type<T>::type type;
};
template <typename T>
struct cpu_value_type<viennacl::matrix_slice<T> >
{
typedef typename cpu_value_type<T>::type type;
};
template <typename T, unsigned int ALIGNMENT>
struct cpu_value_type<viennacl::compressed_matrix<T, ALIGNMENT> >
{
typedef typename cpu_value_type<T>::type type;
};
template <typename T>
struct cpu_value_type<viennacl::compressed_compressed_matrix<T> >
{
typedef typename cpu_value_type<T>::type type;
};
template <typename T, unsigned int ALIGNMENT>
struct cpu_value_type<viennacl::coordinate_matrix<T, ALIGNMENT> >
{
typedef typename cpu_value_type<T>::type type;
};
template <typename T, unsigned int ALIGNMENT>
struct cpu_value_type<viennacl::ell_matrix<T, ALIGNMENT> >
{
typedef typename cpu_value_type<T>::type type;
};
template <typename T, unsigned int ALIGNMENT>
struct cpu_value_type<viennacl::hyb_matrix<T, ALIGNMENT> >
{
typedef typename cpu_value_type<T>::type type;
};
template <typename T, unsigned int ALIGNMENT>
struct cpu_value_type<viennacl::circulant_matrix<T, ALIGNMENT> >
{
typedef typename cpu_value_type<T>::type type;
};
template <typename T, unsigned int ALIGNMENT>
struct cpu_value_type<viennacl::hankel_matrix<T, ALIGNMENT> >
{
typedef typename cpu_value_type<T>::type type;
};
template <typename T, unsigned int ALIGNMENT>
struct cpu_value_type<viennacl::toeplitz_matrix<T, ALIGNMENT> >
{
typedef typename cpu_value_type<T>::type type;
};
template <typename T, unsigned int ALIGNMENT>
struct cpu_value_type<viennacl::vandermonde_matrix<T, ALIGNMENT> >
{
typedef typename cpu_value_type<T>::type type;
};
template <typename T1, typename T2, typename OP>
struct cpu_value_type<viennacl::matrix_expression<T1, T2, OP> >
{
typedef typename cpu_value_type<T1>::type type;
};
//
// Deduce compatible vector type for a matrix type
//
template <typename T>
struct vector_for_matrix
{
typedef typename T::ERROR_CANNOT_DEDUCE_VECTOR_FOR_MATRIX_TYPE type;
};
//ViennaCL
template <typename T, typename F, unsigned int A>
struct vector_for_matrix< viennacl::matrix<T, F, A> >
{
typedef viennacl::vector<T,A> type;
};
template <typename T, unsigned int A>
struct vector_for_matrix< viennacl::compressed_matrix<T, A> >
{
typedef viennacl::vector<T,A> type;
};
template <typename T, unsigned int A>
struct vector_for_matrix< viennacl::coordinate_matrix<T, A> >
{
typedef viennacl::vector<T,A> type;
};
#ifdef VIENNACL_WITH_UBLAS
//Boost:
template <typename T, typename F, typename A>
struct vector_for_matrix< boost::numeric::ublas::matrix<T, F, A> >
{
typedef boost::numeric::ublas::vector<T> type;
};
template <typename T, typename U, vcl_size_t A, typename B, typename C>
struct vector_for_matrix< boost::numeric::ublas::compressed_matrix<T, U, A, B, C> >
{
typedef boost::numeric::ublas::vector<T> type;
};
template <typename T, typename U, vcl_size_t A, typename B, typename C>
struct vector_for_matrix< boost::numeric::ublas::coordinate_matrix<T, U, A, B, C> >
{
typedef boost::numeric::ublas::vector<T> type;
};
#endif
template <typename T>
struct reference_if_nonscalar
{
typedef T & type;
};
#define VIENNACL_REFERENCE_IF_NONSCALAR_INT(TNAME) \
template <> struct reference_if_nonscalar<TNAME> { typedef TNAME type; }; \
template <> struct reference_if_nonscalar<const TNAME> { typedef const TNAME type; }; \
template <> struct reference_if_nonscalar<unsigned TNAME> { typedef unsigned TNAME type; }; \
template <> struct reference_if_nonscalar<const unsigned TNAME> { typedef const unsigned TNAME type; };
VIENNACL_REFERENCE_IF_NONSCALAR_INT(char)
VIENNACL_REFERENCE_IF_NONSCALAR_INT(short)
VIENNACL_REFERENCE_IF_NONSCALAR_INT(int)
VIENNACL_REFERENCE_IF_NONSCALAR_INT(long)
#undef VIENNACL_REFERENCE_IF_NONSCALAR_INT
template <>
struct reference_if_nonscalar<float>
{
typedef float type;
};
template <>
struct reference_if_nonscalar<const float>
{
typedef const float type;
};
template <>
struct reference_if_nonscalar<double>
{
typedef double type;
};
template <>
struct reference_if_nonscalar<const double>
{
typedef const double type;
};
/** \endcond */
//OpenCL equivalent type
/** @brief Metafunction for deducing the OpenCL type for a numeric type, e.g. float -> cl_float */
template<typename T>
struct cl_type
{
typedef T type;
};
/** \cond */
#ifdef VIENNACL_WITH_OPENCL
template<>
struct cl_type<float>{ typedef cl_float type; };
template<>
struct cl_type<double>{ typedef cl_double type; };
template<>
struct cl_type<int>{ typedef cl_int type; };
template<>
struct cl_type<unsigned int>{ typedef cl_uint type; };
template<>
struct cl_type<long>{ typedef cl_long type; };
template<>
struct cl_type<unsigned long>{ typedef cl_ulong type; };
template<>
struct cl_type<short>{ typedef cl_short type; };
template<>
struct cl_type<unsigned short>{ typedef cl_ushort type; };
template<>
struct cl_type<char>{ typedef cl_char type; };
template<>
struct cl_type<unsigned char>{ typedef cl_uchar type; };
#endif
/** \endcond */
} //namespace result_of
} //namespace viennacl
#endif
|