sum_rows.hpp
Go to the documentation of this file.
1 /*!
2  *
3  *
4  * \brief Sums the rows of a row-major or column major matrix.
5  *
6  * \author O. Krause
7  * \date 2016
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 
31 #ifndef REMORA_KERNELS_SUM_ROWS_HPP
32 #define REMORA_KERNELS_SUM_ROWS_HPP
33 
34 #include "default/sum_rows.hpp"
35 #ifdef REMORA_USE_GPU
36 #include "gpu/sum_rows.hpp"
37 #endif
38 
39 namespace remora {namespace bindings{
40 template<class M,class V, class Device, class Tag1, class Tag2>
41 void sum_rows(
42  matrix_expression<M, Device> const & A,
43  vector_expression<V, Device>& b,
44  typename V::value_type alpha,
45  unknown_orientation,
46  Tag1, Tag2
47 ){
48  sum_rows(A,b,alpha,row_major(), Tag1(), Tag2());
49 }
50 }
51 
52 namespace kernels{
53 ///\brief Sums the rows of a row-major or column major matrix.
54 ///
55 /// This is equivalent to the operation v=1^TA where 1 is the vector of all-ones
56 template <class M, class V, class Device>
57 void sum_rows(
58  matrix_expression<M, Device> const & A,
59  vector_expression<V, Device>& b,
60  typename V::value_type alpha
61 ){
62  REMORA_SIZE_CHECK(A().size2() == b().size());
63 
64  bindings::sum_rows(A,b,alpha,typename M::orientation(),
65  typename M::evaluation_category::tag(), typename V::evaluation_category::tag());
66 }
67 
68 }}
69 
70 #endif