<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
trmm.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_TRMM_HH
12#define TLAPACK_LEGACY_TRMM_HH
13
14#include "tlapack/blas/trmm.hpp"
17
18namespace tlapack {
19namespace legacy {
20
97 template <typename TA, typename TB>
98 void trmm(Layout layout,
99 Side side,
100 Uplo uplo,
101 Op trans,
102 Diag diag,
103 idx_t m,
104 idx_t n,
106 TA const* A,
107 idx_t lda,
108 TB* B,
109 idx_t ldb)
110 {
111 using internal::create_matrix;
113
114 // check arguments
115 tlapack_check_false(layout != Layout::ColMajor &&
116 layout != Layout::RowMajor);
117 tlapack_check_false(side != Side::Left && side != Side::Right);
118 tlapack_check_false(uplo != Uplo::Lower && uplo != Uplo::Upper);
119 tlapack_check_false(trans != Op::NoTrans && trans != Op::Trans &&
120 trans != Op::ConjTrans);
121 tlapack_check_false(diag != Diag::NonUnit && diag != Diag::Unit);
122 tlapack_check_false(m < 0);
123 tlapack_check_false(n < 0);
124 tlapack_check_false(lda < ((side == Side::Left) ? m : n));
125 tlapack_check_false(ldb < ((layout == Layout::RowMajor) ? n : m));
126
127 // quick return
128 if (m == 0 || n == 0) return;
129
130 // adapt if row major
131 if (layout == Layout::RowMajor) {
132 side = (side == Side::Left) ? Side::Right : Side::Left;
133 if (uplo == Uplo::Lower)
134 uplo = Uplo::Upper;
135 else if (uplo == Uplo::Upper)
136 uplo = Uplo::Lower;
137 std::swap(m, n);
138 }
139
140 // Matrix views
141 const auto A_ = (side == Side::Left)
142 ? create_matrix<TA>((TA*)A, m, m, lda)
143 : create_matrix<TA>((TA*)A, n, n, lda);
144 auto B_ = create_matrix<TB>(B, m, n, ldb);
145
146 if (alpha == scalar_t(0))
147 for (idx_t j = 0; j < n; ++j)
148 for (idx_t i = 0; i < m; ++i)
149 B_(i, j) = TB(0);
150 else
151 trmm(side, uplo, trans, diag, alpha, A_, B_);
152 }
153
154} // namespace legacy
155} // namespace tlapack
156
157#endif // #ifndef TLAPACK_LEGACY_TRMM_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 trmm(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)
Triangular matrix-matrix multiply:
Definition trmm.hpp:98
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