1 #ifndef VIENNACL_LINALG_INNER_PROD_HPP_
2 #define VIENNACL_LINALG_INNER_PROD_HPP_
41 #ifdef VIENNACL_WITH_ARMADILLO
45 template<
typename NumericT>
52 #ifdef VIENNACL_WITH_EIGEN
56 template<
typename VectorT1,
typename VectorT2>
58 typename VectorT1::RealScalar>::type
66 #ifdef VIENNACL_WITH_MTL4
70 template<
typename VectorT1,
typename VectorT2>
72 typename VectorT1::value_type>::type
73 inner_prod(VectorT1
const & v1, VectorT2
const & v2)
76 return mtl::dot(v1, v2);
80 #ifdef VIENNACL_WITH_UBLAS
84 template<
typename VectorT1,
typename VectorT2>
86 typename VectorT1::value_type>::type
87 inner_prod(VectorT1
const & v1, VectorT2
const & v2)
97 template<
typename VectorT1,
typename VectorT2>
99 typename VectorT1::value_type>::type
102 assert(v1.size() == v2.size() && bool(
"Vector sizes mismatch"));
104 typename VectorT1::value_type result = 0;
105 for (
typename VectorT1::size_type i=0; i<v1.size(); ++i)
106 result += v1[i] * v2[i];
114 template<
typename NumericT>
117 vector_base<NumericT>
const & vector2)
121 const vector_base<NumericT>,
127 template<
typename LHS,
typename RHS,
typename OP,
typename NumericT>
129 const vector_base<NumericT>,
132 vector_base<NumericT>
const & vector2)
136 const vector_base<NumericT>,
141 template<
typename NumericT,
typename LHS,
typename RHS,
typename OP>
146 viennacl::vector_expression<LHS, RHS, OP>
const & vector2)
150 const viennacl::vector_expression<LHS, RHS, OP>,
155 template<
typename LHS1,
typename RHS1,
typename OP1,
156 typename LHS2,
typename RHS2,
typename OP2>
161 viennacl::vector_expression<LHS2, RHS2, OP2>
const & vector2)
164 return viennacl::scalar_expression< const viennacl::vector_expression<LHS1, RHS1, OP1>,
165 const viennacl::vector_expression<LHS2, RHS2, OP2>,
171 template<
typename NumericT>
174 vector_tuple<NumericT>
const & y_tuple)
177 const vector_tuple<NumericT>,
Simple enable-if variant that uses the SFINAE pattern.
Dispatch facility for distinguishing between ublas, STL and ViennaCL types.
This file provides the forward declarations for the main types used within ViennaCL.
viennacl::enable_if< viennacl::is_stl< typename viennacl::traits::tag_of< VectorT1 >::type >::value, typename VectorT1::value_type >::type inner_prod(VectorT1 const &v1, VectorT2 const &v2)
viennacl::vector_expression< const vector_base< NumericT >, const vector_tuple< NumericT >, viennacl::op_inner_prod > inner_prod(vector_base< NumericT > const &x, vector_tuple< NumericT > const &y_tuple)
A proxy for scalar expressions (e.g. from inner vector products)
An expression template class that represents a binary operation that yields a vector.
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
viennacl::vector< float > v1
Tuple class holding pointers to multiple vectors. Mainly used as a temporary object returned from vie...
viennacl::vector< int > v2
A tag class representing inner products of two vectors.
A collection of compile time type deductions.
Simple enable-if variant that uses the SFINAE pattern.