30 #ifndef REMORA_KERNELS_DEFAULT_DOT_HPP 31 #define REMORA_KERNELS_DEFAULT_DOT_HPP 33 #include "../../expression_types.hpp" 34 #include "../../detail/traits.hpp" 36 namespace remora{
namespace bindings{
39 template<
class E1,
class E2,
class result_type>
41 vector_expression<E1, cpu_tag>
const& v1,
42 vector_expression<E2, cpu_tag>
const& v2,
47 std::size_t size = v1().size();
48 result = result_type();
49 for(std::size_t i = 0; i != size; ++i){
50 result += v1()(i) * v2()(i);
54 template<
class E1,
class E2,
class result_type>
56 vector_expression<E1, cpu_tag>
const& v1,
57 vector_expression<E2, cpu_tag>
const& v2,
62 typename E1::const_iterator iter1=v1().begin();
63 typename E1::const_iterator end1=v1().end();
64 typename E2::const_iterator iter2=v2().begin();
65 typename E2::const_iterator end2=v2().end();
66 result = result_type();
68 while(iter1 != end1 && iter2 != end2)
70 std::size_t index1=iter1.index();
71 std::size_t index2=iter2.index();
73 result += *iter1 * *iter2;
77 else if(index1> index2){
87 template<
class E1,
class E2,
class result_type>
89 vector_expression<E1, cpu_tag>
const& v1,
90 vector_expression<E2, cpu_tag>
const& v2,
95 typename E2::const_iterator iter2=v2().begin();
96 typename E2::const_iterator end2=v2().end();
97 result = result_type();
98 for(;iter2 != end2;++iter2){
99 result += v1()(iter2.index()) * *iter2;
103 template<
class E1,
class E2,
class result_type>
105 vector_expression<E1, cpu_tag>
const& v1,
106 vector_expression<E2, cpu_tag>
const& v2,
112 dot(v2,v1,result,t2,t1);