<T>LAPACK 0.1.2
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
geru.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_GERU_HH
12#define TLAPACK_BLAS_GERU_HH
13
15#include "tlapack/blas/ger.hpp"
16
17namespace tlapack {
18
38 class T = type_t<matrixA_t>,
43void geru(const alpha_t& alpha,
44 const vectorX_t& x,
45 const vectorY_t& y,
46 matrixA_t& A)
47{
48 // data traits
49 using idx_t = size_type<matrixA_t>;
51
52 // constants
53 const idx_t m = nrows(A);
54 const idx_t n = ncols(A);
55
56 // check arguments
57 tlapack_check_false(size(x) != m);
58 tlapack_check_false(size(y) != n);
59
60 for (idx_t j = 0; j < n; ++j) {
61 const scalar_t tmp = alpha * y[j];
62 for (idx_t i = 0; i < m; ++i)
63 A(i, j) += x[i] * tmp;
64 }
65}
66
67#ifdef TLAPACK_USE_LAPACKPP
68
73 class T = type_t<matrixA_t>,
78void geru(const alpha_t alpha,
79 const vectorX_t& x,
80 const vectorY_t& y,
81 matrixA_t& A)
82{
83 // Legacy objects
84 auto A_ = legacy_matrix(A);
85 auto x_ = legacy_vector(x);
86 auto y_ = legacy_vector(y);
87
88 // Constants to forward
89 constexpr Layout L = layout<matrixA_t>;
90 const auto& m = A_.m;
91 const auto& n = A_.n;
92
93 return ::blas::geru((::blas::Layout)L, m, n, alpha, x_.ptr, x_.inc, y_.ptr,
94 y_.inc, A_.ptr, A_.ldim);
95}
96
97#endif
98
99} // namespace tlapack
100
101#endif // #ifndef TLAPACK_BLAS_GER_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 geru(const alpha_t &alpha, const vectorX_t &x, const vectorY_t &y, matrixA_t &A)
General matrix rank-1 update:
Definition geru.hpp:43
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
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
Layout
Definition types.hpp:29