gemv.hpp
Go to the documentation of this file.
1 /*!
2  *
3  *
4  * \brief matrix-vector multiplication kernel
5  *
6  * \author O. Krause
7  * \date 2012
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 SHARK_LINALG_BLAS_KERNELS_GEMV_HPP
31 #define SHARK_LINALG_BLAS_KERNELS_GEMV_HPP
32 
33 #include "default/gemv.hpp"
34 
35 #ifdef SHARK_USE_CBLAS
36 #include "cblas/gemv.hpp"
37 #else
38 // if no bindings are included, we have to provide the default has_optimized_gemv
39 // otherwise the binding will take care of this
40 namespace shark { namespace blas { namespace bindings{
41 template<class M1, class M2, class M3>
42 struct has_optimized_gemv
43 : public boost::mpl::false_{};
44 }}}
45 #endif
46 
47 namespace shark { namespace blas {namespace kernels{
48 
49 ///\brief Well known GEneral Matrix-Vector product kernel M+=alpha*E1*e2.
50 ///
51 /// If bindings are included and the matrix/vector combination allows for a specific binding
52 /// to be applied, the binding is called automatically from {binding}/gemv.h
53 /// otherwise default/gemv.h is used which is fully implemented for all dense/sparse combinations.
54 /// if a combination is optimized, bindings::has_optimized_gemv<M,E1,E2>::type evaluates to boost::mpl::true_
55 /// The kernels themselves are implemented in blas::bindings::gemv.
56 template<class M, class E1, class E2>
57 void gemv(
58  matrix_expression<E1> const& e1,
59  vector_expression<E2> const& e2,
61  typename M::value_type alpha
62 ) {
63  SIZE_CHECK(m().size() == e1().size1());
64  SIZE_CHECK(e1().size2() == e2().size());
65 
67  e1, e2, m,alpha,
68  typename bindings::has_optimized_gemv<M,E1,E2>::type()
69  );
70 }
71 
72 }}}
73 #endif