All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tag_of.hpp
Go to the documentation of this file.
#ifndef VIENNACL_META_TAGOF_HPP_
#define VIENNACL_META_TAGOF_HPP_
/* =========================================================================
Copyright (c) 2010-2016, 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 manual)
License: MIT (X11), see file LICENSE in the base directory
============================================================================= */
#include <vector>
#include <map>
#include "viennacl/forwards.h"
#ifdef VIENNACL_WITH_UBLAS
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>
#endif
#ifdef VIENNACL_WITH_ARMADILLO
#include <armadillo>
#endif
#ifdef VIENNACL_WITH_EIGEN
#include <Eigen/Core>
#include <Eigen/Sparse>
#endif
#ifdef VIENNACL_WITH_MTL4
#include <boost/numeric/mtl/mtl.hpp>
#endif
namespace viennacl
{
// ----------------------------------------------------
// TAGS
//
struct tag_none {};
struct tag_mtl4 {};
struct tag_eigen {};
struct tag_ublas {};
struct tag_stl {};
struct tag_viennacl {};
namespace traits
{
// ----------------------------------------------------
// GENERIC BASE
//
template< typename T, typename Active = void >
struct tag_of;
template< typename Sequence, typename Active >
struct tag_of
{
typedef viennacl::tag_none type;
};
#ifdef VIENNACL_WITH_MTL4
// ----------------------------------------------------
// MTL4
//
template<typename ScalarType>
struct tag_of< mtl::dense_vector<ScalarType> >
{
typedef viennacl::tag_mtl4 type;
};
template<typename ScalarType>
struct tag_of< mtl::compressed2D<ScalarType> >
{
typedef viennacl::tag_mtl4 type;
};
template<typename ScalarType, typename T>
struct tag_of< mtl::dense2D<ScalarType, T> >
{
typedef viennacl::tag_mtl4 type;
};
#endif
#ifdef VIENNACL_WITH_EIGEN
// ----------------------------------------------------
// Eigen
//
template<>
struct tag_of< Eigen::VectorXf >
{
typedef viennacl::tag_eigen type;
};
template<>
struct tag_of< Eigen::VectorXd >
{
typedef viennacl::tag_eigen type;
};
template<>
struct tag_of< Eigen::MatrixXf >
{
typedef viennacl::tag_eigen type;
};
template<>
struct tag_of< Eigen::MatrixXd >
{
typedef viennacl::tag_eigen type;
};
template<typename ScalarType, int option>
struct tag_of< Eigen::SparseMatrix<ScalarType, option> >
{
typedef viennacl::tag_eigen type;
};
#endif
#ifdef VIENNACL_WITH_UBLAS
// ----------------------------------------------------
// UBLAS
//
template< typename T >
struct tag_of< boost::numeric::ublas::vector<T> >
{
typedef viennacl::tag_ublas type;
};
template< typename T >
struct tag_of< boost::numeric::ublas::matrix<T> >
{
typedef viennacl::tag_ublas type;
};
template< typename T1, typename T2 >
struct tag_of< boost::numeric::ublas::matrix_unary2<T1,T2> >
{
typedef viennacl::tag_ublas type;
};
template< typename T1, typename T2 >
struct tag_of< boost::numeric::ublas::compressed_matrix<T1,T2> >
{
typedef viennacl::tag_ublas type;
};
#endif
// ----------------------------------------------------
// STL types
//
//vector
template< typename T, typename A >
struct tag_of< std::vector<T, A> >
{
typedef viennacl::tag_stl type;
};
//dense matrix
template< typename T, typename A >
struct tag_of< std::vector<std::vector<T, A>, A> >
{
typedef viennacl::tag_stl type;
};
//sparse matrix (vector of maps)
template< typename KEY, typename DATA, typename COMPARE, typename AMAP, typename AVEC>
struct tag_of< std::vector<std::map<KEY, DATA, COMPARE, AMAP>, AVEC> >
{
typedef viennacl::tag_stl type;
};
// ----------------------------------------------------
// VIENNACL
//
template< typename T, unsigned int alignment >
struct tag_of< viennacl::vector<T, alignment> >
{
typedef viennacl::tag_viennacl type;
};
template< typename T, typename F, unsigned int alignment >
struct tag_of< viennacl::matrix<T, F, alignment> >
{
typedef viennacl::tag_viennacl type;
};
template< typename T1, typename T2, typename OP >
struct tag_of< viennacl::matrix_expression<T1,T2,OP> >
{
typedef viennacl::tag_viennacl type;
};
template< typename T >
struct tag_of< viennacl::matrix_range<T> >
{
typedef viennacl::tag_viennacl type;
};
template< typename T, unsigned int I>
struct tag_of< viennacl::compressed_matrix<T,I> >
{
typedef viennacl::tag_viennacl type;
};
template< typename T, unsigned int I>
struct tag_of< viennacl::coordinate_matrix<T,I> >
{
typedef viennacl::tag_viennacl type;
};
template< typename T, unsigned int I>
struct tag_of< viennacl::ell_matrix<T,I> >
{
typedef viennacl::tag_viennacl type;
};
template< typename T, typename I>
struct tag_of< viennacl::sliced_ell_matrix<T,I> >
{
typedef viennacl::tag_viennacl type;
};
template< typename T, unsigned int I>
struct tag_of< viennacl::hyb_matrix<T,I> >
{
typedef viennacl::tag_viennacl type;
};
template< typename T, unsigned int I>
struct tag_of< viennacl::circulant_matrix<T,I> >
{
typedef viennacl::tag_viennacl type;
};
template< typename T, unsigned int I>
struct tag_of< viennacl::hankel_matrix<T,I> >
{
typedef viennacl::tag_viennacl type;
};
template< typename T, unsigned int I>
struct tag_of< viennacl::toeplitz_matrix<T,I> >
{
typedef viennacl::tag_viennacl type;
};
template< typename T, unsigned int I>
struct tag_of< viennacl::vandermonde_matrix<T,I> >
{
typedef viennacl::tag_viennacl type;
};
// ----------------------------------------------------
} // end namespace traits
template<typename Tag>
struct is_mtl4
{
enum { value = false };
};
template<>
struct is_mtl4< viennacl::tag_mtl4 >
{
enum { value = true };
};
template<typename Tag>
struct is_eigen
{
enum { value = false };
};
template<>
struct is_eigen< viennacl::tag_eigen >
{
enum { value = true };
};
template<typename Tag>
struct is_ublas
{
enum { value = false };
};
template<>
struct is_ublas< viennacl::tag_ublas >
{
enum { value = true };
};
template<typename Tag>
struct is_stl
{
enum { value = false };
};
template<>
struct is_stl< viennacl::tag_stl >
{
enum { value = true };
};
template<typename Tag>
struct is_viennacl
{
enum { value = false };
};
template<>
struct is_viennacl< viennacl::tag_viennacl >
{
enum { value = true };
};
} // end namespace viennacl
#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