MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::detail::expm_multiply_impl Namespace Reference

Classes

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

Functions

template<typename R>
std::size_t table_index ()
template<typename R>
R nth_root (const R &x, int p)
 x^(1/p) for x >= 0, by Newton's method from a power-of-two start.
template<typename R>
std::int64_t ceil_at_least_one (const R &q)
 The smallest integer k >= 1 with k >= q, q >= 0: by doubling and bisection in R, so a type without a conversion to double works too.
template<typename T>
real_of< T >::type mag (const T &x)
template<typename T>
real_of< T >::type inf_norm (const mat::dense2D< T > &Y)
 ||Y||_inf: the largest row sum of |y_ij|.
template<typename M, typename T>
mat::dense2D< T > apply_shifted (const M &A, const T &mu, const T &c, const mat::dense2D< T > &X, bool adjoint)
 Y = c (A - mu I) X (or its adjoint), from A's stored entries.
template<typename T>
T scalar_exp (const T &z)
 exp of a scalar, real or complex, by ADL.

Variables

constexpr theta_row theta_table []
constexpr int m_max = 55
constexpr int p_max = 8
constexpr std::int64_t max_steps = std::int64_t(1) << 50
 The most steps expm_multiply takes: m s stays far inside an int64_t, and a problem that needs more would not finish anyway.

Function Documentation

◆ apply_shifted()

template<typename M, typename T>
mat::dense2D< T > mtl::detail::expm_multiply_impl::apply_shifted ( const M & A,
const T & mu,
const T & c,
const mat::dense2D< T > & X,
bool adjoint )

Y = c (A - mu I) X (or its adjoint), from A's stored entries.

Each entry's coefficient is formed first, c (a - mu) on the diagonal and c a off it, and only then applied to X. Subtracting mu X after the sum would cancel an off-diagonal term that rounding had absorbed into a large diagonal one. Applying c after the products would let a product overflow that c then cannot recover.

◆ ceil_at_least_one()

template<typename R>
std::int64_t mtl::detail::expm_multiply_impl::ceil_at_least_one ( const R & q)

The smallest integer k >= 1 with k >= q, q >= 0: by doubling and bisection in R, so a type without a conversion to double works too.

-1 when k would exceed max_steps (or q is not finite).

◆ inf_norm()

template<typename T>
real_of< T >::type mtl::detail::expm_multiply_impl::inf_norm ( const mat::dense2D< T > & Y)

||Y||_inf: the largest row sum of |y_ij|.

◆ mag()

template<typename T>
real_of< T >::type mtl::detail::expm_multiply_impl::mag ( const T & x)

◆ nth_root()

template<typename R>
R mtl::detail::expm_multiply_impl::nth_root ( const R & x,
int p )

x^(1/p) for x >= 0, by Newton's method from a power-of-two start.

A NaN or infinite x, from a power whose norm overflowed, is returned as it is, so that it fails every theta test (as 0 it would pass them all).

◆ scalar_exp()

template<typename T>
T mtl::detail::expm_multiply_impl::scalar_exp ( const T & z)

exp of a scalar, real or complex, by ADL.

◆ table_index()

template<typename R>
std::size_t mtl::detail::expm_multiply_impl::table_index ( )

Variable Documentation

◆ m_max

int mtl::detail::expm_multiply_impl::m_max = 55
inlineconstexpr

◆ max_steps

std::int64_t mtl::detail::expm_multiply_impl::max_steps = std::int64_t(1) << 50
inlineconstexpr

The most steps expm_multiply takes: m s stays far inside an int64_t, and a problem that needs more would not finish anyway.

◆ p_max

int mtl::detail::expm_multiply_impl::p_max = 8
inlineconstexpr

◆ theta_table

theta_row mtl::detail::expm_multiply_impl::theta_table[]
inlineconstexpr
Initial value:
= {
{ 8, {7.7719945356041192e-03, 1.4497737619256376e-01, 4.0714054712718040e-01, 7.1237215458574532e-01, 1.0289036546654307e+00, 1.3473195087603338e+00, 1.6639660644752414e+00, 1.9782950161375410e+00, 2.2899005304276705e+00, 2.5991054827453262e+00, 2.9060117225237492e+00, 3.2109338699971204e+00, 3.5140423473023503e+00, 3.8155668842632462e+00, 4.1156599790642643e+00, 4.4144853901574193e+00, 4.7121649138841946e+00, 5.0088172571466165e+00, 5.3045368427214825e+00, 5.5994120023154377e+00, 5.8935158996207582e+00, 6.1869157108882282e+00, 6.4796685874810400e+00, 6.7718267225144544e+00, 7.0634353427348096e+00, 7.3545356767401380e+00, 7.6451639677380561e+00, 7.9353533205225428e+00, 8.2251331616723622e+00, 8.5145304207046042e+00, 8.8035692655432207e+00, 9.0922718854906464e+00, 9.3806583503366596e+00, 9.6687471375719820e+00, 9.9565550766628359e+00, 1.0244097712342361e+01, 1.0531389285548315e+01, 1.0818442988831885e+01, 1.1105270971341898e+01, 1.1391884522071681e+01, 1.1678294084009645e+01, 1.1964509388094624e+01, 1.2250539472471891e+01, 1.2536392782202576e+01, 1.2822077189225382e+01, 1.3107600067793753e+01, 1.3392968314052016e+01, 1.3678188403965278e+01, 1.3963266411375725e+01, 1.4248208053137279e+01, 1.4533018705481087e+01, 1.4817703439605674e+01, 1.5102267036230403e+01, 1.5386714014012046e+01, 1.5671048642384378e+01}},
{ 11, {9.7592707910812654e-04, 5.3059166491790523e-02, 2.1446708588946614e-01, 4.4794336515759742e-01, 7.1693543315758257e-01, 1.0028508809454326e+00, 1.2967739630683568e+00, 1.5944377384174611e+00, 1.8936221248564333e+00, 2.1932238642717046e+00, 2.4926253412802897e+00, 2.7915295264065976e+00, 3.0897720811180638e+00, 3.3872913595175826e+00, 3.6840650428796127e+00, 3.9801046566382947e+00, 4.2754329329952343e+00, 4.5700828229722736e+00, 4.8640892451123223e+00, 5.1574889789840022e+00, 5.4503176776802373e+00, 5.7426099743654744e+00, 6.0343984634444245e+00, 6.3257138746765227e+00, 6.6165847883256923e+00, 6.9070378232401275e+00, 7.1970976238823816e+00, 7.4867870389099176e+00, 7.7761271987397418e+00, 8.0651376731114013e+00, 8.3538365725162524e+00, 8.6422406821639903e+00, 8.9303655605635708e+00, 9.2182256507308917e+00, 9.5058343682052335e+00, 9.7932041923557858e+00, 1.0080346741498145e+01, 1.0367272847494743e+01, 1.0653992618892815e+01, 1.0940515501839766e+01, 1.1226850332606913e+01, 1.1513005387425357e+01, 1.1798988426111121e+01, 1.2084806732974906e+01, 1.2370467153032322e+01, 1.2655976125731653e+01, 1.2941339715082364e+01, 1.3226563637592401e+01, 1.3511653287404524e+01, 1.3796613759552324e+01, 1.4081449871011008e+01, 1.4366166180152227e+01, 1.4650767004442264e+01, 1.4935256436797355e+01, 1.5219638360525705e+01}},
{ 24, {1.1920928007687876e-07, 5.9788588938052326e-04, 1.1233864735286706e-02, 5.1166193634450859e-02, 1.3084871645994703e-01, 2.4952893228466974e-01, 4.0145824235104804e-01, 5.8005246276887679e-01, 7.7951133743580303e-01, 9.9518407900044570e-01, 1.2234795424241427e+00, 1.4616615072090335e+00, 1.7076485296087009e+00, 1.9598505859598980e+00, 2.2170443949747201e+00, 2.4782808775219713e+00, 2.7428171126987793e+00, 3.0100663628176343e+00, 3.2795612126359965e+00, 3.5509262147064948e+00, 3.8238574254509654e+00, 4.0981069721915055e+00, 4.3734713118405004e+00, 4.6497822241007567e+00, 4.9268998437559111e+00, 5.2047072280123601e+00, 5.4831060876586344e+00, 5.7620134084477685e+00, 6.0413587581925707e+00, 6.3210821263019605e+00, 6.6011321795011613e+00, 6.8814648452097185e+00, 7.1620421544877590e+00, 7.4428312919365966e+00, 7.7238038115539913e+00, 8.0049349864362860e+00, 8.2862032670021648e+00, 8.5675898276625766e+00, 8.8490781859239487e+00, 9.1306538810900992e+00, 9.4123042022194152e+00, 9.6940179569630107e+00, 9.9757852744706756e+00, 1.0257597436797491e+01, 1.0539446734242167e+01, 1.0821326340852155e+01, 1.1103230206980685e+01, 1.1385152966309136e+01, 1.1667089855178800e+01, 1.1949036642428965e+01, 1.2230989568228123e+01, 1.2512945290624415e+01, 1.2794900838739448e+01, 1.3076853571694221e+01, 1.3358801142493045e+01}},
{ 53, {2.2204460492503126e-16, 2.5809568029717670e-08, 1.3863478661191213e-05, 3.3971688399769617e-04, 2.4008763578872738e-03, 9.0656564075951018e-03, 2.3844555325002733e-02, 4.9912288711153226e-02, 8.9577602032233417e-02, 1.4418297616143777e-01, 2.1423580684517105e-01, 2.9961589138115802e-01, 3.9977753363167950e-01, 5.1391469361242936e-01, 6.4108352330411977e-01, 7.8028742566265741e-01, 9.3053284607865672e-01, 1.0908637192900361e+00, 1.2603810606426387e+00, 1.4382525968043367e+00, 1.6237159502358214e+00, 1.8160778162150855e+00, 2.0147107809446161e+00, 2.2190488693650896e+00, 2.4285825244428261e+00, 2.6428534574594349e+00, 2.8614496339342637e+00, 3.0840005449891619e+00, 3.3101728398902703e+00, 3.5396663487436890e+00, 3.7722104956817506e+00, 4.0075610861180397e+00, 4.2454974425796959e+00, 4.4858198594473677e+00, 4.7283473457935390e+00, 4.9729156261919814e+00, 5.2193753710840580e+00, 5.4675906305245441e+00, 5.7174374475720127e+00, 5.9688026300418482e+00, 6.2215826616898910e+00, 6.4756827360799836e+00, 6.7310158983810240e+00, 6.9875022821306292e+00, 7.2450684295979508e+00, 7.5036466857888637e+00, 7.7631746573779870e+00, 8.0235947289399796e+00, 8.2848536298039157e+00, 8.5469020456849325e+00, 8.8096942699713221e+00, 9.0731878901761434e+00, 9.3373435056120133e+00, 9.6021244728265565e+00, 9.8674966757534008e+00}},
{ 64, {1.0842021724855043e-19, 5.7031627331378612e-10, 1.0916842549409582e-06, 5.0502259779558378e-05, 5.2268933659790255e-04, 2.5463837760920753e-03, 8.0392194980620103e-03, 1.9310204388989012e-02, 3.8593267591278083e-02, 6.7737065912735345e-02, 1.0807726120197289e-01, 1.6043644194312034e-01, 2.2519113685879355e-01, 3.0236317874102947e-01, 3.9171106561217472e-01, 4.9280990765910376e-01, 6.0511620316417070e-01, 7.2801764507879319e-01, 8.6086988719840629e-01, 1.0030227123702387e+00, 1.1538379662055107e+00, 1.3127012967700347e+00, 1.4790293540665946e+00, 1.6522737371364651e+00, 1.8319226641093806e+00, 2.0175010885877098e+00, 2.2085697898362469e+00, 2.4047238156104194e+00, 2.6055905456841675e+00, 2.8108275627199841e+00, 3.0201204579593011e+00, 3.2331806566559953e+00, 3.4497433178707029e+00, 3.6695653418910212e+00, 3.8924235036820045e+00, 4.1181127205857573e+00, 4.3464444556473083e+00, 4.5772452534769297e+00, 4.8103554027646513e+00, 5.0456277179346936e+00, 5.2829264316025633e+00, 5.5221261892163911e+00, 5.7631111373422446e+00, 6.0057740973609013e+00, 6.2500158167897819e+00, 6.4957442909656526e+00, 6.7428741483782746e+00, 6.9913260935038695e+00, 7.2410264015313208e+00, 7.4919064598920357e+00, 7.7439023519896706e+00, 7.9969544789751934e+00, 8.2510072158251564e+00, 8.5060085983569671e+00, 8.7619100381560049e+00}},
{106, {2.4651903288156616e-32, 2.7194799110210360e-16, 6.6631138472177097e-11, 3.4873892401414661e-08, 1.5474993525775630e-06, 1.9900954446047044e-05, 1.2573910042852729e-04, 5.0850835357672613e-04, 1.5252156648747491e-03, 3.7072342587410839e-03, 7.7269024787923633e-03, 1.4342000585067377e-02, 2.4336535132614724e-02, 3.8469654505807610e-02, 5.7437741369910776e-02, 8.1850162442893559e-02, 1.1221680895405090e-01, 1.4894473190705301e-01, 1.9234118897694413e-01, 2.4262081149577988e-01, 2.9991510370610064e-01, 3.6428296916921465e-01, 4.3572136642103504e-01, 5.1417551464388167e-01, 5.9954830659185110e-01, 6.9170875389987263e-01, 7.9049940412773934e-01, 8.9574274293714462e-01, 1.0072466398247633e+00, 1.1248089205569116e+00, 1.2482211604304072e+00, 1.3772717945081014e+00, 1.5117486374519014e+00, 1.6514408988636724e+00, 1.7961407717413900e+00, 1.9456446628093966e+00, 2.0997541247445044e+00, 2.2582765420828284e+00, 2.4210256150635430e+00, 2.5878216789341066e+00, 2.7584918903201960e+00, 2.9328703071200621e+00, 3.1107978839591817e+00, 3.2921224014664854e+00, 3.4766983444339057e+00, 3.6643867412237934e+00, 3.8550549745257610e+00, 4.0485765716736122e+00, 4.2448309811588842e+00, 4.4437033406715205e+00, 4.6450842409181359e+00, 4.8488694885779031e+00, 5.0549598710243187e+00, 5.2632609248416617e+00, 5.4736827096755931e+00}},
{113, {1.9259299443872356e-34, 2.4037033579794548e-17, 1.3221292413259893e-11, 1.0368070295833346e-08, 5.8639269795620564e-07, 8.8648816702500596e-06, 6.2870052127750385e-05, 2.7727335875375628e-04, 8.8966129498740585e-04, 2.2823684658611169e-03, 4.9721164105545551e-03, 9.5756682643408381e-03, 1.6764931201706804e-02, 2.7222650995220685e-02, 4.1605255334150631e-02, 6.0515407462751934e-02, 8.4484249066011111e-02, 1.1396198862269966e-01, 1.4931501955833162e-01, 1.9082776282664082e-01, 2.3870766637734891e-01, 2.9309210748522979e-01, 3.5405625313380784e-01, 4.2162120268296743e-01, 4.9576195462075895e-01, 5.7641490644604132e-01, 6.6348472018721272e-01, 7.5685047389099891e-01, 8.5637107953268710e-01, 9.6188998709278728e-01, 1.0732392186417312e+00, 1.1902427895837415e+00, 1.3127195800849374e+00, 1.4404857206333395e+00, 1.5733565534505209e+00, 1.7111482273736394e+00, 1.8536789787377970e+00, 2.0007701453094175e+00, 2.1522469548409329e+00, 2.3079391245773500e+00, 2.4676813031853957e+00, 2.6313133821650401e+00, 2.7986806998641840e+00, 2.9696341577432062e+00, 3.1440302655022396e+00, 3.3217311290556069e+00, 3.5026043930755999e+00, 3.6865231478913136e+00, 3.8733658088783844e+00, 4.0630159750754968e+00, 4.2553622725797826e+00, 4.4502981872756022e+00, 4.6477218906128579e+00, 4.8475360614485306e+00, 5.0496477063780922e+00}},
{212, {3.0385816786431356e-64, 3.0192292122211267e-32, 1.5391610112630885e-21, 3.6745616767662444e-16, 6.4238395236644821e-13, 9.5648590807332583e-11, 3.4755461771222018e-09, 5.2200599591272877e-08, 4.3444394971614475e-07, 2.3893488847246812e-06, 9.7152097363527828e-06, 3.1476930741592428e-05, 8.5597811205307057e-05, 2.0277020529848338e-04, 4.3000382291070912e-04, 8.3324550404539031e-04, 1.4987437001194742e-03, 2.5330832829533628e-03, 4.0620132724198538e-03, 6.2283088789238513e-03, 9.1889566695488346e-03, 1.3111947052519786e-02, 1.8172922438111687e-02, 2.4551879322457695e-02, 3.2430069819780118e-02, 4.1987199743084000e-02, 5.3398979543498329e-02, 6.6835052256433450e-02, 8.2457298689850397e-02, 1.0041850336454082e-01, 1.2086135387205138e-01, 1.4391774005475388e-01, 1.6970831657322175e-01, 1.9834229203467341e-01, 2.2991740913291811e-01, 2.6452008259285448e-01, 3.0222566467086998e-01, 3.4309881121010771e-01, 3.8719392455781920e-01, 4.3455565286711012e-01, 4.8521942832956272e-01, 5.3921202966171766e-01, 5.9655215666968009e-01, 6.5725100693492222e-01, 7.2131284660698314e-01, 7.8873556897014219e-01, 8.5951123589124467e-01, 9.3362659847720264e-01, 1.0110635942965864e+00, 1.0917998193730833e+00, 1.1758089738612492e+00, 1.2630612808871451e+00, 1.3535238784965937e+00, 1.4471611850184849e+00, 1.5439352384345129e+00}},
{237, {9.0556790788267124e-72, 5.2122008054640541e-36, 4.7720035320848918e-24, 4.8280089712834588e-18, 2.0074498511453646e-14, 5.3258254339565541e-12, 2.9235864194888933e-10, 5.9835201414740096e-09, 6.3348937801097004e-08, 4.2238127590993776e-07, 2.0104504808715778e-06, 7.4275804146930484e-06, 2.2571519005225300e-05, 5.8810485391142821e-05, 1.3544522029754086e-04, 2.8211601410290462e-04, 5.4082826919281011e-04, 9.6736003418644567e-04, 1.6319323052213773e-03, 2.6191324314428295e-03, 4.0271635790913186e-03, 5.9665437043155351e-03, 8.5583992551769763e-03, 1.1932499002678745e-02, 1.6225159643548020e-02, 2.1577133647765701e-02, 2.8131566070372500e-02, 3.6032083886168693e-02, 4.5421060667037418e-02, 5.6438081955150675e-02, 6.9218622694006665e-02, 8.3892937378005294e-02, 1.0058515578277191e-01, 1.1941257177591158e-01, 1.4048510931020586e-01, 1.6390494783460538e-01, 1.8976628864562251e-01, 2.1815524382831367e-01, 2.4914983014781633e-01, 2.8282005134954041e-01, 3.1922805365534646e-01, 3.5842834068968965e-01, 4.0046803555025073e-01, 4.4538717919307952e-01, 4.9321905569288577e-01, 5.4399053623945448e-01, 5.9772243492668076e-01, 6.5442987047477141e-01, 7.1412262899773471e-01, 7.7680552379025825e-01, 8.4247874886592822e-01, 9.1113822363950869e-01, 9.8277592671760727e-01, 1.0573802172527580e+00, 1.1349361427339963e+00}},
}