<T>LAPACK 0.1.2
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
syrk.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_SYRK_HH
12#define TLAPACK_LEGACY_SYRK_HH
13
14#include "tlapack/blas/syrk.hpp"
17
18namespace tlapack {
19namespace legacy {
20
88 template <typename TA, typename TC>
90 Uplo uplo,
91 Op trans,
92 idx_t n,
93 idx_t k,
95 TA const* A,
96 idx_t lda,
98 TC* C,
99 idx_t ldc)
100 {
101 using internal::create_matrix;
103
104 // check arguments
112 tlapack_check_false(n < 0);
115 ? ((trans == Op::NoTrans) ? k : n)
116 : ((trans == Op::NoTrans) ? n : k)));
118
119 // quick return
120 if (n == 0 ||
121 ((alpha == scalar_t(0) || k == 0) && (beta == scalar_t(1))))
122 return;
123
124 // This algorithm only works with Op::NoTrans or Op::Trans
126
127 // adapt if row major
128 if (layout == Layout::RowMajor) {
129 if (uplo == Uplo::Lower)
131 else if (uplo == Uplo::Upper)
134 }
135
136 // Matrix views
137 const auto A_ = (trans == Op::NoTrans)
138 ? create_matrix<TA>((TA*)A, n, k, lda)
139 : create_matrix<TA>((TA*)A, k, n, lda);
140 auto C_ = create_matrix<TC>(C, n, n, ldc);
141
142 if (alpha == scalar_t(0)) {
143 if (beta == scalar_t(0)) {
144 for (idx_t j = 0; j < n; ++j)
145 for (idx_t i = 0; i < n; ++i)
146 C_(i, j) = TC(0);
147 }
148 else {
149 for (idx_t j = 0; j < n; ++j)
150 for (idx_t i = 0; i < n; ++i)
151 C_(i, j) *= beta;
152 }
153 }
154 else {
155 if (beta == scalar_t(0))
156 syrk(uplo, trans, alpha, A_, C_);
157 else
158 syrk(uplo, trans, alpha, A_, beta, C_);
159 }
160 }
161
162} // namespace legacy
163} // namespace tlapack
164
165#endif // #ifndef TLAPACK_LEGACY_SYMM_HH
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
void syrk(Layout layout, Uplo uplo, Op trans, idx_t n, idx_t k, scalar_type< TA, TC > alpha, TA const *A, idx_t lda, scalar_type< TA, TC > beta, TC *C, idx_t ldc)
Symmetric rank-k update:
Definition syrk.hpp:89
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
Op
Definition types.hpp:227
@ Trans
transpose
@ NoTrans
no transpose
@ ConjTrans
conjugate transpose
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.