00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef EIGEN_SELFADJOINT_MATRIX_VECTOR_MKL_H
00034 #define EIGEN_SELFADJOINT_MATRIX_VECTOR_MKL_H
00035
00036 namespace Eigen {
00037
00038 namespace internal {
00039
00040
00041
00042
00043
00044
00045
00046 template<typename Scalar, typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs>
00047 struct selfadjoint_matrix_vector_product_symv :
00048 selfadjoint_matrix_vector_product<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs,BuiltIn> {};
00049
00050 #define EIGEN_MKL_SYMV_SPECIALIZE(Scalar) \
00051 template<typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs> \
00052 struct selfadjoint_matrix_vector_product<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs,Specialized> { \
00053 static EIGEN_DONT_INLINE void run( \
00054 Index size, const Scalar* lhs, Index lhsStride, \
00055 const Scalar* _rhs, Index rhsIncr, Scalar* res, Scalar alpha) { \
00056 enum {\
00057 IsColMajor = StorageOrder==ColMajor \
00058 }; \
00059 if (IsColMajor == ConjugateLhs) {\
00060 selfadjoint_matrix_vector_product<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs,BuiltIn>::run( \
00061 size, lhs, lhsStride, _rhs, rhsIncr, res, alpha); \
00062 } else {\
00063 selfadjoint_matrix_vector_product_symv<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs>::run( \
00064 size, lhs, lhsStride, _rhs, rhsIncr, res, alpha); \
00065 }\
00066 } \
00067 }; \
00068
00069 EIGEN_MKL_SYMV_SPECIALIZE(double)
00070 EIGEN_MKL_SYMV_SPECIALIZE(float)
00071 EIGEN_MKL_SYMV_SPECIALIZE(dcomplex)
00072 EIGEN_MKL_SYMV_SPECIALIZE(scomplex)
00073
00074 #define EIGEN_MKL_SYMV_SPECIALIZATION(EIGTYPE,MKLTYPE,MKLFUNC) \
00075 template<typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs> \
00076 struct selfadjoint_matrix_vector_product_symv<EIGTYPE,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs> \
00077 { \
00078 typedef Matrix<EIGTYPE,Dynamic,1,ColMajor> SYMVVector;\
00079 \
00080 static EIGEN_DONT_INLINE void run( \
00081 Index size, const EIGTYPE* lhs, Index lhsStride, \
00082 const EIGTYPE* _rhs, Index rhsIncr, EIGTYPE* res, EIGTYPE alpha) \
00083 { \
00084 enum {\
00085 IsRowMajor = StorageOrder==RowMajor ? 1 : 0, \
00086 IsLower = UpLo == Lower ? 1 : 0 \
00087 }; \
00088 MKL_INT n=size, lda=lhsStride, incx=rhsIncr, incy=1; \
00089 MKLTYPE alpha_, beta_; \
00090 const EIGTYPE *x_ptr, myone(1); \
00091 char uplo=(IsRowMajor) ? (IsLower ? 'U' : 'L') : (IsLower ? 'L' : 'U'); \
00092 assign_scalar_eig2mkl(alpha_, alpha); \
00093 assign_scalar_eig2mkl(beta_, myone); \
00094 SYMVVector x_tmp; \
00095 if (ConjugateRhs) { \
00096 Map<const SYMVVector, 0, InnerStride<> > map_x(_rhs,size,1,InnerStride<>(incx)); \
00097 x_tmp=map_x.conjugate(); \
00098 x_ptr=x_tmp.data(); \
00099 incx=1; \
00100 } else x_ptr=_rhs; \
00101 MKLFUNC(&uplo, &n, &alpha_, (const MKLTYPE*)lhs, &lda, (const MKLTYPE*)x_ptr, &incx, &beta_, (MKLTYPE*)res, &incy); \
00102 }\
00103 };
00104
00105 EIGEN_MKL_SYMV_SPECIALIZATION(double, double, dsymv)
00106 EIGEN_MKL_SYMV_SPECIALIZATION(float, float, ssymv)
00107 EIGEN_MKL_SYMV_SPECIALIZATION(dcomplex, MKL_Complex16, zhemv)
00108 EIGEN_MKL_SYMV_SPECIALIZATION(scomplex, MKL_Complex8, chemv)
00109
00110 }
00111
00112 }
00113
00114 #endif // EIGEN_SELFADJOINT_MATRIX_VECTOR_MKL_H