<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
rot.hpp
Go to the documentation of this file.
1
3//
4// Copyright (c) 2017-2021, University of Tennessee. All rights reserved.
5// Copyright (c) 2021-2023, 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_ROT_HH
12#define TLAPACK_BLAS_ROT_HH
13
15
16namespace tlapack {
17
35template <TLAPACK_VECTOR vectorX_t,
36 TLAPACK_VECTOR vectorY_t,
37 TLAPACK_REAL c_type,
38 TLAPACK_SCALAR s_type,
39 class T = type_t<vectorX_t>,
40 disable_if_allow_optblas_t<pair<vectorX_t, T>,
41 pair<vectorY_t, T>,
42 pair<c_type, real_type<T> >,
43 pair<s_type, real_type<T> > > = 0>
44void rot(vectorX_t& x, vectorY_t& y, const c_type& c, const s_type& s)
45{
46 using idx_t = size_type<vectorX_t>;
47 using scalar_t =
49
50 // constants
51 const idx_t n = size(x);
52
53 // check arguments
54 tlapack_check_false(size(y) != n);
55
56 // quick return
57 if (n == 0 || (c == c_type(1) && s == s_type(0))) return;
58
59 for (idx_t i = 0; i < n; ++i) {
60 const scalar_t stmp = c * x[i] + s * y[i];
61 y[i] = c * y[i] - conj(s) * x[i];
62 x[i] = stmp;
63 }
64}
65
66#ifdef TLAPACK_USE_LAPACKPP
67
68template <TLAPACK_LEGACY_VECTOR vectorX_t,
69 TLAPACK_LEGACY_VECTOR vectorY_t,
70 TLAPACK_REAL c_type,
71 TLAPACK_SCALAR s_type,
72 class T = type_t<vectorX_t>,
73 enable_if_allow_optblas_t<pair<vectorX_t, T>,
74 pair<vectorY_t, T>,
75 pair<c_type, real_type<T> >,
76 pair<s_type, real_type<T> > > = 0>
77void rot(vectorX_t& x, vectorY_t& y, const c_type c, const s_type s)
78{
79 // Legacy objects
80 auto x_ = legacy_vector(x);
81 auto y_ = legacy_vector(y);
82
83 // Constants to forward
84 const auto& n = x_.n;
85
86 return ::blas::rot(n, x_.ptr, x_.inc, y_.ptr, y_.inc, c, s);
87}
88
89#endif
90
91} // namespace tlapack
92
93#endif // #ifndef TLAPACK_BLAS_ROT_HH
constexpr T conj(const T &x) noexcept
Extends std::conj() to real datatypes.
Definition utils.hpp:100
#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_VECTOR
Macro for tlapack::concepts::Vector compatible with C++17.
Definition concepts.hpp:906
#define TLAPACK_REAL
Macro for tlapack::concepts::Real compatible with C++17.
Definition concepts.hpp:918
void rot(vectorX_t &x, vectorY_t &y, const c_type &c, const s_type &s)
Apply plane rotation:
Definition rot.hpp:44
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
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