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