11#ifndef TLAPACK_BLAS_TRSM_HH
12#define TLAPACK_BLAS_TRSM_HH
72 class T = type_t<matrixB_t>,
73 disable_if_allow_optblas_t<pair<matrixA_t, T>,
75 pair<alpha_t, T> > = 0>
89 const idx_t m = nrows(
B);
90 const idx_t n = ncols(
B);
96 trans != Op::ConjTrans);
101 if (
side == Side::Left) {
103 if (
trans == Op::NoTrans) {
104 if (
uplo == Uplo::Upper) {
105 for (idx_t j = 0; j < n; ++j) {
106 for (idx_t i = 0; i < m; ++i)
108 for (idx_t
k = m - 1;
k != idx_t(-1); --
k) {
109 if (
diag == Diag::NonUnit)
B(
k, j) /=
A(
k,
k);
110 for (idx_t i = 0; i <
k; ++i)
111 B(i, j) -=
A(i,
k) *
B(
k, j);
116 for (idx_t j = 0; j < n; ++j) {
117 for (idx_t i = 0; i < m; ++i)
119 for (idx_t
k = 0;
k < m; ++
k) {
120 if (
diag == Diag::NonUnit)
B(
k, j) /=
A(
k,
k);
121 for (idx_t i =
k + 1; i < m; ++i)
122 B(i, j) -=
A(i,
k) *
B(
k, j);
127 else if (
trans == Op::Trans) {
128 if (
uplo == Uplo::Upper) {
129 for (idx_t j = 0; j < n; ++j) {
130 for (idx_t i = 0; i < m; ++i) {
132 for (idx_t
k = 0;
k < i; ++
k)
134 B(i, j) = (
diag == Diag::NonUnit) ?
sum /
A(i, i) :
sum;
139 for (idx_t j = 0; j < n; ++j) {
140 for (idx_t i = m - 1; i != idx_t(-1); --i) {
142 for (idx_t
k = i + 1;
k < m; ++
k)
144 B(i, j) = (
diag == Diag::NonUnit) ?
sum /
A(i, i) :
sum;
150 if (
uplo == Uplo::Upper) {
151 for (idx_t j = 0; j < n; ++j) {
152 for (idx_t i = 0; i < m; ++i) {
154 for (idx_t
k = 0;
k < i; ++
k)
162 for (idx_t j = 0; j < n; ++j) {
163 for (idx_t i = m - 1; i != idx_t(-1); --i) {
165 for (idx_t
k = i + 1;
k < m; ++
k)
175 if (
trans == Op::NoTrans) {
176 if (
uplo == Uplo::Upper) {
177 for (idx_t j = 0; j < n; ++j) {
178 for (idx_t i = 0; i < m; ++i)
180 for (idx_t
k = 0;
k < j; ++
k) {
181 for (idx_t i = 0; i < m; ++i)
182 B(i, j) -=
B(i,
k) *
A(
k, j);
184 if (
diag == Diag::NonUnit) {
185 for (idx_t i = 0; i < m; ++i)
191 for (idx_t j = n - 1; j != idx_t(-1); --j) {
192 for (idx_t i = 0; i < m; ++i)
194 for (idx_t
k = j + 1;
k < n; ++
k) {
195 for (idx_t i = 0; i < m; ++i)
196 B(i, j) -=
B(i,
k) *
A(
k, j);
198 if (
diag == Diag::NonUnit) {
199 for (idx_t i = 0; i < m; ++i)
205 else if (
trans == Op::Trans) {
206 if (
uplo == Uplo::Upper) {
207 for (idx_t
k = n - 1;
k != idx_t(-1); --
k) {
208 if (
diag == Diag::NonUnit) {
209 for (idx_t i = 0; i < m; ++i)
212 for (idx_t j = 0; j <
k; ++j) {
213 for (idx_t i = 0; i < m; ++i)
214 B(i, j) -=
B(i,
k) *
A(j,
k);
216 for (idx_t i = 0; i < m; ++i)
221 for (idx_t
k = 0;
k < n; ++
k) {
222 if (
diag == Diag::NonUnit) {
223 for (idx_t i = 0; i < m; ++i)
226 for (idx_t j =
k + 1; j < n; ++j) {
227 for (idx_t i = 0; i < m; ++i)
228 B(i, j) -=
B(i,
k) *
A(j,
k);
230 for (idx_t i = 0; i < m; ++i)
236 if (
uplo == Uplo::Upper) {
237 for (idx_t
k = n - 1;
k != idx_t(-1); --
k) {
238 if (
diag == Diag::NonUnit) {
239 for (idx_t i = 0; i < m; ++i)
242 for (idx_t j = 0; j <
k; ++j) {
243 for (idx_t i = 0; i < m; ++i)
246 for (idx_t i = 0; i < m; ++i)
251 for (idx_t
k = 0;
k < n; ++
k) {
252 if (
diag == Diag::NonUnit) {
253 for (idx_t i = 0; i < m; ++i)
256 for (idx_t j =
k + 1; j < n; ++j) {
257 for (idx_t i = 0; i < m; ++i)
260 for (idx_t i = 0; i < m; ++i)
268#ifdef TLAPACK_USE_LAPACKPP
273 class T = type_t<matrixB_t>,
274 enable_if_allow_optblas_t<pair<matrixA_t, T>,
276 pair<alpha_t, T> > = 0>
286 auto A_ = legacy_matrix(A);
287 auto B_ = legacy_matrix(B);
290 constexpr Layout L = layout<matrixB_t>;
291 const auto& m = B_.m;
292 const auto& n = B_.n;
295 if (alpha == alpha_t(0))
297 -5,
"Infs and NaNs in A or B will not propagate to B on output");
299 return ::blas::trsm((::blas::Layout)L, (::blas::Side)side,
300 (::blas::Uplo)uplo, (::blas::Op)trans,
301 (::blas::Diag)diag, m, n, alpha, A_.ptr, A_.ldim,
Diag
Definition types.hpp:197
Side
Definition types.hpp:271
Op
Definition types.hpp:227
Uplo
Definition types.hpp:50
constexpr T conj(const T &x) noexcept
Extends std::conj() to real datatypes.
Definition utils.hpp:100
#define TLAPACK_SCALAR
Macro for tlapack::concepts::Scalar compatible with C++17.
Definition concepts.hpp:915
#define TLAPACK_LEGACY_MATRIX
Macro for tlapack::concepts::LegacyMatrix compatible with C++17.
Definition concepts.hpp:951
#define TLAPACK_MATRIX
Macro for tlapack::concepts::Matrix compatible with C++17.
Definition concepts.hpp:896
constexpr auto diag(T &A, int diagIdx=0) noexcept
Get the Diagonal of an Eigen Matrix.
Definition eigen.hpp:576
void trsm(Side side, Uplo uplo, Op trans, Diag diag, const alpha_t &alpha, const matrixA_t &A, matrixB_t &B)
Solve the triangular matrix-vector equation.
Definition trsm.hpp:76
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
#define tlapack_warning(info, detailedInfo)
Warning handler.
Definition exceptionHandling.hpp:156
Concept for types that represent tlapack::Diag.
Concept for types that represent tlapack::Op.
Concept for types that represent tlapack::Side.
Concept for types that represent tlapack::Uplo.
typename traits::real_type_traits< Types..., int >::type real_type
The common real type of the list of types.
Definition scalar_type_traits.hpp:113