<T>LAPACK 0.1.2
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) 2025, 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>
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
126 tlapack_check_false(m < 0);
127 tlapack_check_false(n < 0);
128 tlapack_check_false(lda < ((side == Side::Left) ? m : n));
130
131 // quick return
132 if (m == 0 || n == 0) return;
133
134 // adapt if row major
135 if (layout == Layout::RowMajor) {
137 if (uplo == Uplo::Lower)
139 else if (uplo == Uplo::Upper)
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
#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
Sort the numbers in D in increasing order (if ID = 'I') or in decreasing order (if ID = 'D' ).
Definition arrayTraits.hpp:15
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
Diag
Definition types.hpp:197
@ Unit
The main diagonal is assumed to consist of 1's.
@ NonUnit
The main diagonal is not assumed to consist of 1's.
Side
Definition types.hpp:271
@ Right
right side
@ Left
left side
constexpr auto diag(T &A, int diagIdx=0) noexcept
Get the Diagonal of an Eigen Matrix.
Definition eigen.hpp:576
Op
Definition types.hpp:227
@ Trans
transpose
@ NoTrans
no transpose
@ ConjTrans
conjugate transpose
Uplo
Definition types.hpp:50
@ Upper
0 <= i <= j, 0 <= j <= n.
@ Lower
0 <= i <= m, 0 <= j <= i.
constexpr Layout layout
Layout of a matrix or vector.
Definition arrayTraits.hpp:232
Layout
Definition types.hpp:29
@ ColMajor
Column-major layout.
@ RowMajor
Row-major layout.