31 #ifndef SHARK_LINALG_BLAS_KERNELS_CBLAS_TRSM_HPP 32 #define SHARK_LINALG_BLAS_KERNELS_CBLAS_TRSM_HPP 38 namespace shark {
namespace blas {
namespace bindings {
40 CBLAS_ORDER order, CBLAS_UPLO uplo,CBLAS_TRANSPOSE transA,
41 CBLAS_SIDE side, CBLAS_DIAG unit,
43 float const *A,
int lda,
float *B,
int ldb
45 cblas_strsm(order, side, uplo, transA, unit,n, nRHS, 1.0, A, lda, B, ldb);
49 CBLAS_ORDER order, CBLAS_UPLO uplo,CBLAS_TRANSPOSE transA,
50 CBLAS_SIDE side, CBLAS_DIAG unit,
52 double const *A,
int lda,
double *B,
int ldb
54 cblas_dtrsm(order, side, uplo, transA, unit,n, nRHS, 1.0, A, lda, B, ldb);
58 CBLAS_ORDER order, CBLAS_UPLO uplo,CBLAS_TRANSPOSE transA,
59 CBLAS_SIDE side, CBLAS_DIAG unit,
61 std::complex<float>
const *A,
int lda, std::complex<float> *B,
int ldb
63 std::complex<float> alpha(1.0,0);
64 cblas_ctrsm(order, side, uplo, transA, unit,n, nRHS,
65 reinterpret_cast<cblas_float_complex_type const *>(&alpha),
66 reinterpret_cast<cblas_float_complex_type const *>(A), lda,
67 reinterpret_cast<cblas_float_complex_type *>(B), ldb);
70 CBLAS_ORDER order, CBLAS_UPLO uplo,CBLAS_TRANSPOSE transA,
71 CBLAS_SIDE side, CBLAS_DIAG unit,
73 std::complex<double>
const *A,
int lda, std::complex<double> *B,
int ldb
75 std::complex<double> alpha(1.0,0);
76 cblas_ztrsm(order, side, uplo, transA, unit,n, nRHS,
77 reinterpret_cast<cblas_double_complex_type const *>(&alpha),
78 reinterpret_cast<cblas_double_complex_type const *>(A), lda,
79 reinterpret_cast<cblas_double_complex_type *>(B), ldb);
84 template <
bool upper,
bool unit,
typename TriangularA,
typename MatB>
86 matrix_expression<TriangularA>
const &A,
87 matrix_expression<MatB> &B,
94 CBLAS_ORDER
const storOrd = (CBLAS_ORDER)storage_order<typename MatB::orientation>::value;
96 bool transposeA = !traits::same_orientation(A,B);
98 CBLAS_DIAG cblasUnit = unit?CblasUnit:CblasNonUnit;
99 CBLAS_UPLO cblasUplo = (upper != transposeA)?CblasUpper:CblasLower;
102 CBLAS_TRANSPOSE transA = transposeA?CblasTrans:CblasNoTrans;
105 int nrhs = B().size2();
107 trsm(storOrd, cblasUplo, transA, CblasLeft,cblasUnit, m, nrhs,
109 traits::leading_dimension(A),
111 traits::leading_dimension(B)
115 template<
class Storage1,
class Storage2,
class T1,
class T2>
116 struct optimized_trsm_detail{
117 typedef boost::mpl::false_ type;
120 struct optimized_trsm_detail<
121 dense_tag, dense_tag,
124 typedef boost::mpl::true_ type;
127 struct optimized_trsm_detail<
128 dense_tag, dense_tag,
131 typedef boost::mpl::true_ type;
135 struct optimized_trsm_detail<
136 dense_tag, dense_tag,
137 std::complex<double>, std::complex<double>
139 typedef boost::mpl::true_ type;
142 struct optimized_trsm_detail<
143 dense_tag, dense_tag,
144 std::complex<float>, std::complex<float>
146 typedef boost::mpl::true_ type;
149 template<
class M1,
class M2>
150 struct has_optimized_trsm
151 :
public optimized_trsm_detail<
152 typename M1::storage_category,
153 typename M2::storage_category,
154 typename M1::value_type,
155 typename M2::value_type