12#ifndef TLAPACK_LAHQZ_SHIFTCOLUMN_HH
13#define TLAPACK_LAHQZ_SHIFTCOLUMN_HH
44template <TLAPACK_MATRIX matrix_t, TLAPACK_VECTOR vector_t,
bool>
48 complex_type<type_t<matrix_t>> s1,
49 complex_type<type_t<matrix_t>> s2,
50 type_t<matrix_t> beta1,
51 type_t<matrix_t> beta2);
55 enable_if_t<is_real<type_t<matrix_t>>,
bool> =
true>
70 const idx_t n = ncols(
A);
124 enable_if_t<is_complex<type_t<matrix_t>>,
bool> =
true>
128 complex_type<type_t<matrix_t>> s1,
129 complex_type<type_t<matrix_t>> s2,
130 type_t<matrix_t> beta1,
131 type_t<matrix_t> beta2)
134 using idx_t = size_type<matrix_t>;
135 using T = type_t<matrix_t>;
136 using real_t = real_type<T>;
139 const idx_t n = ncols(A);
141 const real_t safmin = safe_min<real_t>();
142 const real_t safmax = safe_max<real_t>();
150 T w1 = beta1 * A(0, 0) - s1 * B(0, 0);
151 T w2 = beta1 * A(1, 0) - s1 * B(1, 0);
157 T w1 = beta1 * A(0, 0) - s1 * B(0, 0);
158 T w2 = beta1 * A(1, 0) - s1 * B(1, 0);
159 real_t scale1 = sqrt(
abs1(w1)) * sqrt(
abs1(w2));
160 if (scale1 >= safmin and scale1 <= safmax) {
166 w1 = (w1 - B(0, 1) * w2) / B(0, 0);
167 real_t scale2 = sqrt(
abs1(w1)) * sqrt(
abs1(w2));
168 if (scale2 >= safmin and scale2 <= safmax) {
173 v[0] = beta2 * (A(0, 0) * w1 + A(0, 1) * w2) -
174 s2 * (B(0, 0) * w1 + B(0, 1) * w2);
175 v[1] = beta2 * (A(1, 0) * w1 + A(1, 1) * w2) -
176 s2 * (B(1, 0) * w1 + B(1, 1) * w2);
177 v[2] = beta2 * (A(2, 0) * w1 + A(2, 1) * w2) -
178 s2 * (B(2, 0) * w1 + B(2, 1) * w2);
180 if (
abs1(v[0]) > safmax or
abs1(v[1]) > safmax or
abs1(v[2]) > safmax) {
constexpr real_type< T > real(const T &x) noexcept
Extends std::real() to real datatypes.
Definition utils.hpp:71
constexpr real_type< T > abs1(const T &x)
1-norm absolute value, |Re(x)| + |Im(x)|
Definition utils.hpp:133
constexpr real_type< T > imag(const T &x) noexcept
Extends std::imag() to real datatypes.
Definition utils.hpp:86
#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
int lahqz_shiftcolumn(const matrix_t &A, const matrix_t &B, vector_t &v, complex_type< type_t< matrix_t > > s1, complex_type< type_t< matrix_t > > s2, type_t< matrix_t > beta1, type_t< matrix_t > beta2)
Given a 2-by-2 or 3-by-3 matrix pencil (A,B), lahqz_shiftcolumn calculates a multiple of the product:...
Definition lahqz_shiftcolumn.hpp:56
#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
typename traits::complex_type_traits< Types..., int >::type complex_type
The common complex type of the list of types.
Definition scalar_type_traits.hpp:188