TriangularSolverMatrix_BLAS.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2011, Intel Corporation. All rights reserved.
3 
4  Redistribution and use in source and binary forms, with or without modification,
5  are permitted provided that the following conditions are met:
6 
7  * Redistributions of source code must retain the above copyright notice, this
8  list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright notice,
10  this list of conditions and the following disclaimer in the documentation
11  and/or other materials provided with the distribution.
12  * Neither the name of Intel Corporation nor the names of its contributors may
13  be used to endorse or promote products derived from this software without
14  specific prior written permission.
15 
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 
27  ********************************************************************************
28  * Content : Eigen bindings to BLAS F77
29  * Triangular matrix * matrix product functionality based on ?TRMM.
30  ********************************************************************************
31 */
32 
33 #ifndef EIGEN_TRIANGULAR_SOLVER_MATRIX_BLAS_H
34 #define EIGEN_TRIANGULAR_SOLVER_MATRIX_BLAS_H
35 
36 namespace Eigen {
37 
38 namespace internal {
39 
40 // implements LeftSide op(triangular)^-1 * general
41 #define EIGEN_BLAS_TRSM_L(EIGTYPE, BLASTYPE, BLASFUNC) \
42 template <typename Index, int Mode, bool Conjugate, int TriStorageOrder> \
43 struct triangular_solve_matrix<EIGTYPE,Index,OnTheLeft,Mode,Conjugate,TriStorageOrder,ColMajor> \
44 { \
45  enum { \
46  IsLower = (Mode&Lower) == Lower, \
47  IsUnitDiag = (Mode&UnitDiag) ? 1 : 0, \
48  IsZeroDiag = (Mode&ZeroDiag) ? 1 : 0, \
49  conjA = ((TriStorageOrder==ColMajor) && Conjugate) ? 1 : 0 \
50  }; \
51  static void run( \
52  Index size, Index otherSize, \
53  const EIGTYPE* _tri, Index triStride, \
54  EIGTYPE* _other, Index otherStride, level3_blocking<EIGTYPE,EIGTYPE>& /*blocking*/) \
55  { \
56  BlasIndex m = convert_index<BlasIndex>(size), n = convert_index<BlasIndex>(otherSize), lda, ldb; \
57  char side = 'L', uplo, diag='N', transa; \
58  /* Set alpha_ */ \
59  EIGTYPE alpha(1); \
60  ldb = convert_index<BlasIndex>(otherStride);\
61 \
62  const EIGTYPE *a; \
63 /* Set trans */ \
64  transa = (TriStorageOrder==RowMajor) ? ((Conjugate) ? 'C' : 'T') : 'N'; \
65 /* Set uplo */ \
66  uplo = IsLower ? 'L' : 'U'; \
67  if (TriStorageOrder==RowMajor) uplo = (uplo == 'L') ? 'U' : 'L'; \
68 /* Set a, lda */ \
69  typedef Matrix<EIGTYPE, Dynamic, Dynamic, TriStorageOrder> MatrixTri; \
70  Map<const MatrixTri, 0, OuterStride<> > tri(_tri,size,size,OuterStride<>(triStride)); \
71  MatrixTri a_tmp; \
72 \
73  if (conjA) { \
74  a_tmp = tri.conjugate(); \
75  a = a_tmp.data(); \
76  lda = convert_index<BlasIndex>(a_tmp.outerStride()); \
77  } else { \
78  a = _tri; \
79  lda = convert_index<BlasIndex>(triStride); \
80  } \
81  if (IsUnitDiag) diag='U'; \
82 /* call ?trsm*/ \
83  BLASFUNC(&side, &uplo, &transa, &diag, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (BLASTYPE*)_other, &ldb); \
84  } \
85 };
86 
87 #ifdef EIGEN_USE_MKL
88 EIGEN_BLAS_TRSM_L(double, double, dtrsm)
89 EIGEN_BLAS_TRSM_L(dcomplex, MKL_Complex16, ztrsm)
90 EIGEN_BLAS_TRSM_L(float, float, strsm)
91 EIGEN_BLAS_TRSM_L(scomplex, MKL_Complex8, ctrsm)
92 #else
93 EIGEN_BLAS_TRSM_L(double, double, dtrsm_)
94 EIGEN_BLAS_TRSM_L(dcomplex, double, ztrsm_)
95 EIGEN_BLAS_TRSM_L(float, float, strsm_)
96 EIGEN_BLAS_TRSM_L(scomplex, float, ctrsm_)
97 #endif
98 
99 // implements RightSide general * op(triangular)^-1
100 #define EIGEN_BLAS_TRSM_R(EIGTYPE, BLASTYPE, BLASFUNC) \
101 template <typename Index, int Mode, bool Conjugate, int TriStorageOrder> \
102 struct triangular_solve_matrix<EIGTYPE,Index,OnTheRight,Mode,Conjugate,TriStorageOrder,ColMajor> \
103 { \
104  enum { \
105  IsLower = (Mode&Lower) == Lower, \
106  IsUnitDiag = (Mode&UnitDiag) ? 1 : 0, \
107  IsZeroDiag = (Mode&ZeroDiag) ? 1 : 0, \
108  conjA = ((TriStorageOrder==ColMajor) && Conjugate) ? 1 : 0 \
109  }; \
110  static void run( \
111  Index size, Index otherSize, \
112  const EIGTYPE* _tri, Index triStride, \
113  EIGTYPE* _other, Index otherStride, level3_blocking<EIGTYPE,EIGTYPE>& /*blocking*/) \
114  { \
115  BlasIndex m = convert_index<BlasIndex>(otherSize), n = convert_index<BlasIndex>(size), lda, ldb; \
116  char side = 'R', uplo, diag='N', transa; \
117  /* Set alpha_ */ \
118  EIGTYPE alpha(1); \
119  ldb = convert_index<BlasIndex>(otherStride);\
120 \
121  const EIGTYPE *a; \
122 /* Set trans */ \
123  transa = (TriStorageOrder==RowMajor) ? ((Conjugate) ? 'C' : 'T') : 'N'; \
124 /* Set uplo */ \
125  uplo = IsLower ? 'L' : 'U'; \
126  if (TriStorageOrder==RowMajor) uplo = (uplo == 'L') ? 'U' : 'L'; \
127 /* Set a, lda */ \
128  typedef Matrix<EIGTYPE, Dynamic, Dynamic, TriStorageOrder> MatrixTri; \
129  Map<const MatrixTri, 0, OuterStride<> > tri(_tri,size,size,OuterStride<>(triStride)); \
130  MatrixTri a_tmp; \
131 \
132  if (conjA) { \
133  a_tmp = tri.conjugate(); \
134  a = a_tmp.data(); \
135  lda = convert_index<BlasIndex>(a_tmp.outerStride()); \
136  } else { \
137  a = _tri; \
138  lda = convert_index<BlasIndex>(triStride); \
139  } \
140  if (IsUnitDiag) diag='U'; \
141 /* call ?trsm*/ \
142  BLASFUNC(&side, &uplo, &transa, &diag, &m, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (BLASTYPE*)_other, &ldb); \
143  /*std::cout << "TRMS_L specialization!\n";*/ \
144  } \
145 };
146 
147 #ifdef EIGEN_USE_MKL
148 EIGEN_BLAS_TRSM_R(double, double, dtrsm)
149 EIGEN_BLAS_TRSM_R(dcomplex, MKL_Complex16, ztrsm)
150 EIGEN_BLAS_TRSM_R(float, float, strsm)
151 EIGEN_BLAS_TRSM_R(scomplex, MKL_Complex8, ctrsm)
152 #else
153 EIGEN_BLAS_TRSM_R(double, double, dtrsm_)
154 EIGEN_BLAS_TRSM_R(dcomplex, double, ztrsm_)
155 EIGEN_BLAS_TRSM_R(float, float, strsm_)
156 EIGEN_BLAS_TRSM_R(scomplex, float, ctrsm_)
157 #endif
158 
159 } // end namespace internal
160 
161 } // end namespace Eigen
162 
163 #endif // EIGEN_TRIANGULAR_SOLVER_MATRIX_BLAS_H
int BLASFUNC() ztrsm(char *, char *, char *, char *, int *, int *, double *, double *, int *, double *, int *)
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
int BLASFUNC() ctrsm(char *, char *, char *, char *, int *, int *, float *, float *, int *, float *, int *)
#define EIGEN_BLAS_TRSM_R(EIGTYPE, BLASTYPE, BLASFUNC)
std::complex< float > scomplex
Definition: MKL_support.h:119
std::complex< double > dcomplex
Definition: MKL_support.h:118
int BLASFUNC() dtrsm(char *, char *, char *, char *, int *, int *, double *, double *, int *, double *, int *)
#define EIGEN_BLAS_TRSM_L(EIGTYPE, BLASTYPE, BLASFUNC)
int BLASFUNC() strsm(char *, char *, char *, char *, int *, int *, float *, float *, int *, float *, int *)


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:51:16