• Main Page
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

/data/development/ViennaCL/dev/viennacl/meta/result_of.hpp

Go to the documentation of this file.
00001 #ifndef VIENNACL_META_RESULT_OF_HPP_
00002 #define VIENNACL_META_RESULT_OF_HPP_
00003 
00004 /* =========================================================================
00005    Copyright (c) 2010-2011, Institute for Microelectronics,
00006                             Institute for Analysis and Scientific Computing,
00007                             TU Wien.
00008 
00009                             -----------------
00010                   ViennaCL - The Vienna Computing Library
00011                             -----------------
00012 
00013    Project Head:    Karl Rupp                   rupp@iue.tuwien.ac.at
00014                
00015    (A list of authors and contributors can be found in the PDF manual)
00016 
00017    License:         MIT (X11), see file LICENSE in the base directory
00018 ============================================================================= */
00019 
00024 #include <string>
00025 #include <fstream>
00026 #include <sstream>
00027 #include "viennacl/forwards.h"
00028 
00029 
00030 #ifdef VIENNACL_HAVE_UBLAS  
00031 #include <boost/numeric/ublas/matrix_sparse.hpp>
00032 #include <boost/numeric/ublas/matrix.hpp>
00033 #endif
00034 
00035 #ifdef VIENNACL_HAVE_EIGEN  
00036 #include <Eigen/Core>
00037 #include <Eigen/Sparse>
00038 #endif
00039 
00040 #ifdef VIENNACL_HAVE_MTL4
00041 #include <boost/numeric/mtl/mtl.hpp>
00042 #endif
00043 
00044 #include <vector>
00045 #include <map>
00046 
00047 namespace viennacl
00048 {
00049     namespace result_of
00050     {
00051       //
00052       // Retrieve size_type 
00053       //
00054       template <typename T>
00055       struct size_type
00056       {
00057         typedef typename T::size_type   type;
00058       };
00059 
00060       #ifdef VIENNACL_HAVE_EIGEN
00061       template <class T, int a, int b, int c, int d, int e>
00062       struct size_type< Eigen::Matrix<T, a, b, c, d, e> >
00063       {
00064         typedef std::size_t   type;
00065       };
00066       
00067       template <>
00068       struct size_type<Eigen::VectorXf>
00069       {
00070         typedef std::size_t   type;
00071       };
00072       
00073       template <>
00074       struct size_type<Eigen::VectorXd>
00075       {
00076         typedef std::size_t   type;
00077       };
00078 
00079       template <typename T, int options>
00080       struct size_type<Eigen::SparseMatrix<T, options> >
00081       {
00082         typedef std::size_t   type;
00083       };
00084       #endif
00085       
00086       //
00087       // Retrieve value_type:
00088       //
00089       template <typename T>
00090       struct value_type
00091       {
00092         typedef typename T::value_type    type; 
00093       };
00094 
00095       //
00096       // Retrieve cpu value_type:
00097       //
00098       template <typename T>
00099       struct cpu_value_type
00100       {
00101         typedef typename T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T    type; 
00102       };
00103 
00104       template <>
00105       struct cpu_value_type<float>
00106       {
00107         typedef float    type; 
00108       };
00109       
00110       template <>
00111       struct cpu_value_type<double>
00112       {
00113         typedef double    type; 
00114       };
00115       
00116       template <typename T>
00117       struct cpu_value_type<viennacl::scalar<T> >
00118       {
00119         typedef T    type; 
00120       };
00121 
00122       template <typename T, unsigned int ALIGNMENT>
00123       struct cpu_value_type<viennacl::vector<T, ALIGNMENT> >
00124       {
00125         typedef T    type; 
00126       };
00127 
00128       template <typename T>
00129       struct cpu_value_type<viennacl::vector_range<T> >
00130       {
00131         typedef typename cpu_value_type<T>::type    type; 
00132       };
00133       
00134       template <typename T1, typename T2, typename OP>
00135       struct cpu_value_type<viennacl::vector_expression<T1, T2, OP> >
00136       {
00137         typedef typename cpu_value_type<T1>::type    type; 
00138       };
00139       
00140       
00141       
00142       template <typename T, typename F, unsigned int ALIGNMENT>
00143       struct cpu_value_type<viennacl::matrix<T, F, ALIGNMENT> >
00144       {
00145         typedef T    type; 
00146       };
00147       
00148       template <typename T>
00149       struct cpu_value_type<viennacl::matrix_range<T> >
00150       {
00151         typedef typename cpu_value_type<T>::type    type; 
00152       };
00153 
00154       template <typename T1, typename T2, typename OP>
00155       struct cpu_value_type<viennacl::matrix_expression<T1, T2, OP> >
00156       {
00157         typedef typename cpu_value_type<T1>::type    type; 
00158       };
00159       
00160       
00161     #ifdef VIENNACL_HAVE_EIGEN  
00162       template <>
00163       struct value_type<Eigen::MatrixXf>
00164       {
00165         typedef Eigen::MatrixXf::RealScalar    type; 
00166       };
00167       
00168       template <>
00169       struct value_type<Eigen::MatrixXd>
00170       {
00171         typedef Eigen::MatrixXd::RealScalar    type; 
00172       };
00173 
00174       template <typename ScalarType, int option>
00175       struct value_type<Eigen::SparseMatrix<ScalarType, option> >
00176       {
00177         typedef ScalarType    type; 
00178       };
00179 
00180       template <>
00181       struct value_type<Eigen::VectorXf>
00182       {
00183         typedef Eigen::VectorXf::RealScalar    type; 
00184       };
00185 
00186       template <>
00187       struct value_type<Eigen::VectorXd>
00188       {
00189         typedef Eigen::VectorXd::RealScalar    type; 
00190       };
00191       
00192     #endif
00193       
00194       
00195       
00196       template <typename T>
00197       struct matrix_expression_internal_storage
00198       {
00199         typedef T &     type;
00200       };
00201      
00202       template <>
00203       struct matrix_expression_internal_storage<const float>
00204       {
00205         typedef float type;
00206       };
00207       
00208       template <>
00209       struct matrix_expression_internal_storage<const double>
00210       {
00211         typedef double type;
00212       };
00213       
00214       
00215     } //namespace result_of
00216 } //namespace viennacl
00217     
00218 
00219 #endif

Generated on Fri Dec 30 2011 23:20:43 for ViennaCL - The Vienna Computing Library by  doxygen 1.7.1