<T>LAPACK 0.1.2
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
hemm.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_HEMM_HH
12#define TLAPACK_LEGACY_HEMM_HH
13
14#include "tlapack/blas/hemm.hpp"
17
18namespace tlapack {
19namespace legacy {
20
89 template <typename TA, typename TB, typename TC>
91 Side side,
92 Uplo uplo,
93 idx_t m,
94 idx_t n,
96 TA const* A,
97 idx_t lda,
98 TB const* B,
99 idx_t ldb,
101 TC* C,
102 idx_t ldc)
103 {
104 using internal::create_matrix;
106
107 // check arguments
113 tlapack_check_false(m < 0);
114 tlapack_check_false(n < 0);
115 tlapack_check_false(lda < ((side == Side::Left) ? m : n));
118
119 // quick return
120 if (m == 0 || n == 0 ||
121 ((alpha == scalar_t(0)) && (beta == scalar_t(1))))
122 return;
123
124 // adapt if row major
125 if (layout == Layout::RowMajor) {
127 if (uplo == Uplo::Lower)
129 else if (uplo == Uplo::Upper)
131 std::swap(m, n);
132 }
133
134 // Matrix views
135 const auto A_ = (side == Side::Left)
136 ? create_matrix<TA>((TA*)A, m, m, lda)
137 : create_matrix<TA>((TA*)A, n, n, lda);
138 const auto B_ = create_matrix<TB>((TB*)B, m, n, ldb);
139 auto C_ = create_matrix<TC>(C, m, n, ldc);
140
141 if (alpha == scalar_t(0)) {
142 if (beta == scalar_t(0)) {
143 for (idx_t j = 0; j < n; ++j)
144 for (idx_t i = 0; i < m; ++i)
145 C_(i, j) = TC(0);
146 }
147 else {
148 for (idx_t j = 0; j < n; ++j)
149 for (idx_t i = 0; i < m; ++i)
150 C_(i, j) *= beta;
151 }
152 }
153 else {
154 if (beta == scalar_t(0))
155 hemm(side, uplo, alpha, A_, B_, C_);
156 else
157 hemm(side, uplo, alpha, A_, B_, beta, C_);
158 }
159 }
160
161} // namespace legacy
162} // namespace tlapack
163
164#endif // #ifndef TLAPACK_LEGACY_HEMM_HH
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
void hemm(Layout layout, Side side, Uplo uplo, idx_t m, idx_t n, scalar_type< TA, TB, TC > alpha, TA const *A, idx_t lda, TB const *B, idx_t ldb, scalar_type< TA, TB, TC > beta, TC *C, idx_t ldc)
Hermitian matrix-matrix multiply:
Definition hemm.hpp:90
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
Side
Definition types.hpp:271
@ Right
right side
@ Left
left side
Uplo
Definition types.hpp:50
@ General
0 <= i <= m, 0 <= j <= n.
@ 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.