33 #ifndef EIGEN_GENERAL_MATRIX_VECTOR_MKL_H
34 #define EIGEN_GENERAL_MATRIX_VECTOR_MKL_H
49 template<
typename Index,
typename LhsScalar,
int StorageOrder,
bool ConjugateLhs,
typename RhsScalar,
bool ConjugateRhs>
50 struct general_matrix_vector_product_gemv;
52 #define EIGEN_MKL_GEMV_SPECIALIZE(Scalar) \
53 template<typename Index, bool ConjugateLhs, bool ConjugateRhs> \
54 struct general_matrix_vector_product<Index,Scalar,const_blas_data_mapper<Scalar,Index,ColMajor>,ColMajor,ConjugateLhs,Scalar,const_blas_data_mapper<Scalar,Index,RowMajor>,ConjugateRhs,Specialized> { \
56 Index rows, Index cols, \
57 const const_blas_data_mapper<Scalar,Index,ColMajor> &lhs, \
58 const const_blas_data_mapper<Scalar,Index,RowMajor> &rhs, \
59 Scalar* res, Index resIncr, Scalar alpha) \
62 general_matrix_vector_product<Index,Scalar,const_blas_data_mapper<Scalar,Index,ColMajor>,ColMajor,ConjugateLhs,Scalar,const_blas_data_mapper<Scalar,Index,RowMajor>,ConjugateRhs,BuiltIn>::run( \
63 rows, cols, lhs, rhs, res, resIncr, alpha); \
65 general_matrix_vector_product_gemv<Index,Scalar,ColMajor,ConjugateLhs,Scalar,ConjugateRhs>::run( \
66 rows, cols, lhs.data(), lhs.stride(), rhs.data(), rhs.stride(), res, resIncr, alpha); \
70 template<typename Index, bool ConjugateLhs, bool ConjugateRhs> \
71 struct general_matrix_vector_product<Index,Scalar,const_blas_data_mapper<Scalar,Index,RowMajor>,RowMajor,ConjugateLhs,Scalar,const_blas_data_mapper<Scalar,Index,ColMajor>,ConjugateRhs,Specialized> { \
73 Index rows, Index cols, \
74 const const_blas_data_mapper<Scalar,Index,RowMajor> &lhs, \
75 const const_blas_data_mapper<Scalar,Index,ColMajor> &rhs, \
76 Scalar* res, Index resIncr, Scalar alpha) \
78 general_matrix_vector_product_gemv<Index,Scalar,RowMajor,ConjugateLhs,Scalar,ConjugateRhs>::run( \
79 rows, cols, lhs.data(), lhs.stride(), rhs.data(), rhs.stride(), res, resIncr, alpha); \
83 EIGEN_MKL_GEMV_SPECIALIZE(
double)
84 EIGEN_MKL_GEMV_SPECIALIZE(
float)
85 EIGEN_MKL_GEMV_SPECIALIZE(dcomplex)
86 EIGEN_MKL_GEMV_SPECIALIZE(scomplex)
88 #define EIGEN_MKL_GEMV_SPECIALIZATION(EIGTYPE,MKLTYPE,MKLPREFIX) \
89 template<typename Index, int LhsStorageOrder, bool ConjugateLhs, bool ConjugateRhs> \
90 struct general_matrix_vector_product_gemv<Index,EIGTYPE,LhsStorageOrder,ConjugateLhs,EIGTYPE,ConjugateRhs> \
92 typedef Matrix<EIGTYPE,Dynamic,1,ColMajor> GEMVVector;\
95 Index rows, Index cols, \
96 const EIGTYPE* lhs, Index lhsStride, \
97 const EIGTYPE* rhs, Index rhsIncr, \
98 EIGTYPE* res, Index resIncr, EIGTYPE alpha) \
100 MKL_INT m=rows, n=cols, lda=lhsStride, incx=rhsIncr, incy=resIncr; \
101 MKLTYPE alpha_, beta_; \
102 const EIGTYPE *x_ptr, myone(1); \
103 char trans=(LhsStorageOrder==ColMajor) ? 'N' : (ConjugateLhs) ? 'C' : 'T'; \
104 if (LhsStorageOrder==RowMajor) { \
108 assign_scalar_eig2mkl(alpha_, alpha); \
109 assign_scalar_eig2mkl(beta_, myone); \
111 if (ConjugateRhs) { \
112 Map<const GEMVVector, 0, InnerStride<> > map_x(rhs,cols,1,InnerStride<>(incx)); \
113 x_tmp=map_x.conjugate(); \
114 x_ptr=x_tmp.data(); \
117 MKLPREFIX##gemv(&trans, &m, &n, &alpha_, (const MKLTYPE*)lhs, &lda, (const MKLTYPE*)x_ptr, &incx, &beta_, (MKLTYPE*)res, &incy); \
121 EIGEN_MKL_GEMV_SPECIALIZATION(
double,
double, d)
122 EIGEN_MKL_GEMV_SPECIALIZATION(
float,
float, s)
123 EIGEN_MKL_GEMV_SPECIALIZATION(dcomplex, MKL_Complex16, z)
124 EIGEN_MKL_GEMV_SPECIALIZATION(scomplex, MKL_Complex8, c)
130 #endif // EIGEN_GENERAL_MATRIX_VECTOR_MKL_H
Definition: Eigen_Colamd.h:54