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_GENERAL_MATRIX_MATRIX_TRIANGULAR_MKL_H
00034 #define EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_MKL_H
00035
00036 namespace Eigen {
00037
00038 namespace internal {
00039
00040 template <typename Index, typename Scalar, int AStorageOrder, bool ConjugateA, int ResStorageOrder, int UpLo>
00041 struct general_matrix_matrix_rankupdate :
00042 general_matrix_matrix_triangular_product<
00043 Index,Scalar,AStorageOrder,ConjugateA,Scalar,AStorageOrder,ConjugateA,ResStorageOrder,UpLo,BuiltIn> {};
00044
00045
00046
00047 #define EIGEN_MKL_RANKUPDATE_SPECIALIZE(Scalar) \
00048 template <typename Index, int LhsStorageOrder, bool ConjugateLhs, \
00049 int RhsStorageOrder, bool ConjugateRhs, int UpLo> \
00050 struct general_matrix_matrix_triangular_product<Index,Scalar,LhsStorageOrder,ConjugateLhs, \
00051 Scalar,RhsStorageOrder,ConjugateRhs,ColMajor,UpLo,Specialized> { \
00052 static EIGEN_STRONG_INLINE void run(Index size, Index depth,const Scalar* lhs, Index lhsStride, \
00053 const Scalar* rhs, Index rhsStride, Scalar* res, Index resStride, Scalar alpha) \
00054 { \
00055 if (lhs==rhs) { \
00056 general_matrix_matrix_rankupdate<Index,Scalar,LhsStorageOrder,ConjugateLhs,ColMajor,UpLo> \
00057 ::run(size,depth,lhs,lhsStride,rhs,rhsStride,res,resStride,alpha); \
00058 } else { \
00059 general_matrix_matrix_triangular_product<Index, \
00060 Scalar, LhsStorageOrder, ConjugateLhs, \
00061 Scalar, RhsStorageOrder, ConjugateRhs, \
00062 ColMajor, UpLo, BuiltIn> \
00063 ::run(size,depth,lhs,lhsStride,rhs,rhsStride,res,resStride,alpha); \
00064 } \
00065 } \
00066 };
00067
00068 EIGEN_MKL_RANKUPDATE_SPECIALIZE(double)
00069
00070 EIGEN_MKL_RANKUPDATE_SPECIALIZE(float)
00071
00072
00073
00074 #define EIGEN_MKL_RANKUPDATE_R(EIGTYPE, MKLTYPE, MKLFUNC) \
00075 template <typename Index, int AStorageOrder, bool ConjugateA, int UpLo> \
00076 struct general_matrix_matrix_rankupdate<Index,EIGTYPE,AStorageOrder,ConjugateA,ColMajor,UpLo> { \
00077 enum { \
00078 IsLower = (UpLo&Lower) == Lower, \
00079 LowUp = IsLower ? Lower : Upper, \
00080 conjA = ((AStorageOrder==ColMajor) && ConjugateA) ? 1 : 0 \
00081 }; \
00082 static EIGEN_STRONG_INLINE void run(Index size, Index depth,const EIGTYPE* lhs, Index lhsStride, \
00083 const EIGTYPE* rhs, Index rhsStride, EIGTYPE* res, Index resStride, EIGTYPE alpha) \
00084 { \
00085 \
00086 \
00087 MKL_INT lda=lhsStride, ldc=resStride, n=size, k=depth; \
00088 char uplo=(IsLower) ? 'L' : 'U', trans=(AStorageOrder==RowMajor) ? 'T':'N'; \
00089 MKLTYPE alpha_, beta_; \
00090 \
00091 \
00092 assign_scalar_eig2mkl<MKLTYPE, EIGTYPE>(alpha_, alpha); \
00093 assign_scalar_eig2mkl<MKLTYPE, EIGTYPE>(beta_, EIGTYPE(1)); \
00094 MKLFUNC(&uplo, &trans, &n, &k, &alpha_, lhs, &lda, &beta_, res, &ldc); \
00095 } \
00096 };
00097
00098
00099 #define EIGEN_MKL_RANKUPDATE_C(EIGTYPE, MKLTYPE, RTYPE, MKLFUNC) \
00100 template <typename Index, int AStorageOrder, bool ConjugateA, int UpLo> \
00101 struct general_matrix_matrix_rankupdate<Index,EIGTYPE,AStorageOrder,ConjugateA,ColMajor,UpLo> { \
00102 enum { \
00103 IsLower = (UpLo&Lower) == Lower, \
00104 LowUp = IsLower ? Lower : Upper, \
00105 conjA = (((AStorageOrder==ColMajor) && ConjugateA) || ((AStorageOrder==RowMajor) && !ConjugateA)) ? 1 : 0 \
00106 }; \
00107 static EIGEN_STRONG_INLINE void run(Index size, Index depth,const EIGTYPE* lhs, Index lhsStride, \
00108 const EIGTYPE* rhs, Index rhsStride, EIGTYPE* res, Index resStride, EIGTYPE alpha) \
00109 { \
00110 typedef Matrix<EIGTYPE, Dynamic, Dynamic, AStorageOrder> MatrixType; \
00111 \
00112 MKL_INT lda=lhsStride, ldc=resStride, n=size, k=depth; \
00113 char uplo=(IsLower) ? 'L' : 'U', trans=(AStorageOrder==RowMajor) ? 'C':'N'; \
00114 RTYPE alpha_, beta_; \
00115 const EIGTYPE* a_ptr; \
00116 \
00117 \
00118 \
00119 \
00120 alpha_ = alpha.real(); \
00121 beta_ = 1.0; \
00122 \
00123 MatrixType a; \
00124 if (conjA) { \
00125 Map<const MatrixType, 0, OuterStride<> > mapA(lhs,n,k,OuterStride<>(lhsStride)); \
00126 a = mapA.conjugate(); \
00127 lda = a.outerStride(); \
00128 a_ptr = a.data(); \
00129 } else a_ptr=lhs; \
00130 MKLFUNC(&uplo, &trans, &n, &k, &alpha_, (MKLTYPE*)a_ptr, &lda, &beta_, (MKLTYPE*)res, &ldc); \
00131 } \
00132 };
00133
00134
00135 EIGEN_MKL_RANKUPDATE_R(double, double, dsyrk)
00136 EIGEN_MKL_RANKUPDATE_R(float, float, ssyrk)
00137
00138
00139
00140
00141
00142 }
00143
00144 }
00145
00146 #endif // EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_MKL_H