32 #ifndef SHARK_LINALG_BLAS_KERNELS_CBLAS_GEMV_HPP 33 #define SHARK_LINALG_BLAS_KERNELS_CBLAS_GEMV_HPP 37 namespace shark {
namespace blas {
namespace bindings {
39 inline void gemv(CBLAS_ORDER
const Order,
40 CBLAS_TRANSPOSE
const TransA,
int const M,
int const N,
41 double alpha,
float const *A,
int const lda,
42 float const *X,
int const incX,
43 double beta,
float *Y,
int const incY
45 cblas_sgemv(Order, TransA, M, N, alpha, A, lda,
50 inline void gemv(CBLAS_ORDER
const Order,
51 CBLAS_TRANSPOSE
const TransA,
int const M,
int const N,
52 double alpha,
double const *A,
int const lda,
53 double const *X,
int const incX,
54 double beta,
double *Y,
int const incY
56 cblas_dgemv(Order, TransA, M, N, alpha, A, lda,
61 inline void gemv(CBLAS_ORDER
const Order,
62 CBLAS_TRANSPOSE
const TransA,
int const M,
int const N,
64 std::complex<float>
const *A,
int const lda,
65 std::complex<float>
const *X,
int const incX,
67 std::complex<float> *Y,
int const incY
69 std::complex<float> alphaArg(alpha,0);
70 std::complex<float> betaArg(beta,0);
71 cblas_cgemv(Order, TransA, M, N,
72 reinterpret_cast<cblas_float_complex_type const *>(&alphaArg),
73 reinterpret_cast<cblas_float_complex_type const *>(A), lda,
74 reinterpret_cast<cblas_float_complex_type const *>(X), incX,
75 reinterpret_cast<cblas_float_complex_type const *>(&betaArg),
76 reinterpret_cast<cblas_float_complex_type *>(Y), incY);
79 inline void gemv(CBLAS_ORDER
const Order,
80 CBLAS_TRANSPOSE
const TransA,
int const M,
int const N,
82 std::complex<double>
const *A,
int const lda,
83 std::complex<double>
const *X,
int const incX,
85 std::complex<double> *Y,
int const incY
87 std::complex<double> alphaArg(alpha,0);
88 std::complex<double> betaArg(beta,0);
89 cblas_zgemv(Order, TransA, M, N,
90 reinterpret_cast<cblas_double_complex_type const *>(&alphaArg),
91 reinterpret_cast<cblas_double_complex_type const *>(A), lda,
92 reinterpret_cast<cblas_double_complex_type const *>(X), incX,
93 reinterpret_cast<cblas_double_complex_type const *>(&betaArg),
94 reinterpret_cast<cblas_double_complex_type *>(Y), incY);
100 template <
typename MatrA,
typename VectorX,
typename VectorY>
102 matrix_expression<MatrA>
const &A,
103 vector_expression<VectorX>
const &x,
104 vector_expression<VectorY> &y,
105 typename VectorY::value_type alpha,
108 std::size_t m = A().size1();
109 std::size_t n = A().size2();
114 CBLAS_ORDER
const stor_ord= (CBLAS_ORDER)storage_order<typename MatrA::orientation>::value;
116 gemv(stor_ord, CblasNoTrans, (
int)m, (
int)n, alpha,
118 traits::leading_dimension(A),
121 typename VectorY::value_type(1),
127 template<
class Storage1,
class Storage2,
class Storage3,
class T1,
class T2,
class T3>
128 struct optimized_gemv_detail{
129 typedef boost::mpl::false_ type;
132 struct optimized_gemv_detail<
133 dense_tag, dense_tag, dense_tag,
134 double, double, double
136 typedef boost::mpl::true_ type;
139 struct optimized_gemv_detail<
140 dense_tag, dense_tag, dense_tag,
143 typedef boost::mpl::true_ type;
147 struct optimized_gemv_detail<
148 dense_tag, dense_tag, dense_tag,
149 std::complex<double>, std::complex<double>, std::complex<double>
151 typedef boost::mpl::true_ type;
154 struct optimized_gemv_detail<
155 dense_tag, dense_tag, dense_tag,
156 std::complex<float>, std::complex<float>, std::complex<float>
158 typedef boost::mpl::true_ type;
161 template<
class M1,
class M2,
class M3>
162 struct has_optimized_gemv
163 :
public optimized_gemv_detail<
164 typename M1::storage_category,
165 typename M2::storage_category,
166 typename M3::storage_category,
167 typename M1::value_type,
168 typename M2::value_type,
169 typename M3::value_type