34#ifndef EIGEN_TRIANGULAR_SOLVER_MATRIX_BLAS_H
35#define EIGEN_TRIANGULAR_SOLVER_MATRIX_BLAS_H
38#include "../InternalHeaderCheck.h"
45#define EIGEN_BLAS_TRSM_L(EIGTYPE, BLASTYPE, BLASFUNC) \
46 template <typename Index, int Mode, bool Conjugate, int TriStorageOrder> \
47 struct triangular_solve_matrix<EIGTYPE, Index, OnTheLeft, Mode, Conjugate, TriStorageOrder, ColMajor, 1> { \
49 IsLower = (Mode & Lower) == Lower, \
50 IsUnitDiag = (Mode & UnitDiag) ? 1 : 0, \
51 IsZeroDiag = (Mode & ZeroDiag) ? 1 : 0, \
52 conjA = ((TriStorageOrder == ColMajor) && Conjugate) ? 1 : 0 \
54 static void run(Index size, Index otherSize, const EIGTYPE* _tri, Index triStride, EIGTYPE* _other, \
55 Index otherIncr, Index otherStride, level3_blocking<EIGTYPE, EIGTYPE>& ) { \
56 if (size == 0 || otherSize == 0) return; \
57 EIGEN_ONLY_USED_FOR_DEBUG(otherIncr); \
58 eigen_assert(otherIncr == 1); \
59 BlasIndex m = convert_index<BlasIndex>(size), n = convert_index<BlasIndex>(otherSize), lda, ldb; \
60 char side = 'L', uplo, diag = 'N', transa; \
63 ldb = convert_index<BlasIndex>(otherStride); \
67 transa = (TriStorageOrder == RowMajor) ? ((Conjugate) ? 'C' : 'T') : 'N'; \
69 uplo = IsLower ? 'L' : 'U'; \
70 EIGEN_IF_CONSTEXPR (TriStorageOrder == RowMajor) { \
71 uplo = (uplo == 'L') ? 'U' : 'L'; \
74 typedef Matrix<EIGTYPE, Dynamic, Dynamic, TriStorageOrder> MatrixTri; \
75 Map<const MatrixTri, 0, OuterStride<> > tri(_tri, size, size, OuterStride<>(triStride)); \
78 EIGEN_IF_CONSTEXPR (conjA) { \
79 a_tmp = tri.conjugate(); \
81 lda = convert_index<BlasIndex>(a_tmp.outerStride()); \
84 lda = convert_index<BlasIndex>(triStride); \
86 EIGEN_IF_CONSTEXPR (IsUnitDiag) { \
90 BLASFUNC(&side, &uplo, &transa, &diag, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)a, \
91 &lda, (BLASTYPE*)_other, &ldb); \
96EIGEN_BLAS_TRSM_L(
double,
double, dtrsm)
97EIGEN_BLAS_TRSM_L(dcomplex, MKL_Complex16, ztrsm)
98EIGEN_BLAS_TRSM_L(
float,
float, strsm)
99EIGEN_BLAS_TRSM_L(scomplex, MKL_Complex8, ctrsm)
101EIGEN_BLAS_TRSM_L(
double,
double, EIGEN_BLAS_SYM(dtrsm))
102EIGEN_BLAS_TRSM_L(dcomplex,
double, EIGEN_BLAS_SYM(ztrsm))
103EIGEN_BLAS_TRSM_L(
float,
float, EIGEN_BLAS_SYM(strsm))
104EIGEN_BLAS_TRSM_L(scomplex,
float, EIGEN_BLAS_SYM(ctrsm))
108#define EIGEN_BLAS_TRSM_R(EIGTYPE, BLASTYPE, BLASFUNC) \
109 template <typename Index, int Mode, bool Conjugate, int TriStorageOrder> \
110 struct triangular_solve_matrix<EIGTYPE, Index, OnTheRight, Mode, Conjugate, TriStorageOrder, ColMajor, 1> { \
112 IsLower = (Mode & Lower) == Lower, \
113 IsUnitDiag = (Mode & UnitDiag) ? 1 : 0, \
114 IsZeroDiag = (Mode & ZeroDiag) ? 1 : 0, \
115 conjA = ((TriStorageOrder == ColMajor) && Conjugate) ? 1 : 0 \
117 static void run(Index size, Index otherSize, const EIGTYPE* _tri, Index triStride, EIGTYPE* _other, \
118 Index otherIncr, Index otherStride, level3_blocking<EIGTYPE, EIGTYPE>& ) { \
119 if (size == 0 || otherSize == 0) return; \
120 EIGEN_ONLY_USED_FOR_DEBUG(otherIncr); \
121 eigen_assert(otherIncr == 1); \
122 BlasIndex m = convert_index<BlasIndex>(otherSize), n = convert_index<BlasIndex>(size), lda, ldb; \
123 char side = 'R', uplo, diag = 'N', transa; \
126 ldb = convert_index<BlasIndex>(otherStride); \
130 transa = (TriStorageOrder == RowMajor) ? ((Conjugate) ? 'C' : 'T') : 'N'; \
132 uplo = IsLower ? 'L' : 'U'; \
133 EIGEN_IF_CONSTEXPR (TriStorageOrder == RowMajor) { \
134 uplo = (uplo == 'L') ? 'U' : 'L'; \
137 typedef Matrix<EIGTYPE, Dynamic, Dynamic, TriStorageOrder> MatrixTri; \
138 Map<const MatrixTri, 0, OuterStride<> > tri(_tri, size, size, OuterStride<>(triStride)); \
141 EIGEN_IF_CONSTEXPR (conjA) { \
142 a_tmp = tri.conjugate(); \
144 lda = convert_index<BlasIndex>(a_tmp.outerStride()); \
147 lda = convert_index<BlasIndex>(triStride); \
149 EIGEN_IF_CONSTEXPR (IsUnitDiag) { \
153 BLASFUNC(&side, &uplo, &transa, &diag, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)a, \
154 &lda, (BLASTYPE*)_other, &ldb); \
160EIGEN_BLAS_TRSM_R(
double,
double, dtrsm)
161EIGEN_BLAS_TRSM_R(dcomplex, MKL_Complex16, ztrsm)
162EIGEN_BLAS_TRSM_R(
float,
float, strsm)
163EIGEN_BLAS_TRSM_R(scomplex, MKL_Complex8, ctrsm)
165EIGEN_BLAS_TRSM_R(
double,
double, EIGEN_BLAS_SYM(dtrsm))
166EIGEN_BLAS_TRSM_R(dcomplex,
double, EIGEN_BLAS_SYM(ztrsm))
167EIGEN_BLAS_TRSM_R(
float,
float, EIGEN_BLAS_SYM(strsm))
168EIGEN_BLAS_TRSM_R(scomplex,
float, EIGEN_BLAS_SYM(ctrsm))
171#undef EIGEN_BLAS_TRSM_R
172#undef EIGEN_BLAS_TRSM_L