MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
expm.hpp File Reference
#include <array>
#include <cmath>
#include <complex>
#include <concepts>
#include <cstddef>
#include <limits>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
#include <mtl/concepts/matrix.hpp>
#include <mtl/concepts/magnitude.hpp>
#include <mtl/mat/dense2D.hpp>
#include <mtl/vec/dense_vector.hpp>
#include <mtl/math/identity.hpp>
#include <mtl/detail/unit_roundoff.hpp>
#include <mtl/detail/wrapping_arithmetic.hpp>
#include <mtl/operation/lu.hpp>
#include <mtl/operation/mult.hpp>
#include <mtl/operation/norms.hpp>

Classes

struct  mtl::detail::expm_impl::theta_row
 theta_m for m = 3, 5, 7, 9, 13 at unit roundoff u = 2^-t, generated by tools/expm_theta.py and rounded toward zero. More...

Namespaces

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

Concepts

concept  mtl::detail::expm_impl::adl::has_exp_sinh

Functions

template<typename R>
std::size_t mtl::detail::expm_impl::table_index ()
 Index into theta_table of the table expm uses for magnitude type R: the first (largest u) whose u = 2^-t does not exceed R's unit roundoff.
template<typename R>
void mtl::detail::expm_impl::split_pow2 (R &x, long &e)
 x = mant * 2^e with mant in [1, 2), for x > 0. Leaves a non-finite x alone.
template<typename R>
R mtl::detail::expm_impl::pow2 (long k)
 2^k in R, by repeated doubling or halving.
template<typename R, typename T>
std::array< long, 5 > mtl::detail::expm_impl::ell_log2 (const mat::dense2D< T > &A, R normA, R u)
 For each degree m: the smallest integer L with 2^L >= |c_{2m+1}| ||(|A|)^(2m+1)||_1 / (||A||_1 u), or a large negative number when that quantity is zero.
int mtl::detail::expm_impl::ell (long L, int m, int s)
template<typename T, typename R>
std::vector< T > mtl::detail::expm_impl::pade_coefficients (int m)
 Coefficients of p_m(x) = sum_j b_j x^j, normalized to b_0 = 1: b_j = b_{j-1} (m - j + 1) / (j (2m - j + 1)).
template<typename T>
void mtl::detail::expm_impl::combine (mat::dense2D< T > &Y, const T &c0, std::initializer_list< std::pair< T, const mat::dense2D< T > * > > terms)
 Y = c0 I + sum_i c[i] M[i].
template<typename T, typename R>
void mtl::detail::expm_impl::scale_by (mat::dense2D< T > &Y, const R &f, int k)
 Y = Y * f, repeated k times (f a power of two, so each step is exact unless it underflows; applying it k times keeps f itself in range).
template<typename T>
T mtl::detail::expm_impl::adl::superdiagonal_exp (const T &a, const T &b, const T &t)
 exp of the 2x2 upper triangular block [a t; 0 b]: its (1,2) entry, t (e^b - e^a) / (b - a) = t e^((a+b)/2) sinh(d) / d, d = (b - a)/2, which does not cancel when a and b are close (Higham 2008, (10.42)).
template<typename T>
T mtl::detail::expm_impl::adl::call_exp (const T &x)
template<typename T>
void mtl::detail::expm_impl::set_triangular_exact (mat::dense2D< T > &X, const std::vector< T > &d, const std::vector< T > &t)
 Al-Mohy & Higham (2009), Code Fragment 2.1: overwrite the diagonal and first superdiagonal of X with exp of those of the upper triangular 2^-j A, where d and t hold 2^-j times A's diagonal and superdiagonal.
template<typename Accumulator = void, FieldMatrix M>
auto mtl::expm (const M &A_in)
 The matrix exponential exp(A) of a square matrix A, as a dense2D.

Variables

constexpr std::array< int, 5 > mtl::detail::expm_impl::degrees {3, 5, 7, 9, 13}
constexpr theta_row mtl::detail::expm_impl::theta_table []
constexpr std::array< double, 5 > mtl::detail::expm_impl::leading_coefficient
 |c_{2m+1}|, the leading coefficient of the backward-error series h_{2m+1}(x) = log(e^-x r_m(x)), rounded up: (m!)^2 / ((2m)!
constexpr int mtl::detail::expm_impl::loop_cap = 1 << 14