12#ifndef TLAPACK_ROT_SEQUENCE_HH
13#define TLAPACK_ROT_SEQUENCE_HH
88 const idx_t m = nrows(
A);
89 const idx_t n = ncols(
A);
90 const idx_t
k = (
side == Side::Left) ? m - 1 : n - 1;
100 if (direction == Direction::Forward) {
101 if (
side == Side::Left) {
102 for (idx_t j = 0; j < n; ++j) {
103 for (idx_t
i2 =
k;
i2 > 0; --
i2) {
105 T
temp = c[i] *
A(i, j) +
s[i] *
A(i + 1, j);
107 -
conj(
s[i]) *
A(i, j) + c[i] *
A(i + 1, j);
119 for (idx_t j = 0; j < m; ++j) {
120 T
temp =
A(j, i + 1);
134 -
s[i - 2] *
A(j, i - 2) + c[i - 2] *
temp1;
143 for (idx_t j = 0; j < m; ++j) {
144 T
temp = c[i] *
A(j, i) +
conj(
s[i]) *
A(j, i + 1);
145 A(j, i + 1) = -
s[i] *
A(j, i) + c[i] *
A(j, i + 1);
152 if (
side == Side::Left) {
153 for (idx_t j = 0; j < n; ++j) {
154 for (idx_t i = 0; i <
k; ++i) {
155 T
temp = c[i] *
A(i, j) +
s[i] *
A(i + 1, j);
157 -
conj(
s[i]) *
A(i, j) + c[i] *
A(i + 1, j);
166 idx_t
ii =
k - (
k % 3);
167 for (idx_t i = 0; i + 1 <
ii; i = i + 3) {
168 for (idx_t j = 0; j < m; ++j) {
185 -
s[i + 2] *
temp1 + c[i + 2] *
A(j, i + 3);
190 for (idx_t i =
ii; i <
k; ++i) {
191 for (idx_t j = 0; j < m; ++j) {
192 T
temp = c[i] *
A(j, i) +
conj(
s[i]) *
A(j, i + 1);
193 A(j, i + 1) = -
s[i] *
A(j, i) + c[i] *
A(j, i + 1);
201 if (direction == Direction::Forward) {
202 if (
side == Side::Left) {
209 for (idx_t j = 0; j < n; ++j) {
210 T
temp =
A(i + 1, j);
225 A(i - 2, j) = c[i - 2] *
A(i - 2, j) +
s[i - 2] *
temp1;
232 for (idx_t j = 0; j < n; ++j) {
233 T
temp = c[i] *
A(i, j) +
s[i] *
A(i + 1, j);
235 -
conj(
s[i]) *
A(i, j) + c[i] *
A(i + 1, j);
241 for (idx_t j = 0; j < m; ++j) {
242 for (idx_t
i2 =
k;
i2 > 0; --
i2) {
244 T
temp = c[i] *
A(j, i) +
conj(
s[i]) *
A(j, i + 1);
245 A(j, i + 1) = -
s[i] *
A(j, i) + c[i] *
A(j, i + 1);
252 if (
side == Side::Left) {
255 idx_t
ii =
k - (
k % 3);
256 for (idx_t i = 0; i + 1 <
ii; i = i + 3) {
257 for (idx_t j = 0; j < n; ++j) {
271 A(i + 2, j) = c[i + 2] *
temp1 +
s[i + 2] *
A(i + 3, j);
278 for (idx_t i =
ii; i <
k; ++i) {
279 for (idx_t j = 0; j < n; ++j) {
280 T
temp = c[i] *
A(i, j) +
s[i] *
A(i + 1, j);
282 -
conj(
s[i]) *
A(i, j) + c[i] *
A(i + 1, j);
288 for (idx_t j = 0; j < m; ++j) {
289 for (idx_t i = 0; i <
k; ++i) {
290 T
temp = c[i] *
A(j, i) +
conj(
s[i]) *
A(j, i + 1);
291 A(j, i + 1) = -
s[i] *
A(j, i) + c[i] *
A(j, i + 1);
constexpr T conj(const T &x) noexcept
Extends std::conj() to real datatypes.
Definition utils.hpp:100
#define TLAPACK_SVECTOR
Macro for tlapack::concepts::SliceableVector compatible with C++17.
Definition concepts.hpp:909
#define TLAPACK_SIDE
Macro for tlapack::concepts::Side compatible with C++17.
Definition concepts.hpp:927
#define TLAPACK_SMATRIX
Macro for tlapack::concepts::SliceableMatrix compatible with C++17.
Definition concepts.hpp:899
#define TLAPACK_DIRECTION
Macro for tlapack::concepts::Direction compatible with C++17.
Definition concepts.hpp:930
int rot_sequence(side_t side, direction_t direction, const C_t &c, const S_t &s, A_t &A)
Applies a sequence of plane rotations to an (m-by-n) matrix.
Definition rot_sequence.hpp:81
#define tlapack_check(cond)
Throw an error if cond is false.
Definition exceptionHandling.hpp:98
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