33 #ifndef EIGEN_SELFADJOINT_MATRIX_MATRIX_BLAS_H 34 #define EIGEN_SELFADJOINT_MATRIX_MATRIX_BLAS_H 37 #include "../InternalHeaderCheck.h" 45 #define EIGEN_BLAS_SYMM_L(EIGTYPE, BLASTYPE, EIGPREFIX, BLASFUNC) \ 46 template <typename Index, int LhsStorageOrder, bool ConjugateLhs, int RhsStorageOrder, bool ConjugateRhs> \ 47 struct product_selfadjoint_matrix<EIGTYPE, Index, LhsStorageOrder, true, ConjugateLhs, RhsStorageOrder, false, \ 48 ConjugateRhs, ColMajor, 1> { \ 49 static void run(Index rows, Index cols, const EIGTYPE* _lhs, Index lhsStride, const EIGTYPE* _rhs, \ 50 Index rhsStride, EIGTYPE* res, Index resIncr, Index resStride, EIGTYPE alpha, \ 51 level3_blocking<EIGTYPE, EIGTYPE>& ) { \ 52 if (rows == 0 || cols == 0) return; \ 53 EIGEN_ONLY_USED_FOR_DEBUG(resIncr); \ 54 eigen_assert(resIncr == 1); \ 55 char side = 'L', uplo = 'L'; \ 56 BlasIndex m, n, lda, ldb, ldc; \ 57 const EIGTYPE *a, *b; \ 59 MatrixX##EIGPREFIX b_tmp; \ 63 m = convert_index<BlasIndex>(rows); \ 64 n = convert_index<BlasIndex>(cols); \ 67 lda = convert_index<BlasIndex>(lhsStride); \ 68 ldb = convert_index<BlasIndex>(rhsStride); \ 69 ldc = convert_index<BlasIndex>(resStride); \ 72 if (LhsStorageOrder == RowMajor) uplo = 'U'; \ 75 if (RhsStorageOrder == RowMajor) { \ 76 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > rhs(_rhs, n, m, OuterStride<>(rhsStride)); \ 77 b_tmp = rhs.adjoint(); \ 79 ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \ 83 BLASFUNC(&side, &uplo, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)a, &lda, \ 84 (const BLASTYPE*)b, &ldb, (const BLASTYPE*)&numext::real_ref(beta), (BLASTYPE*)res, &ldc); \ 88 #define EIGEN_BLAS_HEMM_L(EIGTYPE, BLASTYPE, EIGPREFIX, BLASFUNC) \ 89 template <typename Index, int LhsStorageOrder, bool ConjugateLhs, int RhsStorageOrder, bool ConjugateRhs> \ 90 struct product_selfadjoint_matrix<EIGTYPE, Index, LhsStorageOrder, true, ConjugateLhs, RhsStorageOrder, false, \ 91 ConjugateRhs, ColMajor, 1> { \ 92 static void run(Index rows, Index cols, const EIGTYPE* _lhs, Index lhsStride, const EIGTYPE* _rhs, \ 93 Index rhsStride, EIGTYPE* res, Index resIncr, Index resStride, EIGTYPE alpha, \ 94 level3_blocking<EIGTYPE, EIGTYPE>& ) { \ 95 if (rows == 0 || cols == 0) return; \ 96 EIGEN_ONLY_USED_FOR_DEBUG(resIncr); \ 97 eigen_assert(resIncr == 1); \ 98 char side = 'L', uplo = 'L'; \ 99 BlasIndex m, n, lda, ldb, ldc; \ 100 const EIGTYPE *a, *b; \ 102 MatrixX##EIGPREFIX b_tmp; \ 103 Matrix<EIGTYPE, Dynamic, Dynamic, LhsStorageOrder> a_tmp; \ 107 m = convert_index<BlasIndex>(rows); \ 108 n = convert_index<BlasIndex>(cols); \ 111 lda = convert_index<BlasIndex>(lhsStride); \ 112 ldb = convert_index<BlasIndex>(rhsStride); \ 113 ldc = convert_index<BlasIndex>(resStride); \ 116 if (((LhsStorageOrder == ColMajor) && ConjugateLhs) || ((LhsStorageOrder == RowMajor) && (!ConjugateLhs))) { \ 117 Map<const Matrix<EIGTYPE, Dynamic, Dynamic, LhsStorageOrder>, 0, OuterStride<> > lhs( \ 118 _lhs, m, m, OuterStride<>(lhsStride)); \ 119 a_tmp = lhs.conjugate(); \ 121 lda = convert_index<BlasIndex>(a_tmp.outerStride()); \ 124 if (LhsStorageOrder == RowMajor) uplo = 'U'; \ 126 if (RhsStorageOrder == ColMajor && (!ConjugateRhs)) { \ 129 if (RhsStorageOrder == ColMajor && ConjugateRhs) { \ 130 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > rhs(_rhs, m, n, OuterStride<>(rhsStride)); \ 131 b_tmp = rhs.conjugate(); \ 132 } else if (ConjugateRhs) { \ 133 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > rhs(_rhs, n, m, OuterStride<>(rhsStride)); \ 134 b_tmp = rhs.adjoint(); \ 136 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > rhs(_rhs, n, m, OuterStride<>(rhsStride)); \ 137 b_tmp = rhs.transpose(); \ 140 ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \ 143 BLASFUNC(&side, &uplo, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)a, &lda, \ 144 (const BLASTYPE*)b, &ldb, (const BLASTYPE*)&numext::real_ref(beta), (BLASTYPE*)res, &ldc); \ 149 EIGEN_BLAS_SYMM_L(
double,
double, d, dsymm)
150 EIGEN_BLAS_SYMM_L(
float,
float, f, ssymm)
151 EIGEN_BLAS_HEMM_L(dcomplex, MKL_Complex16, cd, zhemm)
152 EIGEN_BLAS_HEMM_L(scomplex, MKL_Complex8, cf, chemm)
154 EIGEN_BLAS_SYMM_L(
double,
double, d, dsymm_)
155 EIGEN_BLAS_SYMM_L(
float,
float, f, ssymm_)
156 EIGEN_BLAS_HEMM_L(dcomplex,
double, cd, zhemm_)
157 EIGEN_BLAS_HEMM_L(scomplex,
float, cf, chemm_)
162 #define EIGEN_BLAS_SYMM_R(EIGTYPE, BLASTYPE, EIGPREFIX, BLASFUNC) \ 163 template <typename Index, int LhsStorageOrder, bool ConjugateLhs, int RhsStorageOrder, bool ConjugateRhs> \ 164 struct product_selfadjoint_matrix<EIGTYPE, Index, LhsStorageOrder, false, ConjugateLhs, RhsStorageOrder, true, \ 165 ConjugateRhs, ColMajor, 1> { \ 166 static void run(Index rows, Index cols, const EIGTYPE* _lhs, Index lhsStride, const EIGTYPE* _rhs, \ 167 Index rhsStride, EIGTYPE* res, Index resIncr, Index resStride, EIGTYPE alpha, \ 168 level3_blocking<EIGTYPE, EIGTYPE>& ) { \ 169 if (rows == 0 || cols == 0) return; \ 170 EIGEN_ONLY_USED_FOR_DEBUG(resIncr); \ 171 eigen_assert(resIncr == 1); \ 172 char side = 'R', uplo = 'L'; \ 173 BlasIndex m, n, lda, ldb, ldc; \ 174 const EIGTYPE *a, *b; \ 176 MatrixX##EIGPREFIX b_tmp; \ 179 m = convert_index<BlasIndex>(rows); \ 180 n = convert_index<BlasIndex>(cols); \ 183 lda = convert_index<BlasIndex>(rhsStride); \ 184 ldb = convert_index<BlasIndex>(lhsStride); \ 185 ldc = convert_index<BlasIndex>(resStride); \ 188 if (RhsStorageOrder == RowMajor) uplo = 'U'; \ 191 if (LhsStorageOrder == RowMajor) { \ 192 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > lhs(_lhs, n, m, OuterStride<>(rhsStride)); \ 193 b_tmp = lhs.adjoint(); \ 195 ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \ 199 BLASFUNC(&side, &uplo, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)a, &lda, \ 200 (const BLASTYPE*)b, &ldb, (const BLASTYPE*)&numext::real_ref(beta), (BLASTYPE*)res, &ldc); \ 204 #define EIGEN_BLAS_HEMM_R(EIGTYPE, BLASTYPE, EIGPREFIX, BLASFUNC) \ 205 template <typename Index, int LhsStorageOrder, bool ConjugateLhs, int RhsStorageOrder, bool ConjugateRhs> \ 206 struct product_selfadjoint_matrix<EIGTYPE, Index, LhsStorageOrder, false, ConjugateLhs, RhsStorageOrder, true, \ 207 ConjugateRhs, ColMajor, 1> { \ 208 static void run(Index rows, Index cols, const EIGTYPE* _lhs, Index lhsStride, const EIGTYPE* _rhs, \ 209 Index rhsStride, EIGTYPE* res, Index resIncr, Index resStride, EIGTYPE alpha, \ 210 level3_blocking<EIGTYPE, EIGTYPE>& ) { \ 211 EIGEN_ONLY_USED_FOR_DEBUG(resIncr); \ 212 eigen_assert(resIncr == 1); \ 213 char side = 'R', uplo = 'L'; \ 214 BlasIndex m, n, lda, ldb, ldc; \ 215 const EIGTYPE *a, *b; \ 217 MatrixX##EIGPREFIX b_tmp; \ 218 Matrix<EIGTYPE, Dynamic, Dynamic, RhsStorageOrder> a_tmp; \ 221 m = convert_index<BlasIndex>(rows); \ 222 n = convert_index<BlasIndex>(cols); \ 225 lda = convert_index<BlasIndex>(rhsStride); \ 226 ldb = convert_index<BlasIndex>(lhsStride); \ 227 ldc = convert_index<BlasIndex>(resStride); \ 230 if (((RhsStorageOrder == ColMajor) && ConjugateRhs) || ((RhsStorageOrder == RowMajor) && (!ConjugateRhs))) { \ 231 Map<const Matrix<EIGTYPE, Dynamic, Dynamic, RhsStorageOrder>, 0, OuterStride<> > rhs( \ 232 _rhs, n, n, OuterStride<>(rhsStride)); \ 233 a_tmp = rhs.conjugate(); \ 235 lda = convert_index<BlasIndex>(a_tmp.outerStride()); \ 238 if (RhsStorageOrder == RowMajor) uplo = 'U'; \ 240 if (LhsStorageOrder == ColMajor && (!ConjugateLhs)) { \ 243 if (LhsStorageOrder == ColMajor && ConjugateLhs) { \ 244 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > lhs(_lhs, m, n, OuterStride<>(lhsStride)); \ 245 b_tmp = lhs.conjugate(); \ 246 } else if (ConjugateLhs) { \ 247 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > lhs(_lhs, n, m, OuterStride<>(lhsStride)); \ 248 b_tmp = lhs.adjoint(); \ 250 Map<const MatrixX##EIGPREFIX, 0, OuterStride<> > lhs(_lhs, n, m, OuterStride<>(lhsStride)); \ 251 b_tmp = lhs.transpose(); \ 254 ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \ 257 BLASFUNC(&side, &uplo, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)a, &lda, \ 258 (const BLASTYPE*)b, &ldb, (const BLASTYPE*)&numext::real_ref(beta), (BLASTYPE*)res, &ldc); \ 263 EIGEN_BLAS_SYMM_R(
double,
double, d, dsymm)
264 EIGEN_BLAS_SYMM_R(
float,
float, f, ssymm)
265 EIGEN_BLAS_HEMM_R(dcomplex, MKL_Complex16, cd, zhemm)
266 EIGEN_BLAS_HEMM_R(scomplex, MKL_Complex8, cf, chemm)
268 EIGEN_BLAS_SYMM_R(
double,
double, d, dsymm_)
269 EIGEN_BLAS_SYMM_R(
float,
float, f, ssymm_)
270 EIGEN_BLAS_HEMM_R(dcomplex,
double, cd, zhemm_)
271 EIGEN_BLAS_HEMM_R(scomplex,
float, cf, chemm_)
277 #endif // EIGEN_SELFADJOINT_MATRIX_MATRIX_BLAS_H Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1