12#ifndef TLAPACK_GENERALIZED_SCHUR_SWAP_HH
13#define TLAPACK_GENERALIZED_SCHUR_SWAP_HH
77 const idx_t n = ncols(
A);
88 const idx_t
j1 =
j0 + 1;
89 const idx_t
j2 =
j0 + 2;
90 const idx_t
j3 =
j0 + 3;
147 auto z1 = col(
Z,
j0);
148 auto z2 = col(
Z,
j1);
172 auto q1 = col(
Q,
j0);
173 auto q2 = col(
Q,
j1);
188 std::vector<T>
vl(3);
189 std::vector<T>
vrA(3);
190 std::vector<T>
vrB(3);
216 for (idx_t j = 0; j < 3; ++j) {
222 for (idx_t j = 0; j < 3; ++j) {
245 for (idx_t j = 2; j < 3; ++j) {
251 for (idx_t j = 2; j < 3; ++j) {
278 for (idx_t j =
j0; j < n; ++j) {
284 for (idx_t j =
j0; j < n; ++j) {
291 for (idx_t j = 0; j < n; ++j) {
300 for (idx_t j = 0; j <
j3; ++j) {
306 for (idx_t j = 0; j <
j3; ++j) {
313 for (idx_t j = 0; j < n; ++j) {
323 for (idx_t j = 0; j <
j3; ++j) {
329 for (idx_t j = 0; j <
j3; ++j) {
336 for (idx_t j = 0; j < n; ++j) {
357 std::vector<T>
vr(3);
358 std::vector<T>
vlA(3);
359 std::vector<T>
vlB(3);
384 for (idx_t j = 0; j < 3; ++j) {
390 for (idx_t j = 0; j < 3; ++j) {
412 for (idx_t j = 0; j < 3; ++j) {
418 for (idx_t j = 0; j < 3; ++j) {
445 for (idx_t j = 0; j <
j3; ++j) {
451 for (idx_t j = 0; j <
j3; ++j) {
458 for (idx_t j = 0; j < n; ++j) {
467 for (idx_t j =
j0; j < n; ++j) {
473 for (idx_t j =
j0; j < n; ++j) {
480 for (idx_t j = 0; j < n; ++j) {
490 for (idx_t j =
j0; j < n; ++j) {
496 for (idx_t j =
j0; j < n; ++j) {
503 for (idx_t j = 0; j < n; ++j) {
524 std::vector<idx_t>
piv(8);
526 for (idx_t j = 0; j < 8; ++j)
527 for (idx_t i = 0; i < 8; ++i)
582 for (idx_t i = 0; i < 8; ++i) {
583 if (i !=
piv[i]) std::swap(
x[i],
x[
piv[i]]);
666 auto a0 = row(
AA, 0);
667 auto a1 = row(
AA, 1);
668 auto a2 = row(
AA, 2);
669 auto a3 = row(
AA, 3);
675 auto b0 = row(
BB, 0);
676 auto b1 = row(
BB, 1);
677 auto b2 = row(
BB, 2);
678 auto b3 = row(
BB, 3);
684 auto q0 = col(
QQ, 0);
685 auto q1 = col(
QQ, 1);
686 auto q2 = col(
QQ, 2);
687 auto q3 = col(
QQ, 3);
696 auto a0 = col(
AA, 0);
697 auto a1 = col(
AA, 1);
698 auto a2 = col(
AA, 2);
699 auto a3 = col(
AA, 3);
705 auto b0 = col(
BB, 0);
706 auto b1 = col(
BB, 1);
707 auto b2 = col(
BB, 2);
708 auto b3 = col(
BB, 3);
714 auto z0 = col(
ZZ, 0);
715 auto z1 = col(
ZZ, 1);
716 auto z2 = col(
ZZ, 2);
717 auto z3 = col(
ZZ, 3);
742 for (idx_t j = 0; j < 8; ++j)
743 for (idx_t i = 0; i < 8; ++i)
797 if (
ierr != 0)
return 1;
799 for (idx_t i = 0; i < 8; ++i) {
800 if (i !=
piv[i]) std::swap(
x[i],
x[
piv[i]]);
842 std::swap(
x[5],
x[6]);
867 auto a0 = row(
AA, 0);
868 auto a1 = row(
AA, 1);
869 auto a2 = row(
AA, 2);
870 auto a3 = row(
AA, 3);
876 auto b0 = row(
BB, 0);
877 auto b1 = row(
BB, 1);
878 auto b2 = row(
BB, 2);
879 auto b3 = row(
BB, 3);
885 auto q0 = col(
QQ, 0);
886 auto q1 = col(
QQ, 1);
887 auto q2 = col(
QQ, 2);
888 auto q3 = col(
QQ, 3);
897 auto a0 = col(
AA, 0);
898 auto a1 = col(
AA, 1);
899 auto a2 = col(
AA, 2);
900 auto a3 = col(
AA, 3);
906 auto b0 = col(
BB, 0);
907 auto b1 = col(
BB, 1);
908 auto b2 = col(
BB, 2);
909 auto b3 = col(
BB, 3);
915 auto z0 = col(
ZZ, 0);
916 auto z1 = col(
ZZ, 1);
917 auto z2 = col(
ZZ, 2);
918 auto z3 = col(
ZZ, 3);
1018 lahqz_schur22(
A22,
B22,
alpha1,
alpha2,
beta1,
beta2,
cl2,
sl2,
cr,
sr,
1032 auto q0 = col(
Q,
j0);
1033 auto q1 = col(
Q,
j1);
1044 auto z0 = col(
Z,
j0);
1045 auto z1 = col(
Z,
j1);
1048 if (
scal0 != (T)1) {
1054 if (
scal1 != (T)1) {
1080 lahqz_schur22(
A22,
B22,
alpha1,
alpha2,
beta1,
beta2,
cl2,
sl2,
cr,
sr,
1110 if (
scal0 != (T)1) {
1116 if (
scal1 != (T)1) {
1150 const idx_t n = ncols(
A);
1159 const idx_t
j1 =
j0 + 1;
1191 auto z1 = col(
Z,
j0);
1192 auto z2 = col(
Z,
j1);
1216 auto q1 = col(
Q,
j0);
1217 auto q2 = col(
Q,
j1);
#define TLAPACK_CSMATRIX
Macro for tlapack::concepts::ConstructableAndSliceableMatrix compatible with C++17.
Definition concepts.hpp:961
real_type< TX, TY > lapy2(const TX &x, const TY &y)
Finds , taking care not to cause unnecessary overflow.
Definition lapy2.hpp:34
int generalized_schur_swap(bool want_q, bool want_z, matrix_t &A, matrix_t &B, matrix_t &Q, matrix_t &Z, const size_type< matrix_t > &j0, const size_type< matrix_t > &n1, const size_type< matrix_t > &n2)
schur_swap, swaps 2 eigenvalues of A.
Definition generalized_schur_swap.hpp:60
auto lange(norm_t normType, const matrix_t &A)
Calculates the norm of a matrix.
Definition lange.hpp:38
void svd22(const T &f, const T &g, const T &h, T &ssmin, T &ssmax, T &csl, T &snl, T &csr, T &snr)
Computes the singular value decomposition of a 2-by-2 real triangular matrix.
Definition svd22.hpp:55
void laset(uplo_t uplo, const type_t< matrix_t > &alpha, const type_t< matrix_t > &beta, matrix_t &A)
Initializes a matrix to diagonal and off-diagonal values.
Definition laset.hpp:38
void larfg(storage_t storeMode, type_t< vector_t > &alpha, vector_t &x, type_t< vector_t > &tau)
Generates a elementary Householder reflection.
Definition larfg.hpp:73
void lacpy(uplo_t uplo, const matrixA_t &A, matrixB_t &B)
Copies a matrix from A to B.
Definition lacpy.hpp:38
void inv_house3(const matrix_t &A, vector_t &v, type_t< vector_t > &tau)
Inv_house calculates a reflector to reduce the first column in a 2x3 matrix A from the right to zero.
Definition inv_house3.hpp:44
void rotg(T &a, T &b, T &c, T &s)
Construct plane rotation that eliminates b, such that:
Definition rotg.hpp:39
void rot(vectorX_t &x, vectorY_t &y, const c_type &c, const s_type &s)
Apply plane rotation:
Definition rot.hpp:44
void scal(const alpha_t &alpha, vector_t &x)
Scale vector by constant, .
Definition scal.hpp:30
void trsv(Uplo uplo, Op trans, Diag diag, const matrixA_t &A, vectorX_t &x)
Solve the triangular matrix-vector equation.
Definition trsv.hpp:64
void syr(Uplo uplo, const alpha_t &alpha, const vectorX_t &x, matrixA_t &A)
Symmetric matrix rank-1 update:
Definition syr.hpp:45
void gemm(Op transA, Op transB, const alpha_t &alpha, const matrixA_t &A, const matrixB_t &B, const beta_t &beta, matrixC_t &C)
General matrix-matrix multiply:
Definition gemm.hpp:61
#define tlapack_check(cond)
Throw an error if cond is false.
Definition exceptionHandling.hpp:98
int getrf(matrix_t &A, piv_t &piv, const GetrfOpts &opts={})
getrf computes an LU factorization of a general m-by-n matrix A.
Definition getrf.hpp:64
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 internal::FrobNorm FROB_NORM
Frobenius norm of matrices.
Definition types.hpp:354
constexpr internal::LowerTriangle LOWER_TRIANGLE
Lower Triangle access.
Definition types.hpp:188
constexpr internal::UpperTriangle UPPER_TRIANGLE
Upper Triangle access.
Definition types.hpp:186
constexpr T conj(const T &x) noexcept
Extends std::conj() to real datatypes.
Definition utils.hpp:100
constexpr internal::Forward FORWARD
Forward direction.
Definition types.hpp:388
constexpr internal::Transpose TRANSPOSE
transpose
Definition types.hpp:262
void lahqz_schur22(A_t &A, B_t &B, complex_type< type_t< A_t > > &alpha1, complex_type< type_t< A_t > > &alpha2, real_type< type_t< A_t > > &beta1, real_type< type_t< A_t > > &beta2, real_type< type_t< A_t > > &cl, type_t< A_t > &sl, real_type< type_t< A_t > > &cr, type_t< A_t > &sr, type_t< A_t > &scal0, type_t< A_t > &scal1)
Computes the generalized Schur factorization of a 2x2 pencil (A,B) with B upper triangular.
Definition lahqz_schur22.hpp:63
constexpr internal::UnitDiagonal UNIT_DIAG
The main diagonal is assumed to consist of 1's.
Definition types.hpp:222
constexpr internal::GeneralAccess GENERAL
General access.
Definition types.hpp:180
constexpr internal::NonUnitDiagonal NON_UNIT_DIAG
The main diagonal is not assumed to consist of 1's.
Definition types.hpp:220
constexpr internal::ColumnwiseStorage COLUMNWISE_STORAGE
Columnwise storage.
Definition types.hpp:421
constexpr internal::NoTranspose NO_TRANS
no transpose
Definition types.hpp:260
Strong zero type.
Definition StrongZero.hpp:43