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> { \
48 using Scalar = EIGTYPE; \
50 IsLower = (Mode & Lower) == Lower, \
51 IsUnitDiag = (Mode & UnitDiag) ? 1 : 0, \
52 IsZeroDiag = (Mode & ZeroDiag) ? 1 : 0, \
53 conjA = ((TriStorageOrder == ColMajor) && Conjugate) ? 1 : 0 \
55 static void run(Index size, Index otherSize, const EIGTYPE* _tri, Index triStride, Scalar* _other, \
56 Index otherIncr, Index otherStride, level3_blocking<EIGTYPE, EIGTYPE>& blocking) { \
57 if (size == 0 || otherSize == 0) return; \
58 if (!blas_compatible_stride<TriStorageOrder>(size, size, triStride) || \
59 !blas_compatible_stride<ColMajor>(size, otherSize, otherStride)) { \
60 triangular_solve_matrix<EIGTYPE, Index, OnTheLeft, Mode, Conjugate, TriStorageOrder, ColMajor, Dynamic>::run( \
61 size, otherSize, _tri, triStride, _other, otherIncr, otherStride, blocking); \
64 EIGEN_ONLY_USED_FOR_DEBUG(otherIncr); \
65 eigen_assert(otherIncr == 1); \
66 BlasIndex m = convert_index<BlasIndex>(size), n = convert_index<BlasIndex>(otherSize), lda, ldb; \
67 char side = 'L', uplo, diag = 'N', transa; \
70 ldb = blas_leading_dim<ColMajor>(size, otherSize, otherStride); \
74 transa = (TriStorageOrder == RowMajor) ? ((Conjugate) ? 'C' : 'T') : 'N'; \
76 uplo = IsLower ? 'L' : 'U'; \
77 EIGEN_IF_CONSTEXPR (TriStorageOrder == RowMajor) { \
78 uplo = (uplo == 'L') ? 'U' : 'L'; \
81 using MatrixTri = Matrix<EIGTYPE, Dynamic, Dynamic, TriStorageOrder>; \
82 Map<const MatrixTri, 0, OuterStride<> > tri(_tri, size, size, OuterStride<>(triStride)); \
85 EIGEN_IF_CONSTEXPR (conjA) { \
86 a_tmp = tri.conjugate(); \
88 lda = convert_index<BlasIndex>(a_tmp.outerStride()); \
91 lda = blas_leading_dim<TriStorageOrder>(size, size, triStride); \
93 EIGEN_IF_CONSTEXPR (IsUnitDiag) { \
97 BLASFUNC(&side, &uplo, &transa, &diag, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)a, \
98 &lda, (BLASTYPE*)_other, &ldb); \
103EIGEN_BLAS_TRSM_L(
double,
double, dtrsm)
104EIGEN_BLAS_TRSM_L(dcomplex, MKL_Complex16, ztrsm)
105EIGEN_BLAS_TRSM_L(
float,
float, strsm)
106EIGEN_BLAS_TRSM_L(scomplex, MKL_Complex8, ctrsm)
108EIGEN_BLAS_TRSM_L(
double,
double, EIGEN_BLAS_SYM(dtrsm))
109EIGEN_BLAS_TRSM_L(dcomplex,
double, EIGEN_BLAS_SYM(ztrsm))
110EIGEN_BLAS_TRSM_L(
float,
float, EIGEN_BLAS_SYM(strsm))
111EIGEN_BLAS_TRSM_L(scomplex,
float, EIGEN_BLAS_SYM(ctrsm))
115#define EIGEN_BLAS_TRSM_R(EIGTYPE, BLASTYPE, BLASFUNC) \
116 template <typename Index, int Mode, bool Conjugate, int TriStorageOrder> \
117 struct triangular_solve_matrix<EIGTYPE, Index, OnTheRight, Mode, Conjugate, TriStorageOrder, ColMajor, 1> { \
118 using Scalar = EIGTYPE; \
120 IsLower = (Mode & Lower) == Lower, \
121 IsUnitDiag = (Mode & UnitDiag) ? 1 : 0, \
122 IsZeroDiag = (Mode & ZeroDiag) ? 1 : 0, \
123 conjA = ((TriStorageOrder == ColMajor) && Conjugate) ? 1 : 0 \
125 static void run(Index size, Index otherSize, const EIGTYPE* _tri, Index triStride, Scalar* _other, \
126 Index otherIncr, Index otherStride, level3_blocking<EIGTYPE, EIGTYPE>& blocking) { \
127 if (size == 0 || otherSize == 0) return; \
128 if (!blas_compatible_stride<TriStorageOrder>(size, size, triStride) || \
129 !blas_compatible_stride<ColMajor>(otherSize, size, otherStride)) { \
130 triangular_solve_matrix<EIGTYPE, Index, OnTheRight, Mode, Conjugate, TriStorageOrder, ColMajor, Dynamic>::run( \
131 size, otherSize, _tri, triStride, _other, otherIncr, otherStride, blocking); \
134 EIGEN_ONLY_USED_FOR_DEBUG(otherIncr); \
135 eigen_assert(otherIncr == 1); \
136 BlasIndex m = convert_index<BlasIndex>(otherSize), n = convert_index<BlasIndex>(size), lda, ldb; \
137 char side = 'R', uplo, diag = 'N', transa; \
140 ldb = blas_leading_dim<ColMajor>(otherSize, size, otherStride); \
144 transa = (TriStorageOrder == RowMajor) ? ((Conjugate) ? 'C' : 'T') : 'N'; \
146 uplo = IsLower ? 'L' : 'U'; \
147 EIGEN_IF_CONSTEXPR (TriStorageOrder == RowMajor) { \
148 uplo = (uplo == 'L') ? 'U' : 'L'; \
151 using MatrixTri = Matrix<EIGTYPE, Dynamic, Dynamic, TriStorageOrder>; \
152 Map<const MatrixTri, 0, OuterStride<> > tri(_tri, size, size, OuterStride<>(triStride)); \
155 EIGEN_IF_CONSTEXPR (conjA) { \
156 a_tmp = tri.conjugate(); \
158 lda = convert_index<BlasIndex>(a_tmp.outerStride()); \
161 lda = blas_leading_dim<TriStorageOrder>(size, size, triStride); \
163 EIGEN_IF_CONSTEXPR (IsUnitDiag) { \
167 BLASFUNC(&side, &uplo, &transa, &diag, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)a, \
168 &lda, (BLASTYPE*)_other, &ldb); \
174EIGEN_BLAS_TRSM_R(
double,
double, dtrsm)
175EIGEN_BLAS_TRSM_R(dcomplex, MKL_Complex16, ztrsm)
176EIGEN_BLAS_TRSM_R(
float,
float, strsm)
177EIGEN_BLAS_TRSM_R(scomplex, MKL_Complex8, ctrsm)
179EIGEN_BLAS_TRSM_R(
double,
double, EIGEN_BLAS_SYM(dtrsm))
180EIGEN_BLAS_TRSM_R(dcomplex,
double, EIGEN_BLAS_SYM(ztrsm))
181EIGEN_BLAS_TRSM_R(
float,
float, EIGEN_BLAS_SYM(strsm))
182EIGEN_BLAS_TRSM_R(scomplex,
float, EIGEN_BLAS_SYM(ctrsm))
185#undef EIGEN_BLAS_TRSM_R
186#undef EIGEN_BLAS_TRSM_L