33#ifndef EIGEN_GENERAL_MATRIX_VECTOR_MKL_H
34#define EIGEN_GENERAL_MATRIX_VECTOR_MKL_H
49template<
typename Index,
typename LhsScalar,
int LhsStorageOrder,
bool ConjugateLhs,
typename RhsScalar,
bool ConjugateRhs>
50struct general_matrix_vector_product_gemv :
51 general_matrix_vector_product<Index,LhsScalar,LhsStorageOrder,ConjugateLhs,RhsScalar,ConjugateRhs,BuiltIn> {};
53#define EIGEN_MKL_GEMV_SPECIALIZE(Scalar) \
54template<typename Index, bool ConjugateLhs, bool ConjugateRhs> \
55struct general_matrix_vector_product<Index,Scalar,ColMajor,ConjugateLhs,Scalar,ConjugateRhs,Specialized> { \
56static EIGEN_DONT_INLINE void run( \
57 Index rows, Index cols, \
58 const Scalar* lhs, Index lhsStride, \
59 const Scalar* rhs, Index rhsIncr, \
60 Scalar* res, Index resIncr, Scalar alpha) \
63 general_matrix_vector_product<Index,Scalar,ColMajor,ConjugateLhs,Scalar,ConjugateRhs,BuiltIn>::run( \
64 rows, cols, lhs, lhsStride, rhs, rhsIncr, res, resIncr, alpha); \
66 general_matrix_vector_product_gemv<Index,Scalar,ColMajor,ConjugateLhs,Scalar,ConjugateRhs>::run( \
67 rows, cols, lhs, lhsStride, rhs, rhsIncr, res, resIncr, alpha); \
71template<typename Index, bool ConjugateLhs, bool ConjugateRhs> \
72struct general_matrix_vector_product<Index,Scalar,RowMajor,ConjugateLhs,Scalar,ConjugateRhs,Specialized> { \
73static EIGEN_DONT_INLINE void run( \
74 Index rows, Index cols, \
75 const Scalar* lhs, Index lhsStride, \
76 const Scalar* rhs, Index rhsIncr, \
77 Scalar* res, Index resIncr, Scalar alpha) \
79 general_matrix_vector_product_gemv<Index,Scalar,RowMajor,ConjugateLhs,Scalar,ConjugateRhs>::run( \
80 rows, cols, lhs, lhsStride, rhs, rhsIncr, res, resIncr, alpha); \
84EIGEN_MKL_GEMV_SPECIALIZE(
double)
85EIGEN_MKL_GEMV_SPECIALIZE(
float)
86EIGEN_MKL_GEMV_SPECIALIZE(dcomplex)
87EIGEN_MKL_GEMV_SPECIALIZE(scomplex)
89#define EIGEN_MKL_GEMV_SPECIALIZATION(EIGTYPE,MKLTYPE,MKLPREFIX) \
90template<typename Index, int LhsStorageOrder, bool ConjugateLhs, bool ConjugateRhs> \
91struct general_matrix_vector_product_gemv<Index,EIGTYPE,LhsStorageOrder,ConjugateLhs,EIGTYPE,ConjugateRhs> \
93typedef Matrix<EIGTYPE,Dynamic,1,ColMajor> GEMVVector;\
95static EIGEN_DONT_INLINE void run( \
96 Index rows, Index cols, \
97 const EIGTYPE* lhs, Index lhsStride, \
98 const EIGTYPE* rhs, Index rhsIncr, \
99 EIGTYPE* res, Index resIncr, EIGTYPE alpha) \
101 MKL_INT m=rows, n=cols, lda=lhsStride, incx=rhsIncr, incy=resIncr; \
102 MKLTYPE alpha_, beta_; \
103 const EIGTYPE *x_ptr, myone(1); \
104 char trans=(LhsStorageOrder==ColMajor) ? 'N' : (ConjugateLhs) ? 'C' : 'T'; \
105 if (LhsStorageOrder==RowMajor) { \
109 assign_scalar_eig2mkl(alpha_, alpha); \
110 assign_scalar_eig2mkl(beta_, myone); \
112 if (ConjugateRhs) { \
113 Map<const GEMVVector, 0, InnerStride<> > map_x(rhs,cols,1,InnerStride<>(incx)); \
114 x_tmp=map_x.conjugate(); \
115 x_ptr=x_tmp.data(); \
118 MKLPREFIX##gemv(&trans, &m, &n, &alpha_, (const MKLTYPE*)lhs, &lda, (const MKLTYPE*)x_ptr, &incx, &beta_, (MKLTYPE*)res, &incy); \
122EIGEN_MKL_GEMV_SPECIALIZATION(
double,
double, d)
123EIGEN_MKL_GEMV_SPECIALIZATION(
float,
float, s)
124EIGEN_MKL_GEMV_SPECIALIZATION(dcomplex, MKL_Complex16, z)
125EIGEN_MKL_GEMV_SPECIALIZATION(scomplex, MKL_Complex8, c)