<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
rotm.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_ROTM_HH
12#define TLAPACK_BLAS_ROTM_HH
13
15
16namespace tlapack {
17
67template <
68 int flag,
69 TLAPACK_VECTOR vectorX_t,
70 TLAPACK_VECTOR vectorY_t,
71 enable_if_t<((-2 <= flag) && (flag <= 1)), int> = 0,
72 class T = type_t<vectorX_t>,
73 enable_if_t<is_same_v<T, real_type<T> >, int> = 0,
74 disable_if_allow_optblas_t<pair<vectorX_t, T>, pair<vectorY_t, T> > = 0>
75void rotm(vectorX_t& x, vectorY_t& y, const T h[4])
76{
77 using idx_t = size_type<vectorX_t>;
79
80 // constants
81 const idx_t n = size(x);
82
83 // check arguments
84 tlapack_check_false(size(y) != n);
85
86 if (flag == -1) {
87 for (idx_t i = 0; i < n; ++i) {
88 const scalar_t stmp = h[0] * x[i] + h[2] * y[i];
89 y[i] = h[3] * y[i] + h[1] * x[i];
90 x[i] = stmp;
91 }
92 }
93 else if (flag == 0) {
94 for (idx_t i = 0; i < n; ++i) {
95 const scalar_t stmp = x[i] + h[2] * y[i];
96 y[i] = y[i] + h[1] * x[i];
97 x[i] = stmp;
98 }
99 }
100 else if (flag == 1) {
101 for (idx_t i = 0; i < n; ++i) {
102 const scalar_t stmp = h[0] * x[i] + y[i];
103 y[i] = h[3] * y[i] - x[i];
104 x[i] = stmp;
105 }
106 }
107}
108
109#ifdef TLAPACK_USE_LAPACKPP
110
111template <
112 int flag,
113 TLAPACK_LEGACY_VECTOR vectorX_t,
114 TLAPACK_LEGACY_VECTOR vectorY_t,
115 enable_if_t<((-2 <= flag) && (flag <= 1)), int> = 0,
116 class T = type_t<vectorX_t>,
117 enable_if_t<is_same_v<T, real_type<T> >, int> = 0,
118 enable_if_allow_optblas_t<pair<vectorX_t, T>, pair<vectorY_t, T> > = 0>
119void rotm(vectorX_t& x, vectorY_t& y, const T h[4])
120{
121 // Legacy objects
122 auto x_ = legacy_vector(x);
123 auto y_ = legacy_vector(y);
124
125 // Constants to forward
126 const auto& n = x_.n;
127 const T h_[] = {(T)flag, h[0], h[1], h[2], h[3]};
128
129 return ::blas::rotm(n, x_.ptr, x_.inc, y_.ptr, y_.inc, h_);
130}
131
132#endif
133
134} // namespace tlapack
135
136#endif // #ifndef TLAPACK_BLAS_ROTM_HH
#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
void rotm(vectorX_t &x, vectorY_t &y, const T h[4])
Apply modified (fast) plane rotation, H:
Definition rotm.hpp:75
#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