00001 #ifndef VIENNACL_TOOLS_MATRIX_SIZE_DEDUCER_HPP_
00002 #define VIENNACL_TOOLS_MATRIX_SIZE_DEDUCER_HPP_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00024 #include <string>
00025 #include <fstream>
00026 #include <sstream>
00027 #include "viennacl/forwards.h"
00028 #include "viennacl/tools/adapter.hpp"
00029
00030 #include <vector>
00031 #include <map>
00032
00033 namespace viennacl
00034 {
00035 namespace tools
00036 {
00037
00044 template <typename LHS, typename RHS, typename OP>
00045 struct MATRIX_SIZE_DEDUCER
00046 {
00047
00048 static size_t size1(LHS & lhs, RHS & rhs) { return lhs.size1(); }
00049 static size_t size2(LHS & lhs, RHS & rhs) { return rhs.size2(); }
00050 };
00051
00052
00053 template <typename ScalarType, unsigned int A1, unsigned int A2>
00054 struct MATRIX_SIZE_DEDUCER<viennacl::vector<ScalarType, A1>,
00055 viennacl::vector<ScalarType, A2>,
00056 viennacl::op_prod>
00057 {
00058 static size_t size1(viennacl::vector<ScalarType, A1> & lhs,
00059 viennacl::vector<ScalarType, A2> & rhs) { return lhs.size1(); }
00060
00061 static size_t size2(viennacl::vector<ScalarType, A1> & lhs,
00062 viennacl::vector<ScalarType, A2> & rhs) { return rhs.size2(); }
00063 };
00064
00065
00066
00067
00068
00069
00070
00071
00072 template <typename ScalarType, typename F1, unsigned int A1, typename F2, unsigned int A2>
00073 struct MATRIX_SIZE_DEDUCER<const viennacl::matrix_expression<const viennacl::matrix<ScalarType, F1, A1>,
00074 const viennacl::matrix<ScalarType, F1, A1>, op_trans>,
00075 const viennacl::matrix<ScalarType, F2, A2>,
00076 viennacl::op_prod>
00077 {
00078 static size_t size1(viennacl::matrix_expression<const viennacl::matrix<ScalarType, F1, A1>,
00079 const viennacl::matrix<ScalarType, F1, A1>,
00080 op_trans> const & lhs,
00081 viennacl::matrix<ScalarType, F2, A2> const & rhs) { return lhs.lhs().size2(); }
00082 static size_t size2(viennacl::matrix_expression<const viennacl::matrix<ScalarType, F1, A1>,
00083 const viennacl::matrix<ScalarType, F1, A1>,
00084 op_trans> const & lhs,
00085 viennacl::matrix<ScalarType, F2, A2> const & rhs) { return rhs.size2(); }
00086 };
00087
00088 template <typename ScalarType, typename F1, unsigned int A1, typename F2, unsigned int A2>
00089 struct MATRIX_SIZE_DEDUCER<const viennacl::matrix<ScalarType, F1, A1>,
00090 const viennacl::matrix_expression<const viennacl::matrix<ScalarType, F2, A2>,
00091 const viennacl::matrix<ScalarType, F2, A2>, op_trans>,
00092 viennacl::op_prod>
00093 {
00094 static size_t size1(viennacl::matrix<ScalarType, F1, A1> const & lhs,
00095 viennacl::matrix_expression<const viennacl::matrix<ScalarType, F2, A2>,
00096 const viennacl::matrix<ScalarType, F2, A2>,
00097 op_trans> const & rhs) { return lhs.size1(); }
00098 static size_t size2(viennacl::matrix<ScalarType, F1, A1> const & lhs,
00099 viennacl::matrix_expression<const viennacl::matrix<ScalarType, F2, A2>,
00100 const viennacl::matrix<ScalarType, F2, A2>,
00101 op_trans> const & rhs) { return rhs.lhs().size1(); }
00102 };
00103
00104 }
00105 }
00106
00107 #endif
00108