<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
trsm.hpp
Go to the documentation of this file.
1
3//
4// Copyright (c) 2017-2021, University of Tennessee. All rights reserved.
5// Copyright (c) 2021-2023, University of Colorado Denver. All rights reserved.
6//
7// This file is part of <T>LAPACK.
8// <T>LAPACK is free software: you can redistribute it and/or modify it under
9// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
10
11#ifndef TLAPACK_LEGACY_TRSM_HH
12#define TLAPACK_LEGACY_TRSM_HH
13
14#include "tlapack/blas/trsm.hpp"
17
18namespace tlapack {
19namespace legacy {
20
101 template <typename TA, typename TB>
102 void trsm(Layout layout,
103 Side side,
104 Uplo uplo,
105 Op trans,
106 Diag diag,
107 idx_t m,
108 idx_t n,
110 TA const* A,
111 idx_t lda,
112 TB* B,
113 idx_t ldb)
114 {
115 using internal::create_matrix;
117
118 // check arguments
119 tlapack_check_false(layout != Layout::ColMajor &&
120 layout != Layout::RowMajor);
121 tlapack_check_false(side != Side::Left && side != Side::Right);
122 tlapack_check_false(uplo != Uplo::Lower && uplo != Uplo::Upper);
123 tlapack_check_false(trans != Op::NoTrans && trans != Op::Trans &&
124 trans != Op::ConjTrans);
125 tlapack_check_false(diag != Diag::NonUnit && diag != Diag::Unit);
126 tlapack_check_false(m < 0);
127 tlapack_check_false(n < 0);
128 tlapack_check_false(lda < ((side == Side::Left) ? m : n));
129 tlapack_check_false(ldb < ((layout == Layout::RowMajor) ? n : m));
130
131 // quick return
132 if (m == 0 || n == 0) return;
133
134 // adapt if row major
135 if (layout == Layout::RowMajor) {
136 side = (side == Side::Left) ? Side::Right : Side::Left;
137 if (uplo == Uplo::Lower)
138 uplo = Uplo::Upper;
139 else if (uplo == Uplo::Upper)
140 uplo = Uplo::Lower;
141 std::swap(m, n);
142 }
143
144 // Matrix views
145 const auto A_ = (side == Side::Left)
146 ? create_matrix<TA>((TA*)A, m, m, lda)
147 : create_matrix<TA>((TA*)A, n, n, lda);
148 auto B_ = create_matrix<TB>(B, m, n, ldb);
149
150 if (alpha == scalar_t(0))
151 for (idx_t j = 0; j < n; ++j)
152 for (idx_t i = 0; i < m; ++i)
153 B_(i, j) = TB(0);
154 else
155 trsm(side, uplo, trans, diag, alpha, A_, B_);
156 }
157
158} // namespace legacy
159} // namespace tlapack
160
161#endif // #ifndef TLAPACK_LEGACY_TRSM_HH
constexpr Layout layout
Layout of a matrix or vector.
Definition arrayTraits.hpp:232
Diag
Definition types.hpp:192
Side
Definition types.hpp:266
Op
Definition types.hpp:222
Uplo
Definition types.hpp:45
Layout
Definition types.hpp:24
constexpr auto diag(T &A, int diagIdx=0) noexcept
Get the Diagonal of an Eigen Matrix.
Definition eigen.hpp:576
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
void trsm(Layout layout, Side side, Uplo uplo, Op trans, Diag diag, idx_t m, idx_t n, scalar_type< TA, TB > alpha, TA const *A, idx_t lda, TB *B, idx_t ldb)
Solve the triangular matrix-vector equation.
Definition trsm.hpp:102
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