12#ifndef TLAPACK_TREVC_PROTECT_HH
13#define TLAPACK_TREVC_PROTECT_HH
36template <TLAPACK_SCALAR T, enable_if_t<is_real<T>,
int> = 0>
73template <TLAPACK_SCALAR T, enable_if_t<is_complex<T>,
int> = 0>
109template <TLAPACK_SCALAR T, enable_if_t<is_real<T>,
int> = 0>
137template <TLAPACK_SCALAR T, enable_if_t<is_real<T>,
int> = 0>
165template <TLAPACK_SCALAR T, enable_if_t<is_real<T>,
int> = 0>
170 if (abs(a) > (
sf_max - abs(
b)))
xi = T(0.5);
185template <TLAPACK_SCALAR T, enable_if_t<is_complex<T>,
int> = 0>
190 return std::min<real_type<T>>(
xir,
xii);
213template <TLAPACK_SCALAR T, enable_if_t<is_real<T>,
int> = 0>
324template <TLAPACK_SCALAR T, enable_if_t<is_real<T>,
int> = 0>
505template <TLAPACK_MATRIX matrix_T_t, TLAPACK_VECTOR vector_colN_t>
515 const idx_t n = nrows(T);
521 for (idx_t j = 0; j < n;) {
524 if (T(j + 1, j) !=
TT(0)) {
532 for (idx_t i = 0; i < j; ++i) {
543 for (idx_t i = 0; i < j; ++i) {
552 for (idx_t j = 0; j < n;) {
555 if (T(j + 1, j) !=
TT(0)) {
564 for (idx_t i = 0; i < j; ++i) {
575 for (idx_t i = 0; i < j; ++i) {
void ladiv(const real_t &a, const real_t &b, const real_t &c, const real_t &d, real_t &p, real_t &q)
Performs complex division in real arithmetic.
Definition ladiv.hpp:39
#define tlapack_check(cond)
Throw an error if cond is false.
Definition exceptionHandling.hpp:98
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 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
T trevc_protectupdate(T ynorm, T tnorm, T xnorm, T sf_max)
Given the infinity norms of the matrices Y, T, and X, calculate a scaling factor scale in (0,...
Definition trevc_protect.hpp:138
constexpr real_type< T > imag(const T &x) noexcept
Extends std::imag() to real datatypes.
Definition utils.hpp:86
T trevc_protectdiv(T a, T b, T sf_min, T sf_max)
Given two numbers a and b, calculate a scaling factor alpha in (0, 1] such that the division (a * alp...
Definition trevc_protect.hpp:37
Norm
Definition types.hpp:308
@ Inf
infinity norm of matrices
void trevc_colnorms(Norm norm, const matrix_T_t &T, vector_colN_t &colN)
Calculate the 1- or infinity-norms of the columns of the strictly upper triangular part of T.
Definition trevc_protect.hpp:506
void trevc_2x2solve(T a, T b, T c, T d, T &x1, T &x2, T &scale, T sf_min, T sf_max)
Robustly solve a 2x2 system of equations (a b) (x1) = scale * (rhs1) (c d) (x2) (rhs2)
Definition trevc_protect.hpp:214
T trevc_protectsum(T a, T b, T sf_max)
Calculate a scaling factor xi in [0.5, 1] such that the sum (xi * a) + (xi * b) does not overflow.
Definition trevc_protect.hpp:166