MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
sylvester.hpp File Reference
#include <complex>
#include <cstddef>
#include <limits>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
#include <mtl/concepts/matrix.hpp>
#include <mtl/concepts/scalar.hpp>
#include <mtl/concepts/magnitude.hpp>
#include <mtl/mat/dense2D.hpp>
#include <mtl/math/accumulator_traits.hpp>
#include <mtl/math/pow2_scaling.hpp>
#include <mtl/operation/mult.hpp>
#include <mtl/operation/schur.hpp>
#include <mtl/detail/unit_roundoff.hpp>
#include <mtl/interface/dispatch_traits.hpp>

Classes

struct  mtl::sylvester_result< Value >
 The solution of a Sylvester equation. More...
struct  mtl::sylvester_scaled_result< Value >
 The solution of a Sylvester equation scaled against overflow, as LAPACK trsyl returns it: X solves A X + sgn X B = scale * C with 0 < scale <= 1. More...
struct  mtl::detail::sylvester_limits< R >
 The range limits of a Sylvester solve, from numeric_limits: More...

Namespaces

namespace  mtl
namespace  mtl::detail
 mat*vec multiply into pre-allocated y: y = A * x.

Enumerations

enum class  mtl::sylvester_sign { mtl::plus , mtl::minus }
 The sign between the two terms of a Sylvester equation: plus for A X + X B = C, minus for A X - X B = C. More...

Functions

template<typename T>
bool mtl::detail::sylvester_representable (const T &x)
 Whether a solution entry is representable: finite, and below the largest value of the real type (a posit saturates there rather than overflowing).
template<typename M>
std::vector< std::size_t > mtl::detail::quasi_triangular_blocks (const M &T, const char *who, const char *name)
 The diagonal blocks of an upper quasi-triangular square matrix, as their starting indices followed by n.
template<typename R>
sylvester_limits< R > mtl::detail::make_sylvester_limits (std::size_t m, std::size_t n, const R &eps)
template<typename R>
R mtl::detail::scale_down_to_one (R x)
 The largest power of two f <= 1 with x * f <= 1, for x > 1.
template<typename Value>
Value mtl::detail::sylvester_scale_pow2 (const Value &x, int k)
 x * 2^k, part by part for a complex type: exact in a binary type unless the result overflows or becomes subnormal.
template<typename T>
T mtl::detail::block_quotient (const T &x, const T &y)
 Solve the p*q unknowns of a p x p block a and a q x q block b (p, q <= 2),.
template<typename T, typename R>
bool mtl::detail::solve_sylvester_block (const T(&a)[2][2], int p, const T(&b)[2][2], int q, const T &sgn, T(&rhs)[2][2], const R &smin, const sylvester_limits< R > &lim, bool scaled, R &scaloc)
template<typename Accumulator, typename MA, typename MB, typename MC>
sylvester_scaled_result< typename MC::value_type > mtl::detail::sylvester_triangular_inhouse (const MA &A, const MB &B, const MC &C, sylvester_sign sign, const std::vector< std::size_t > &ablocks, const std::vector< std::size_t > &bblocks, bool scaled)
 The in-house solve behind sylvester_triangular (scaled == false: no scaling, scale stays 1) and sylvester_triangular_scaled (scaled == true).
template<typename Accumulator, typename MA, typename MB, typename MC>
sylvester_scaled_result< typename MC::value_type > mtl::detail::sylvester_triangular_solve (const MA &A, const MB &B, const MC &C, sylvester_sign sign, bool scaled)
 Validate, dispatch and solve, for sylvester_triangular (scaled == false) and sylvester_triangular_scaled (scaled == true).
template<typename Accumulator = void, FieldMatrix MA, FieldMatrix MB, FieldMatrix MC>
auto mtl::sylvester_triangular_scaled (const MA &A, const MB &B, const MC &C, sylvester_sign sign=sylvester_sign::plus)
 Solve A X + X B = scale * C (sylvester_sign::plus, the default) or A X - X B = scale * C (sylvester_sign::minus) for X and a scale factor 0 < scale <= 1, as LAPACK trsyl does.
template<typename Accumulator = void, FieldMatrix MA, FieldMatrix MB, FieldMatrix MC>
auto mtl::sylvester_triangular (const MA &A, const MB &B, const MC &C, sylvester_sign sign=sylvester_sign::plus)
 Solve A X + X B = C (sylvester_sign::plus, the default) or A X - X B = C (sylvester_sign::minus) for X, where A (m x m) and B (n x n) are upper quasi-triangular, as schur() returns them, or upper triangular, as rsf2csf() returns them.
template<typename Value>
magnitude_t< Value > mtl::detail::sylvester_max_part (const mat::dense2D< Value > &X)
 The largest |x| over X's entries; for a complex type the largest |part|, as in sylvester_representable.
template<typename R>
int mtl::detail::sylvester_downscale_exponent (const R &p, const R &bound)
 The k >= 0 for which p * 2^-k <= bound: 0 when p <= bound already, and otherwise the smallest k the binary exponents of p and bound guarantee.
template<typename Accumulator = void, FieldMatrix MA, FieldMatrix MB, FieldMatrix MC>
auto mtl::sylvester (const MA &A, const MB &B, const MC &C, sylvester_sign sign=sylvester_sign::plus)
 Solve A X + X B = C (sylvester_sign::plus, the default) or A X - X B = C (sylvester_sign::minus) for general square A (m x m) and B (n x n), and C (m x n), by the Bartels-Stewart method: A = Q_A T_A Q_A^H and B = Q_B T_B Q_B^H by schur(), then T_A Y + Y T_B = Q_A^H C Q_B by sylvester_triangular(), and X = Q_A Y Q_B^H.