33 #ifndef EIGEN_SELFADJOINT_MATRIX_MATRIX_BLAS_H
34 #define EIGEN_SELFADJOINT_MATRIX_MATRIX_BLAS_H
36 #include "../InternalHeaderCheck.h"
45 #define EIGEN_BLAS_SYMM_L(EIGTYPE, BLASTYPE, EIGPREFIX, BLASFUNC) \
46 template <typename Index, \
47 int LhsStorageOrder, bool ConjugateLhs, \
48 int RhsStorageOrder, bool ConjugateRhs> \
49 struct product_selfadjoint_matrix<EIGTYPE,Index,LhsStorageOrder,true,ConjugateLhs,RhsStorageOrder,false,ConjugateRhs,ColMajor,1> \
53 Index rows, Index cols, \
54 const EIGTYPE* _lhs, Index lhsStride, \
55 const EIGTYPE* _rhs, Index rhsStride, \
56 EIGTYPE* res, Index resIncr, Index resStride, \
57 EIGTYPE alpha, level3_blocking<EIGTYPE, EIGTYPE>& ) \
59 EIGEN_ONLY_USED_FOR_DEBUG(resIncr); \
60 eigen_assert(resIncr == 1); \
61 char side='L', uplo='L'; \
62 BlasIndex m, n, lda, ldb, ldc; \
63 const EIGTYPE *a, *b; \
65 MatrixX##EIGPREFIX b_tmp; \
69 m = convert_index<BlasIndex>(rows); \
70 n = convert_index<BlasIndex>(cols); \
73 lda = convert_index<BlasIndex>(lhsStride); \
74 ldb = convert_index<BlasIndex>(rhsStride); \
75 ldc = convert_index<BlasIndex>(resStride); \
78 if (LhsStorageOrder==RowMajor) uplo='U'; \
81 if (RhsStorageOrder==RowMajor) { \
82 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > rhs(_rhs,n,m,OuterStride<>(rhsStride)); \
83 b_tmp = rhs.adjoint(); \
85 ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \
88 BLASFUNC(&side, &uplo, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (const BLASTYPE*)b, &ldb, (const BLASTYPE*)&numext::real_ref(beta), (BLASTYPE*)res, &ldc); \
94 #define EIGEN_BLAS_HEMM_L(EIGTYPE, BLASTYPE, EIGPREFIX, BLASFUNC) \
95 template <typename Index, \
96 int LhsStorageOrder, bool ConjugateLhs, \
97 int RhsStorageOrder, bool ConjugateRhs> \
98 struct product_selfadjoint_matrix<EIGTYPE,Index,LhsStorageOrder,true,ConjugateLhs,RhsStorageOrder,false,ConjugateRhs,ColMajor,1> \
101 Index rows, Index cols, \
102 const EIGTYPE* _lhs, Index lhsStride, \
103 const EIGTYPE* _rhs, Index rhsStride, \
104 EIGTYPE* res, Index resIncr, Index resStride, \
105 EIGTYPE alpha, level3_blocking<EIGTYPE, EIGTYPE>& ) \
107 EIGEN_ONLY_USED_FOR_DEBUG(resIncr); \
108 eigen_assert(resIncr == 1); \
109 char side='L', uplo='L'; \
110 BlasIndex m, n, lda, ldb, ldc; \
111 const EIGTYPE *a, *b; \
113 MatrixX##EIGPREFIX b_tmp; \
114 Matrix<EIGTYPE, Dynamic, Dynamic, LhsStorageOrder> a_tmp; \
118 m = convert_index<BlasIndex>(rows); \
119 n = convert_index<BlasIndex>(cols); \
122 lda = convert_index<BlasIndex>(lhsStride); \
123 ldb = convert_index<BlasIndex>(rhsStride); \
124 ldc = convert_index<BlasIndex>(resStride); \
127 if (((LhsStorageOrder==ColMajor) && ConjugateLhs) || ((LhsStorageOrder==RowMajor) && (!ConjugateLhs))) { \
128 Map<const Matrix<EIGTYPE, Dynamic, Dynamic, LhsStorageOrder>, 0, OuterStride<> > lhs(_lhs,m,m,OuterStride<>(lhsStride)); \
129 a_tmp = lhs.conjugate(); \
131 lda = convert_index<BlasIndex>(a_tmp.outerStride()); \
133 if (LhsStorageOrder==RowMajor) uplo='U'; \
135 if (RhsStorageOrder==ColMajor && (!ConjugateRhs)) { \
138 if (RhsStorageOrder==ColMajor && ConjugateRhs) { \
139 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > rhs(_rhs,m,n,OuterStride<>(rhsStride)); \
140 b_tmp = rhs.conjugate(); \
142 if (ConjugateRhs) { \
143 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > rhs(_rhs,n,m,OuterStride<>(rhsStride)); \
144 b_tmp = rhs.adjoint(); \
146 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > rhs(_rhs,n,m,OuterStride<>(rhsStride)); \
147 b_tmp = rhs.transpose(); \
150 ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \
153 BLASFUNC(&side, &uplo, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (const BLASTYPE*)b, &ldb, (const BLASTYPE*)&numext::real_ref(beta), (BLASTYPE*)res, &ldc); \
172 #define EIGEN_BLAS_SYMM_R(EIGTYPE, BLASTYPE, EIGPREFIX, BLASFUNC) \
173 template <typename Index, \
174 int LhsStorageOrder, bool ConjugateLhs, \
175 int RhsStorageOrder, bool ConjugateRhs> \
176 struct product_selfadjoint_matrix<EIGTYPE,Index,LhsStorageOrder,false,ConjugateLhs,RhsStorageOrder,true,ConjugateRhs,ColMajor,1> \
180 Index rows, Index cols, \
181 const EIGTYPE* _lhs, Index lhsStride, \
182 const EIGTYPE* _rhs, Index rhsStride, \
183 EIGTYPE* res, Index resIncr, Index resStride, \
184 EIGTYPE alpha, level3_blocking<EIGTYPE, EIGTYPE>& ) \
186 EIGEN_ONLY_USED_FOR_DEBUG(resIncr); \
187 eigen_assert(resIncr == 1); \
188 char side='R', uplo='L'; \
189 BlasIndex m, n, lda, ldb, ldc; \
190 const EIGTYPE *a, *b; \
192 MatrixX##EIGPREFIX b_tmp; \
195 m = convert_index<BlasIndex>(rows); \
196 n = convert_index<BlasIndex>(cols); \
199 lda = convert_index<BlasIndex>(rhsStride); \
200 ldb = convert_index<BlasIndex>(lhsStride); \
201 ldc = convert_index<BlasIndex>(resStride); \
204 if (RhsStorageOrder==RowMajor) uplo='U'; \
207 if (LhsStorageOrder==RowMajor) { \
208 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > lhs(_lhs,n,m,OuterStride<>(rhsStride)); \
209 b_tmp = lhs.adjoint(); \
211 ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \
214 BLASFUNC(&side, &uplo, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (const BLASTYPE*)b, &ldb, (const BLASTYPE*)&numext::real_ref(beta), (BLASTYPE*)res, &ldc); \
220 #define EIGEN_BLAS_HEMM_R(EIGTYPE, BLASTYPE, EIGPREFIX, BLASFUNC) \
221 template <typename Index, \
222 int LhsStorageOrder, bool ConjugateLhs, \
223 int RhsStorageOrder, bool ConjugateRhs> \
224 struct product_selfadjoint_matrix<EIGTYPE,Index,LhsStorageOrder,false,ConjugateLhs,RhsStorageOrder,true,ConjugateRhs,ColMajor,1> \
227 Index rows, Index cols, \
228 const EIGTYPE* _lhs, Index lhsStride, \
229 const EIGTYPE* _rhs, Index rhsStride, \
230 EIGTYPE* res, Index resIncr, Index resStride, \
231 EIGTYPE alpha, level3_blocking<EIGTYPE, EIGTYPE>& ) \
233 EIGEN_ONLY_USED_FOR_DEBUG(resIncr); \
234 eigen_assert(resIncr == 1); \
235 char side='R', uplo='L'; \
236 BlasIndex m, n, lda, ldb, ldc; \
237 const EIGTYPE *a, *b; \
239 MatrixX##EIGPREFIX b_tmp; \
240 Matrix<EIGTYPE, Dynamic, Dynamic, RhsStorageOrder> a_tmp; \
243 m = convert_index<BlasIndex>(rows); \
244 n = convert_index<BlasIndex>(cols); \
247 lda = convert_index<BlasIndex>(rhsStride); \
248 ldb = convert_index<BlasIndex>(lhsStride); \
249 ldc = convert_index<BlasIndex>(resStride); \
252 if (((RhsStorageOrder==ColMajor) && ConjugateRhs) || ((RhsStorageOrder==RowMajor) && (!ConjugateRhs))) { \
253 Map<const Matrix<EIGTYPE, Dynamic, Dynamic, RhsStorageOrder>, 0, OuterStride<> > rhs(_rhs,n,n,OuterStride<>(rhsStride)); \
254 a_tmp = rhs.conjugate(); \
256 lda = convert_index<BlasIndex>(a_tmp.outerStride()); \
258 if (RhsStorageOrder==RowMajor) uplo='U'; \
260 if (LhsStorageOrder==ColMajor && (!ConjugateLhs)) { \
263 if (LhsStorageOrder==ColMajor && ConjugateLhs) { \
264 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > lhs(_lhs,m,n,OuterStride<>(lhsStride)); \
265 b_tmp = lhs.conjugate(); \
267 if (ConjugateLhs) { \
268 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > lhs(_lhs,n,m,OuterStride<>(lhsStride)); \
269 b_tmp = lhs.adjoint(); \
271 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > lhs(_lhs,n,m,OuterStride<>(lhsStride)); \
272 b_tmp = lhs.transpose(); \
275 ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \
278 BLASFUNC(&side, &uplo, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (const BLASTYPE*)b, &ldb, (const BLASTYPE*)&numext::real_ref(beta), (BLASTYPE*)res, &ldc); \
#define EIGEN_BLAS_HEMM_L(EIGTYPE, BLASTYPE, EIGPREFIX, BLASFUNC)
#define EIGEN_BLAS_HEMM_R(EIGTYPE, BLASTYPE, EIGPREFIX, BLASFUNC)
#define EIGEN_BLAS_SYMM_R(EIGTYPE, BLASTYPE, EIGPREFIX, BLASFUNC)
#define EIGEN_BLAS_SYMM_L(EIGTYPE, BLASTYPE, EIGPREFIX, BLASFUNC)
int BLASFUNC() chemm(const char *, const char *, const int *, const int *, const float *, const float *, const int *, const float *, const int *, const float *, float *, const int *)
int BLASFUNC() zhemm(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *)
int BLASFUNC() dsymm(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *)
int BLASFUNC() ssymm(const char *, const char *, const int *, const int *, const float *, const float *, const int *, const float *, const int *, const float *, float *, const int *)
std::complex< double > dcomplex
std::complex< float > scomplex