|
MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
|
Functions | |
| template<typename R> | |
| void | sqrt_block2 (const R &a0, const R &b, const R &c, R(&r)[2][2]) |
| The principal square root of a real 2x2 block [a b; c a] with b c < 0 (Higham 1987): alpha I + (T - a I) / (2 alpha), alpha the real part of sqrt(a + i mu), mu = sqrt(-b c). | |
| template<typename T> | |
| void | require_finite_result (const mat::dense2D< T > &X, const char *who, const char *what="the result") |
| Throws std::overflow_error unless every entry of X is finite. | |
| void | no_principal_root (const char *who) |
| template<typename T> | |
| mat::dense2D< T > | sqrt_quasi_triangular (const mat::dense2D< T > &Tm, const char *who) |
| R with R R = T for T upper quasi-triangular (real) or upper triangular (complex), the principal root. | |
| template<typename T> | |
| mat::dense2D< T > | adjoint (const mat::dense2D< T > &Q) |
| Q^H: the transpose, conjugated for a complex type. | |
| mat::dense2D< T > mtl::detail::sqrtm_impl::adjoint | ( | const mat::dense2D< T > & | Q | ) |
Q^H: the transpose, conjugated for a complex type.
|
inline |
| void mtl::detail::sqrtm_impl::require_finite_result | ( | const mat::dense2D< T > & | X, |
| const char * | who, | ||
| const char * | what = "the result" ) |
Throws std::overflow_error unless every entry of X is finite.
what names X in the message: the result, or the Schur factor, whose eigenvalues can exceed the largest finite value although A's entries do not.
| void mtl::detail::sqrtm_impl::sqrt_block2 | ( | const R & | a0, |
| const R & | b, | ||
| const R & | c, | ||
| R(&) | r[2][2] ) |
The principal square root of a real 2x2 block [a b; c a] with b c < 0 (Higham 1987): alpha I + (T - a I) / (2 alpha), alpha the real part of sqrt(a + i mu), mu = sqrt(-b c).
Formed in real arithmetic: alpha = sqrt((|z| + a) / 2) for a >= 0, and mu / (2 sqrt((|z| - a) / 2)) for a < 0, which avoids the cancellation in |z| + a.
alpha depends only on a and mu, so only those two are scaled: by a power of 4 that brings the larger into [1, 4), with alpha scaled back by the matching power of 2. Both steps are exact. So |z| cannot overflow, and alpha cannot underflow to zero for a subnormal block. b and c are never scaled. A block of mixed scale, such as [0 1e308; -1e-308 0], keeps its small entry, and the off-diagonal entries of the root are b / (2 alpha) and c / (2 alpha) from the given b and c. mu = sqrt|b| sqrt|c| does not overflow where b c would. Where it rounds past the largest finite value, the quarter (sqrt|b| / 2)(sqrt|c| / 2) is used, with a / 4.
| mat::dense2D< T > mtl::detail::sqrtm_impl::sqrt_quasi_triangular | ( | const mat::dense2D< T > & | Tm, |
| const char * | who ) |
R with R R = T for T upper quasi-triangular (real) or upper triangular (complex), the principal root.
Throws std::domain_error when a diagonal block has an eigenvalue on the closed negative real axis.