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

Classes

struct  mtl::detail::logm_impl::theta_row
 theta_m for m = 1..16 at unit roundoff u = 2^-t, generated by tools/logm_theta.py and rounded toward zero. More...
struct  mtl::detail::logm_impl::real_of< T >
struct  mtl::detail::logm_impl::real_of< std::complex< R > >

Namespaces

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

Concepts

concept  mtl::detail::logm_impl::adl::has_log
concept  mtl::detail::logm_impl::adl::has_atan2
concept  mtl::detail::logm_impl::adl::has_atanh

Functions

template<typename R>
std::size_t mtl::detail::logm_impl::table_index ()
template<typename R>
R mtl::detail::logm_impl::adl::call_log (const R &x)
template<typename R>
R mtl::detail::logm_impl::adl::call_atan2 (const R &y, const R &x)
template<typename R>
R mtl::detail::logm_impl::adl::call_atanh (const R &x)
template<typename R>
R mtl::detail::logm_impl::log_lapy2 (const R &x, const R &y)
 log sqrt(x^2 + y^2).
template<typename R>
std::complex< R > mtl::detail::logm_impl::clog (const std::complex< R > &z)
 The principal logarithm of a complex number: log|z| + i arg z.
template<typename T>
real_of< T >::type mtl::detail::logm_impl::one_norm (const mat::dense2D< T > &M)
 ||M||_1 of a dense square matrix: the largest column sum of |m_ij|, with a complex entry measured as |re| + |im| as LAPACK's cabs1 does.
template<typename R>
bool mtl::detail::logm_impl::alpha_within (const std::array< R, 6 > &nrm, int p, const R &theta)
 alpha_p(X) <= theta, as ||X^p|| <= theta^p and ||X^(p+1)|| <= theta^(p+1), from the norms nrm[p] = ||X^p||_1.
template<typename Accumulator, typename T>
std::array< typename real_of< T >::type, 6 > mtl::detail::logm_impl::power_norms (const mat::dense2D< T > &Tm)
 The norms ||(T - I)^p||_1 for p = 1..5.
template<typename T>
std::vector< std::complex< typename real_of< T >::type > > mtl::detail::logm_impl::eigenvalues_of (const mat::dense2D< T > &Tm)
 The eigenvalues of quasi-triangular T, as complex numbers: a 1x1 block t, and a 2x2 block [a b; c a] as a +- i sqrt|b| sqrt|c|.
template<typename T>
T mtl::detail::logm_impl::briggs (T a, int k)
 a^(1/2^k) - 1 without the cancellation of forming the root first: (a - 1) / prod_{j=1}^{k} (1 + a^(1/2^j)) (Al-Mohy 2012; SciPy's _briggs_helper_function).
template<typename T>
mat::dense2D< T > mtl::detail::logm_impl::solve_quasi_triangular (const mat::dense2D< T > &M, const mat::dense2D< T > &B, const std::vector< std::size_t > &blocks)
 Solve M Y = B for M upper quasi-triangular with the diagonal blocks blocks (start indices, then n), by block back substitution; a 2x2 block is solved by Gaussian elimination with partial pivoting.
template<typename R>
void mtl::detail::logm_impl::gauss_legendre (int m, std::vector< R > &x, std::vector< R > &w)
 The m-point Gauss-Legendre rule on [0, 1], in R: Newton on the Legendre recurrence from double-precision starting values, so the nodes and weights carry R's own precision.
template<typename R>
void mtl::detail::logm_impl::log_block2 (const R &a, const R &b, const R &c, R(&l)[2][2])
 log of a real 2x2 block [a b; c a] with b c < 0: log(rho) I + (theta / mu) N, N = [0 b; c 0], since N^2 = -mu^2 I; rho = |a + i mu|, theta = arg(a + i mu).
template<typename T>
T mtl::detail::logm_impl::superdiagonal_log (const T &l1, const T &l2, const T &t)
 The (1,2) entry of log([l1 t; 0 l2]) (Higham 2008, (11.28), with SciPy's test for well-separated eigenvalues).
void mtl::detail::logm_impl::no_principal_log (const char *who)
template<typename Accumulator, typename T>
mat::dense2D< T > mtl::detail::logm_impl::log_quasi_triangular (const mat::dense2D< T > &T0, const char *who)
 log of quasi-triangular (real) or triangular (complex) T, the principal branch.
template<typename Accumulator = void, FieldMatrix M>
auto mtl::logm (const M &A)
 The principal logarithm of a square matrix: the X with exp(X) = A whose eigenvalues have imaginary parts in (-pi, pi), as a dense2D of A's element type.

Variables

constexpr theta_row mtl::detail::logm_impl::theta_table []
constexpr int mtl::detail::logm_impl::loop_cap = 1 << 10
template<typename T>
constexpr bool mtl::detail::logm_impl::exact_entries
 Whether the recomputation of step 5 is available for T.