<T>LAPACK 0.1.2
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
syr2.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_BLAS_SYR2_HH
12#define TLAPACK_BLAS_SYR2_HH
13
15
16namespace tlapack {
17
43 class T = type_t<matrixA_t>,
49 const alpha_t& alpha,
50 const vectorX_t& x,
51 const vectorY_t& y,
52 matrixA_t& A)
53{
54 // data traits
55 using idx_t = size_type<matrixA_t>;
56 using TX = type_t<vectorX_t>;
57 using TY = type_t<vectorY_t>;
58
59 // constants
60 const idx_t n = nrows(A);
61
62 // check arguments
64 tlapack_check_false(size(x) != n);
65 tlapack_check_false(size(y) != n);
66 tlapack_check_false(ncols(A) != n);
67
68 if (uplo == Uplo::Upper) {
69 for (idx_t j = 0; j < n; ++j) {
72 for (idx_t i = 0; i <= j; ++i)
73 A(i, j) += x[i] * tmp1 + y[i] * tmp2;
74 }
75 }
76 else {
77 for (idx_t j = 0; j < n; ++j) {
80 for (idx_t i = j; i < n; ++i)
81 A(i, j) += x[i] * tmp1 + y[i] * tmp2;
82 }
83 }
84}
85
86#ifdef TLAPACK_USE_LAPACKPP
87
92 class T = type_t<matrixA_t>,
97void syr2(Uplo uplo,
98 const alpha_t alpha,
99 const vectorX_t& x,
100 const vectorY_t& y,
101 matrixA_t& A)
102{
103 // Legacy objects
104 auto A_ = legacy_matrix(A);
105 auto x_ = legacy_vector(x);
106 auto y_ = legacy_vector(y);
107
108 // Constants to forward
109 constexpr Layout L = layout<matrixA_t>;
110 const auto& n = A_.n;
111
112 return ::blas::syr2((::blas::Layout)L, (::blas::Uplo)uplo, n, alpha, x_.ptr,
113 x_.inc, y_.ptr, y_.inc, A_.ptr, A_.ldim);
114}
115
116#endif
117
118} // namespace tlapack
119
120#endif // #ifndef TLAPACK_BLAS_SYR2_HH
#define TLAPACK_SCALAR
Macro for tlapack::concepts::Scalar compatible with C++17.
Definition concepts.hpp:915
#define TLAPACK_LEGACY_VECTOR
Macro for tlapack::concepts::LegacyVector compatible with C++17.
Definition concepts.hpp:954
#define TLAPACK_LEGACY_MATRIX
Macro for tlapack::concepts::LegacyMatrix compatible with C++17.
Definition concepts.hpp:951
#define TLAPACK_VECTOR
Macro for tlapack::concepts::Vector compatible with C++17.
Definition concepts.hpp:906
#define TLAPACK_MATRIX
Macro for tlapack::concepts::Matrix compatible with C++17.
Definition concepts.hpp:896
void syr2(Uplo uplo, const alpha_t &alpha, const vectorX_t &x, const vectorY_t &y, matrixA_t &A)
Symmetric matrix rank-2 update:
Definition syr2.hpp:48
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
Concept for types that represent tlapack::Uplo.
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
Uplo
Definition types.hpp:50
@ Upper
0 <= i <= j, 0 <= j <= n.
@ Lower
0 <= i <= m, 0 <= j <= i.
Layout
Definition types.hpp:29