dot.hpp
Go to the documentation of this file.
1 /*!
2  *
3  *
4  * \brief dot-product of vectors
5  *
6  * \author O. Krause
7  * \date 2013
8  *
9  *
10  * \par Copyright 1995-2015 Shark Development Team
11  *
12  * <BR><HR>
13  * This file is part of Shark.
14  * <http://image.diku.dk/shark/>
15  *
16  * Shark is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU Lesser General Public License as published
18  * by the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * Shark is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU Lesser General Public License for more details.
25  *
26  * You should have received a copy of the GNU Lesser General Public License
27  * along with Shark. If not, see <http://www.gnu.org/licenses/>.
28  *
29  */
30 #ifndef REMORA_KERNELS_DOT_HPP
31 #define REMORA_KERNELS_DOT_HPP
32 
33 #include "default/dot.hpp"
34 #ifdef REMORA_USE_GPU
35 #include "gpu/dot.hpp"
36 #endif
37 
38 namespace remora{namespace kernels{
39 
40 ///\brief Well known dot-product r=<e1,e2>=sum_i e1_i*e2_i.
41 ///
42 /// If bindings are included and the vector combination allows for a specific binding
43 /// to be applied, the binding is called automatically from {binding}/dot.h
44 /// otherwise default/dot.h is used which is fully implemented for all dense/sparse combinations.
45 /// if a combination is optimized, bindings::has_optimized_dot<E1,E2,R>::type evaluates to std::true_type
46 /// The kernels themselves are implemented in bindings::dot.
47 template<class E1, class E2, class result_type, class Device>
48 void dot(
49  vector_expression<E1, Device> const& e1,
50  vector_expression<E2, Device> const& e2,
51  result_type& result
52 ) {
53  REMORA_SIZE_CHECK(e1().size() == e2().size());
54 
55  bindings::dot(
56  e1, e2,result,typename E1::evaluation_category::tag(), typename E2::evaluation_category::tag()
57  );
58 }
59 
60 }}
61 #endif