gauss_kronrod.hpp 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317
  1. // Copyright John Maddock 2017.
  2. // Copyright Nick Thompson 2017.
  3. // Use, modification and distribution are subject to the
  4. // Boost Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_MATH_QUADRATURE_GAUSS_KRONROD_HPP
  7. #define BOOST_MATH_QUADRATURE_GAUSS_KRONROD_HPP
  8. #ifdef _MSC_VER
  9. #pragma once
  10. #pragma warning(push)
  11. #pragma warning(disable: 4127)
  12. #endif
  13. #include <array>
  14. #include <vector>
  15. #include <algorithm>
  16. #include <boost/math/special_functions/legendre.hpp>
  17. #include <boost/math/special_functions/legendre_stieltjes.hpp>
  18. #include <boost/math/quadrature/gauss.hpp>
  19. namespace boost { namespace math{ namespace quadrature{ namespace detail{
  20. #ifndef BOOST_MATH_GAUSS_NO_COMPUTE_ON_DEMAND
  21. template <class Real, unsigned N, unsigned tag>
  22. class gauss_kronrod_detail
  23. {
  24. static legendre_stieltjes<Real> const& get_legendre_stieltjes()
  25. {
  26. static const legendre_stieltjes<Real> data((N - 1) / 2 + 1);
  27. return data;
  28. }
  29. static std::vector<Real> calculate_abscissa()
  30. {
  31. static std::vector<Real> result = boost::math::legendre_p_zeros<Real>((N - 1) / 2);
  32. const legendre_stieltjes<Real> E = get_legendre_stieltjes();
  33. std::vector<Real> ls_zeros = E.zeros();
  34. result.insert(result.end(), ls_zeros.begin(), ls_zeros.end());
  35. std::sort(result.begin(), result.end());
  36. return result;
  37. }
  38. static std::vector<Real> calculate_weights()
  39. {
  40. std::vector<Real> result(abscissa().size(), 0);
  41. unsigned gauss_order = (N - 1) / 2;
  42. unsigned gauss_start = gauss_order & 1 ? 0 : 1;
  43. const legendre_stieltjes<Real>& E = get_legendre_stieltjes();
  44. for (unsigned i = gauss_start; i < abscissa().size(); i += 2)
  45. {
  46. Real x = abscissa()[i];
  47. Real p = boost::math::legendre_p_prime(gauss_order, x);
  48. Real gauss_weight = 2 / ((1 - x * x) * p * p);
  49. result[i] = gauss_weight + static_cast<Real>(2) / (static_cast<Real>(gauss_order + 1) * legendre_p_prime(gauss_order, x) * E(x));
  50. }
  51. for (unsigned i = gauss_start ? 0 : 1; i < abscissa().size(); i += 2)
  52. {
  53. Real x = abscissa()[i];
  54. result[i] = static_cast<Real>(2) / (static_cast<Real>(gauss_order + 1) * legendre_p(gauss_order, x) * E.prime(x));
  55. }
  56. return result;
  57. }
  58. public:
  59. static const std::vector<Real>& abscissa()
  60. {
  61. static std::vector<Real> data = calculate_abscissa();
  62. return data;
  63. }
  64. static const std::vector<Real>& weights()
  65. {
  66. static std::vector<Real> data = calculate_weights();
  67. return data;
  68. }
  69. };
  70. #else
  71. template <class Real, unsigned N, unsigned tag>
  72. class gauss_kronrod_detail;
  73. #endif
  74. #ifndef BOOST_HAS_FLOAT128
  75. template <class T>
  76. class gauss_kronrod_detail<T, 15, 0>
  77. {
  78. using storage_type = typename gauss_constant_category<T>::storage_type;
  79. public:
  80. static std::array<storage_type, 8> const & abscissa()
  81. {
  82. static constexpr std::array<storage_type, 8> data = {
  83. static_cast<storage_type>(0.00000000000000000000000000000000000e+00L),
  84. static_cast<storage_type>(2.07784955007898467600689403773244913e-01L),
  85. static_cast<storage_type>(4.05845151377397166906606412076961463e-01L),
  86. static_cast<storage_type>(5.86087235467691130294144838258729598e-01L),
  87. static_cast<storage_type>(7.41531185599394439863864773280788407e-01L),
  88. static_cast<storage_type>(8.64864423359769072789712788640926201e-01L),
  89. static_cast<storage_type>(9.49107912342758524526189684047851262e-01L),
  90. static_cast<storage_type>(9.91455371120812639206854697526328517e-01L),
  91. };
  92. return data;
  93. }
  94. static std::array<storage_type, 8> const & weights()
  95. {
  96. static constexpr std::array<storage_type, 8> data = {
  97. static_cast<storage_type>(2.09482141084727828012999174891714264e-01L),
  98. static_cast<storage_type>(2.04432940075298892414161999234649085e-01L),
  99. static_cast<storage_type>(1.90350578064785409913256402421013683e-01L),
  100. static_cast<storage_type>(1.69004726639267902826583426598550284e-01L),
  101. static_cast<storage_type>(1.40653259715525918745189590510237920e-01L),
  102. static_cast<storage_type>(1.04790010322250183839876322541518017e-01L),
  103. static_cast<storage_type>(6.30920926299785532907006631892042867e-02L),
  104. static_cast<storage_type>(2.29353220105292249637320080589695920e-02L),
  105. };
  106. return data;
  107. }
  108. };
  109. #else
  110. template <class T>
  111. class gauss_kronrod_detail<T, 15, 0>
  112. {
  113. using storage_type = typename gauss_constant_category<T>::storage_type;
  114. public:
  115. static std::array<storage_type, 8> const & abscissa()
  116. {
  117. static const std::array<storage_type, 8> data = {
  118. static_cast<storage_type>(0.00000000000000000000000000000000000e+00Q),
  119. static_cast<storage_type>(2.07784955007898467600689403773244913e-01Q),
  120. static_cast<storage_type>(4.05845151377397166906606412076961463e-01Q),
  121. static_cast<storage_type>(5.86087235467691130294144838258729598e-01Q),
  122. static_cast<storage_type>(7.41531185599394439863864773280788407e-01Q),
  123. static_cast<storage_type>(8.64864423359769072789712788640926201e-01Q),
  124. static_cast<storage_type>(9.49107912342758524526189684047851262e-01Q),
  125. static_cast<storage_type>(9.91455371120812639206854697526328517e-01Q),
  126. };
  127. return data;
  128. }
  129. static std::array<storage_type, 8> const & weights()
  130. {
  131. static const std::array<storage_type, 8> data = {
  132. static_cast<storage_type>(2.09482141084727828012999174891714264e-01Q),
  133. static_cast<storage_type>(2.04432940075298892414161999234649085e-01Q),
  134. static_cast<storage_type>(1.90350578064785409913256402421013683e-01Q),
  135. static_cast<storage_type>(1.69004726639267902826583426598550284e-01Q),
  136. static_cast<storage_type>(1.40653259715525918745189590510237920e-01Q),
  137. static_cast<storage_type>(1.04790010322250183839876322541518017e-01Q),
  138. static_cast<storage_type>(6.30920926299785532907006631892042867e-02Q),
  139. static_cast<storage_type>(2.29353220105292249637320080589695920e-02Q),
  140. };
  141. return data;
  142. }
  143. };
  144. #endif
  145. template <class T>
  146. class gauss_kronrod_detail<T, 15, 4>
  147. {
  148. public:
  149. static std::array<T, 8> const & abscissa()
  150. {
  151. static std::array<T, 8> data = { // LCOV_EXCL_START
  152. BOOST_MATH_HUGE_CONSTANT(T, 0, 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00),
  153. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.0778495500789846760068940377324491347978440714517064971384573461986693844943520226910343227183698530560857645062738e-01),
  154. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.0584515137739716690660641207696146334738201409937012638704325179466381322612565532831268972774658776528675866604802e-01),
  155. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.8608723546769113029414483825872959843678075060436095130499289319880373607444407464511674498935942098956811555121368e-01),
  156. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.4153118559939443986386477328078840707414764714139026011995535196742987467218051379282683236686324705969251809311201e-01),
  157. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.6486442335976907278971278864092620121097230707408814860145771276706770813259572103585847859604590541475281326027862e-01),
  158. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.4910791234275852452618968404785126240077093767061778354876910391306333035484014080573077002792572414430073966699522e-01),
  159. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9145537112081263920685469752632851664204433837033470129108741357244173934653407235924503509626841760744349505339308e-01),
  160. }; // LCOV_EXCL_STOP
  161. return data;
  162. }
  163. static std::array<T, 8> const & weights()
  164. {
  165. static std::array<T, 8> data = { // LCOV_EXCL_START
  166. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.0948214108472782801299917489171426369776208022370431671299800656137515132325648616816908211675949102392971459688215e-01),
  167. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.0443294007529889241416199923464908471651760418071835742447095312045467698546598879348374292009347554167803659293064e-01),
  168. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.9035057806478540991325640242101368282607807545535835588544088036744058072410212679605964605106377593834568683551139e-01),
  169. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.6900472663926790282658342659855028410624490030294424149734006755695680921619029112936702403855359908156070095656537e-01),
  170. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.4065325971552591874518959051023792039988975724799857556174546893312708093090950408097379122415555910759700350860143e-01),
  171. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.0479001032225018383987632254151801744375665421383061189339065133963746321576289524167571627509311333949422518201492e-01),
  172. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.3092092629978553290700663189204286665071157211550707113605545146983997477964874928199170264504441995865872491871943e-02),
  173. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.2935322010529224963732008058969591993560811275746992267507430254711815787976075946156368168156289483493617134063245e-02),
  174. }; // LCOV_EXCL_STOP
  175. return data;
  176. }
  177. };
  178. #ifndef BOOST_HAS_FLOAT128
  179. template <class T>
  180. class gauss_kronrod_detail<T, 21, 0>
  181. {
  182. using storage_type = typename gauss_constant_category<T>::storage_type;
  183. public:
  184. static std::array<storage_type, 11> const & abscissa()
  185. {
  186. static constexpr std::array<storage_type, 11> data = {
  187. static_cast<storage_type>(0.00000000000000000000000000000000000e+00L),
  188. static_cast<storage_type>(1.48874338981631210884826001129719985e-01L),
  189. static_cast<storage_type>(2.94392862701460198131126603103865566e-01L),
  190. static_cast<storage_type>(4.33395394129247190799265943165784162e-01L),
  191. static_cast<storage_type>(5.62757134668604683339000099272694141e-01L),
  192. static_cast<storage_type>(6.79409568299024406234327365114873576e-01L),
  193. static_cast<storage_type>(7.80817726586416897063717578345042377e-01L),
  194. static_cast<storage_type>(8.65063366688984510732096688423493049e-01L),
  195. static_cast<storage_type>(9.30157491355708226001207180059508346e-01L),
  196. static_cast<storage_type>(9.73906528517171720077964012084452053e-01L),
  197. static_cast<storage_type>(9.95657163025808080735527280689002848e-01L),
  198. };
  199. return data;
  200. }
  201. static std::array<storage_type, 11> const & weights()
  202. {
  203. static constexpr std::array<storage_type, 11> data = {
  204. static_cast<storage_type>(1.49445554002916905664936468389821204e-01L),
  205. static_cast<storage_type>(1.47739104901338491374841515972068046e-01L),
  206. static_cast<storage_type>(1.42775938577060080797094273138717061e-01L),
  207. static_cast<storage_type>(1.34709217311473325928054001771706833e-01L),
  208. static_cast<storage_type>(1.23491976262065851077958109831074160e-01L),
  209. static_cast<storage_type>(1.09387158802297641899210590325804960e-01L),
  210. static_cast<storage_type>(9.31254545836976055350654650833663444e-02L),
  211. static_cast<storage_type>(7.50396748109199527670431409161900094e-02L),
  212. static_cast<storage_type>(5.47558965743519960313813002445801764e-02L),
  213. static_cast<storage_type>(3.25581623079647274788189724593897606e-02L),
  214. static_cast<storage_type>(1.16946388673718742780643960621920484e-02L),
  215. };
  216. return data;
  217. }
  218. };
  219. #else
  220. template <class T>
  221. class gauss_kronrod_detail<T, 21, 0>
  222. {
  223. using storage_type = typename gauss_constant_category<T>::storage_type;
  224. public:
  225. static std::array<storage_type, 11> const & abscissa()
  226. {
  227. static const std::array<storage_type, 11> data = {
  228. static_cast<storage_type>(0.00000000000000000000000000000000000e+00Q),
  229. static_cast<storage_type>(1.48874338981631210884826001129719985e-01Q),
  230. static_cast<storage_type>(2.94392862701460198131126603103865566e-01Q),
  231. static_cast<storage_type>(4.33395394129247190799265943165784162e-01Q),
  232. static_cast<storage_type>(5.62757134668604683339000099272694141e-01Q),
  233. static_cast<storage_type>(6.79409568299024406234327365114873576e-01Q),
  234. static_cast<storage_type>(7.80817726586416897063717578345042377e-01Q),
  235. static_cast<storage_type>(8.65063366688984510732096688423493049e-01Q),
  236. static_cast<storage_type>(9.30157491355708226001207180059508346e-01Q),
  237. static_cast<storage_type>(9.73906528517171720077964012084452053e-01Q),
  238. static_cast<storage_type>(9.95657163025808080735527280689002848e-01Q),
  239. };
  240. return data;
  241. }
  242. static std::array<storage_type, 11> const & weights()
  243. {
  244. static const std::array<storage_type, 11> data = {
  245. static_cast<storage_type>(1.49445554002916905664936468389821204e-01Q),
  246. static_cast<storage_type>(1.47739104901338491374841515972068046e-01Q),
  247. static_cast<storage_type>(1.42775938577060080797094273138717061e-01Q),
  248. static_cast<storage_type>(1.34709217311473325928054001771706833e-01Q),
  249. static_cast<storage_type>(1.23491976262065851077958109831074160e-01Q),
  250. static_cast<storage_type>(1.09387158802297641899210590325804960e-01Q),
  251. static_cast<storage_type>(9.31254545836976055350654650833663444e-02Q),
  252. static_cast<storage_type>(7.50396748109199527670431409161900094e-02Q),
  253. static_cast<storage_type>(5.47558965743519960313813002445801764e-02Q),
  254. static_cast<storage_type>(3.25581623079647274788189724593897606e-02Q),
  255. static_cast<storage_type>(1.16946388673718742780643960621920484e-02Q),
  256. };
  257. return data;
  258. }
  259. };
  260. #endif
  261. template <class T>
  262. class gauss_kronrod_detail<T, 21, 4>
  263. {
  264. public:
  265. static std::array<T, 11> const & abscissa()
  266. {
  267. static std::array<T, 11> data = { // LCOV_EXCL_START
  268. BOOST_MATH_HUGE_CONSTANT(T, 0, 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00),
  269. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.4887433898163121088482600112971998461756485942069169570798925351590361735566852137117762979946369123003116080525534e-01),
  270. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.9439286270146019813112660310386556616268662515695791864888229172724611166332737888445523178268237359119185139299872e-01),
  271. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.3339539412924719079926594316578416220007183765624649650270151314376698907770350122510275795011772122368293504099894e-01),
  272. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.6275713466860468333900009927269414084301388194196695886034621458779266353216327549712087854169992422106448211158815e-01),
  273. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.7940956829902440623432736511487357576929471183480946766481718895255857539507492461507857357048037949983390204739932e-01),
  274. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.8081772658641689706371757834504237716340752029815717974694859999505607982761420654526977234238996241110129779403362e-01),
  275. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.6506336668898451073209668842349304852754301496533045252195973184537475513805556135679072894604577069440463108641177e-01),
  276. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.3015749135570822600120718005950834622516790998193924230349406866828415983091673055011194572851007884702013619684320e-01),
  277. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.7390652851717172007796401208445205342826994669238211923121206669659520323463615962572356495626855625823304251877421e-01),
  278. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9565716302580808073552728068900284792126058721947892436337916111757023046774867357152325996912076724298149077812671e-01),
  279. }; // LCOV_EXCL_STOP
  280. return data;
  281. }
  282. static std::array<T, 11> const & weights()
  283. {
  284. static std::array<T, 11> data = { // LCOV_EXCL_START
  285. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.4944555400291690566493646838982120374523631668747280383560851873698964478511841925721030705689540264726493367634340e-01),
  286. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.4773910490133849137484151597206804552373162548520660451819195439885993016735696405732703959182882254268727823258502e-01),
  287. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.4277593857706008079709427313871706088597905653190555560741004743970770449909340027811131706283756428281146832304737e-01),
  288. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.3470921731147332592805400177170683276099191300855971406636668491320291400121282036676953159488271772384389604997640e-01),
  289. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.2349197626206585107795810983107415951230034952864832764467994120974054238975454689681538622363738230836484113389878e-01),
  290. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.0938715880229764189921059032580496027181329983434522007819675829826550372891432168683899432674553842507906611591517e-01),
  291. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.3125454583697605535065465083366344390018828880760031970085038760177735672200775237414123061615827474831165614953012e-02),
  292. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.5039674810919952767043140916190009395219382000910088173697048048430404342858495178813808730646554086856929327903059e-02),
  293. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.4755896574351996031381300244580176373721114058333557524432615804784098927818975325116301569003298086458722055550981e-02),
  294. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.2558162307964727478818972459389760617388939845662609571537504232714121820165498692381607605384626494546068817765276e-02),
  295. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.1694638867371874278064396062192048396217332481931888927598147525622222058064992651806736704969967250888097490233242e-02),
  296. }; // LCOV_EXCL_STOP
  297. return data;
  298. }
  299. };
  300. #ifndef BOOST_HAS_FLOAT128
  301. template <class T>
  302. class gauss_kronrod_detail<T, 31, 0>
  303. {
  304. using storage_type = typename gauss_constant_category<T>::storage_type;
  305. public:
  306. static std::array<storage_type, 16> const & abscissa()
  307. {
  308. static constexpr std::array<storage_type, 16> data = {
  309. static_cast<storage_type>(0.00000000000000000000000000000000000e+00L),
  310. static_cast<storage_type>(1.01142066918717499027074231447392339e-01L),
  311. static_cast<storage_type>(2.01194093997434522300628303394596208e-01L),
  312. static_cast<storage_type>(2.99180007153168812166780024266388963e-01L),
  313. static_cast<storage_type>(3.94151347077563369897207370981045468e-01L),
  314. static_cast<storage_type>(4.85081863640239680693655740232350613e-01L),
  315. static_cast<storage_type>(5.70972172608538847537226737253910641e-01L),
  316. static_cast<storage_type>(6.50996741297416970533735895313274693e-01L),
  317. static_cast<storage_type>(7.24417731360170047416186054613938010e-01L),
  318. static_cast<storage_type>(7.90418501442465932967649294817947347e-01L),
  319. static_cast<storage_type>(8.48206583410427216200648320774216851e-01L),
  320. static_cast<storage_type>(8.97264532344081900882509656454495883e-01L),
  321. static_cast<storage_type>(9.37273392400705904307758947710209471e-01L),
  322. static_cast<storage_type>(9.67739075679139134257347978784337225e-01L),
  323. static_cast<storage_type>(9.87992518020485428489565718586612581e-01L),
  324. static_cast<storage_type>(9.98002298693397060285172840152271209e-01L),
  325. };
  326. return data;
  327. }
  328. static std::array<storage_type, 16> const & weights()
  329. {
  330. static constexpr std::array<storage_type, 16> data = {
  331. static_cast<storage_type>(1.01330007014791549017374792767492547e-01L),
  332. static_cast<storage_type>(1.00769845523875595044946662617569722e-01L),
  333. static_cast<storage_type>(9.91735987217919593323931734846031311e-02L),
  334. static_cast<storage_type>(9.66427269836236785051799076275893351e-02L),
  335. static_cast<storage_type>(9.31265981708253212254868727473457186e-02L),
  336. static_cast<storage_type>(8.85644430562117706472754436937743032e-02L),
  337. static_cast<storage_type>(8.30805028231330210382892472861037896e-02L),
  338. static_cast<storage_type>(7.68496807577203788944327774826590067e-02L),
  339. static_cast<storage_type>(6.98541213187282587095200770991474758e-02L),
  340. static_cast<storage_type>(6.20095678006706402851392309608029322e-02L),
  341. static_cast<storage_type>(5.34815246909280872653431472394302968e-02L),
  342. static_cast<storage_type>(4.45897513247648766082272993732796902e-02L),
  343. static_cast<storage_type>(3.53463607913758462220379484783600481e-02L),
  344. static_cast<storage_type>(2.54608473267153201868740010196533594e-02L),
  345. static_cast<storage_type>(1.50079473293161225383747630758072681e-02L),
  346. static_cast<storage_type>(5.37747987292334898779205143012764982e-03L),
  347. };
  348. return data;
  349. }
  350. };
  351. #else
  352. template <class T>
  353. class gauss_kronrod_detail<T, 31, 0>
  354. {
  355. using storage_type = typename gauss_constant_category<T>::storage_type;
  356. public:
  357. static std::array<storage_type, 16> const & abscissa()
  358. {
  359. static const std::array<storage_type, 16> data = {
  360. static_cast<storage_type>(0.00000000000000000000000000000000000e+00Q),
  361. static_cast<storage_type>(1.01142066918717499027074231447392339e-01Q),
  362. static_cast<storage_type>(2.01194093997434522300628303394596208e-01Q),
  363. static_cast<storage_type>(2.99180007153168812166780024266388963e-01Q),
  364. static_cast<storage_type>(3.94151347077563369897207370981045468e-01Q),
  365. static_cast<storage_type>(4.85081863640239680693655740232350613e-01Q),
  366. static_cast<storage_type>(5.70972172608538847537226737253910641e-01Q),
  367. static_cast<storage_type>(6.50996741297416970533735895313274693e-01Q),
  368. static_cast<storage_type>(7.24417731360170047416186054613938010e-01Q),
  369. static_cast<storage_type>(7.90418501442465932967649294817947347e-01Q),
  370. static_cast<storage_type>(8.48206583410427216200648320774216851e-01Q),
  371. static_cast<storage_type>(8.97264532344081900882509656454495883e-01Q),
  372. static_cast<storage_type>(9.37273392400705904307758947710209471e-01Q),
  373. static_cast<storage_type>(9.67739075679139134257347978784337225e-01Q),
  374. static_cast<storage_type>(9.87992518020485428489565718586612581e-01Q),
  375. static_cast<storage_type>(9.98002298693397060285172840152271209e-01Q),
  376. };
  377. return data;
  378. }
  379. static std::array<storage_type, 16> const & weights()
  380. {
  381. static const std::array<storage_type, 16> data = {
  382. static_cast<storage_type>(1.01330007014791549017374792767492547e-01Q),
  383. static_cast<storage_type>(1.00769845523875595044946662617569722e-01Q),
  384. static_cast<storage_type>(9.91735987217919593323931734846031311e-02Q),
  385. static_cast<storage_type>(9.66427269836236785051799076275893351e-02Q),
  386. static_cast<storage_type>(9.31265981708253212254868727473457186e-02Q),
  387. static_cast<storage_type>(8.85644430562117706472754436937743032e-02Q),
  388. static_cast<storage_type>(8.30805028231330210382892472861037896e-02Q),
  389. static_cast<storage_type>(7.68496807577203788944327774826590067e-02Q),
  390. static_cast<storage_type>(6.98541213187282587095200770991474758e-02Q),
  391. static_cast<storage_type>(6.20095678006706402851392309608029322e-02Q),
  392. static_cast<storage_type>(5.34815246909280872653431472394302968e-02Q),
  393. static_cast<storage_type>(4.45897513247648766082272993732796902e-02Q),
  394. static_cast<storage_type>(3.53463607913758462220379484783600481e-02Q),
  395. static_cast<storage_type>(2.54608473267153201868740010196533594e-02Q),
  396. static_cast<storage_type>(1.50079473293161225383747630758072681e-02Q),
  397. static_cast<storage_type>(5.37747987292334898779205143012764982e-03Q),
  398. };
  399. return data;
  400. }
  401. };
  402. #endif
  403. template <class T>
  404. class gauss_kronrod_detail<T, 31, 4>
  405. {
  406. public:
  407. static std::array<T, 16> const & abscissa()
  408. {
  409. static std::array<T, 16> data = { // LCOV_EXCL_START
  410. BOOST_MATH_HUGE_CONSTANT(T, 0, 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00),
  411. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.0114206691871749902707423144739233878745105740164180495800189504151097862454083050931321451540380998341273193681967e-01),
  412. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.0119409399743452230062830339459620781283645446263767961594972460994823900302018760183625806752105908967902257386509e-01),
  413. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.9918000715316881216678002426638896266160338274382080184125545738918081102513884467602322020157243563662094470221235e-01),
  414. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.9415134707756336989720737098104546836275277615869825503116534395160895778696141797549711416165976202589352169635648e-01),
  415. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.8508186364023968069365574023235061286633893089407312129367943604080239955167155974371848690848595275551258416303565e-01),
  416. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.7097217260853884753722673725391064123838639628274960485326541705419537986975857948341462856982614477912646497026257e-01),
  417. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.5099674129741697053373589531327469254694822609259966708966160576093305841043840794460394747228060367236079289132544e-01),
  418. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.2441773136017004741618605461393800963089929458410256355142342070412378167792521899610109760313432626923598549381925e-01),
  419. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.9041850144246593296764929481794734686214051995697617332365280643308302974631807059994738664225445530963711137343440e-01),
  420. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.4820658341042721620064832077421685136625617473699263409572755876067507517414548519760771975082148085090373835713340e-01),
  421. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.9726453234408190088250965645449588283177871149442786763972687601078537721473771221195399661919716123038835639691946e-01),
  422. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.3727339240070590430775894771020947124399627351530445790136307635020297379704552795054758617426808659746824044603157e-01),
  423. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.6773907567913913425734797878433722528335733730013163797468062226335804249452174804319385048203118506304424717089291e-01),
  424. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.8799251802048542848956571858661258114697281712376148999999751558738843736901942471272205036831914497667516843990079e-01),
  425. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9800229869339706028517284015227120907340644231555723034839427970683348682837134566648979907760125278631896777136104e-01),
  426. }; // LCOV_EXCL_STOP
  427. return data;
  428. }
  429. static std::array<T, 16> const & weights()
  430. {
  431. static std::array<T, 16> data = { // LCOV_EXCL_START
  432. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.0133000701479154901737479276749254677092627259659629246734858372174107615774696665932418050683956749891773195816338e-01),
  433. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.0076984552387559504494666261756972191634838013536373069278929029488122760822761077475060185965408326901925180106227e-01),
  434. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9173598721791959332393173484603131059567260816713281734860095693651563064308745717056680128223790739026832596087552e-02),
  435. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.6642726983623678505179907627589335136656568630495198973407668882934392359962841826511402504664592185391687490319950e-02),
  436. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.3126598170825321225486872747345718561927881321317330560285879189052002874531855060114908990458716740695847509343865e-02),
  437. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.8564443056211770647275443693774303212266732690655967817996052574877144544749814260718837576325109922207832119243346e-02),
  438. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.3080502823133021038289247286103789601554188253368717607281604875233630643885056057630789228337088859687986285569521e-02),
  439. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.6849680757720378894432777482659006722109101167947000584089097112470821092034084418224731527690291913686588446455555e-02),
  440. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.9854121318728258709520077099147475786045435140671549698798093177992675624987998849748628778570667518643649536771245e-02),
  441. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.2009567800670640285139230960802932190400004210329723569147829395618376206272317333030584268303808639229575334680414e-02),
  442. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.3481524690928087265343147239430296771554760947116739813222888752727413616259625439714812475198987513183153639571249e-02),
  443. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.4589751324764876608227299373279690223256649667921096570980823211805450700059906366455036418897149593261561551176267e-02),
  444. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.5346360791375846222037948478360048122630678992420820868148023340902501837247680978434662724296810081131106317333086e-02),
  445. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.5460847326715320186874001019653359397271745046864640508377984982400903447009185267605205778819712848080691366407461e-02),
  446. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.5007947329316122538374763075807268094639436437387634979291759700896494746154334398961710227490402528151677469993935e-02),
  447. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.3774798729233489877920514301276498183080402431284197876486169536848635554354599213793172596490038991436925569025913e-03),
  448. }; // LCOV_EXCL_STOP
  449. return data;
  450. }
  451. };
  452. #ifndef BOOST_HAS_FLOAT128
  453. template <class T>
  454. class gauss_kronrod_detail<T, 41, 0>
  455. {
  456. using storage_type = typename gauss_constant_category<T>::storage_type;
  457. public:
  458. static std::array<storage_type, 21> const & abscissa()
  459. {
  460. static constexpr std::array<storage_type, 21> data = {
  461. static_cast<storage_type>(0.00000000000000000000000000000000000e+00L),
  462. static_cast<storage_type>(7.65265211334973337546404093988382110e-02L),
  463. static_cast<storage_type>(1.52605465240922675505220241022677528e-01L),
  464. static_cast<storage_type>(2.27785851141645078080496195368574625e-01L),
  465. static_cast<storage_type>(3.01627868114913004320555356858592261e-01L),
  466. static_cast<storage_type>(3.73706088715419560672548177024927237e-01L),
  467. static_cast<storage_type>(4.43593175238725103199992213492640108e-01L),
  468. static_cast<storage_type>(5.10867001950827098004364050955250998e-01L),
  469. static_cast<storage_type>(5.75140446819710315342946036586425133e-01L),
  470. static_cast<storage_type>(6.36053680726515025452836696226285937e-01L),
  471. static_cast<storage_type>(6.93237656334751384805490711845931533e-01L),
  472. static_cast<storage_type>(7.46331906460150792614305070355641590e-01L),
  473. static_cast<storage_type>(7.95041428837551198350638833272787943e-01L),
  474. static_cast<storage_type>(8.39116971822218823394529061701520685e-01L),
  475. static_cast<storage_type>(8.78276811252281976077442995113078467e-01L),
  476. static_cast<storage_type>(9.12234428251325905867752441203298113e-01L),
  477. static_cast<storage_type>(9.40822633831754753519982722212443380e-01L),
  478. static_cast<storage_type>(9.63971927277913791267666131197277222e-01L),
  479. static_cast<storage_type>(9.81507877450250259193342994720216945e-01L),
  480. static_cast<storage_type>(9.93128599185094924786122388471320278e-01L),
  481. static_cast<storage_type>(9.98859031588277663838315576545863010e-01L),
  482. };
  483. return data;
  484. }
  485. static std::array<storage_type, 21> const & weights()
  486. {
  487. static constexpr std::array<storage_type, 21> data = {
  488. static_cast<storage_type>(7.66007119179996564450499015301017408e-02L),
  489. static_cast<storage_type>(7.63778676720807367055028350380610018e-02L),
  490. static_cast<storage_type>(7.57044976845566746595427753766165583e-02L),
  491. static_cast<storage_type>(7.45828754004991889865814183624875286e-02L),
  492. static_cast<storage_type>(7.30306903327866674951894176589131128e-02L),
  493. static_cast<storage_type>(7.10544235534440683057903617232101674e-02L),
  494. static_cast<storage_type>(6.86486729285216193456234118853678017e-02L),
  495. static_cast<storage_type>(6.58345971336184221115635569693979431e-02L),
  496. static_cast<storage_type>(6.26532375547811680258701221742549806e-02L),
  497. static_cast<storage_type>(5.91114008806395723749672206485942171e-02L),
  498. static_cast<storage_type>(5.51951053482859947448323724197773292e-02L),
  499. static_cast<storage_type>(5.09445739237286919327076700503449487e-02L),
  500. static_cast<storage_type>(4.64348218674976747202318809261075168e-02L),
  501. static_cast<storage_type>(4.16688733279736862637883059368947380e-02L),
  502. static_cast<storage_type>(3.66001697582007980305572407072110085e-02L),
  503. static_cast<storage_type>(3.12873067770327989585431193238007379e-02L),
  504. static_cast<storage_type>(2.58821336049511588345050670961531430e-02L),
  505. static_cast<storage_type>(2.03883734612665235980102314327547051e-02L),
  506. static_cast<storage_type>(1.46261692569712529837879603088683562e-02L),
  507. static_cast<storage_type>(8.60026985564294219866178795010234725e-03L),
  508. static_cast<storage_type>(3.07358371852053150121829324603098749e-03L),
  509. };
  510. return data;
  511. }
  512. };
  513. #else
  514. template <class T>
  515. class gauss_kronrod_detail<T, 41, 0>
  516. {
  517. using storage_type = typename gauss_constant_category<T>::storage_type;
  518. public:
  519. static std::array<storage_type, 21> const & abscissa()
  520. {
  521. static const std::array<storage_type, 21> data = {
  522. static_cast<storage_type>(0.00000000000000000000000000000000000e+00Q),
  523. static_cast<storage_type>(7.65265211334973337546404093988382110e-02Q),
  524. static_cast<storage_type>(1.52605465240922675505220241022677528e-01Q),
  525. static_cast<storage_type>(2.27785851141645078080496195368574625e-01Q),
  526. static_cast<storage_type>(3.01627868114913004320555356858592261e-01Q),
  527. static_cast<storage_type>(3.73706088715419560672548177024927237e-01Q),
  528. static_cast<storage_type>(4.43593175238725103199992213492640108e-01Q),
  529. static_cast<storage_type>(5.10867001950827098004364050955250998e-01Q),
  530. static_cast<storage_type>(5.75140446819710315342946036586425133e-01Q),
  531. static_cast<storage_type>(6.36053680726515025452836696226285937e-01Q),
  532. static_cast<storage_type>(6.93237656334751384805490711845931533e-01Q),
  533. static_cast<storage_type>(7.46331906460150792614305070355641590e-01Q),
  534. static_cast<storage_type>(7.95041428837551198350638833272787943e-01Q),
  535. static_cast<storage_type>(8.39116971822218823394529061701520685e-01Q),
  536. static_cast<storage_type>(8.78276811252281976077442995113078467e-01Q),
  537. static_cast<storage_type>(9.12234428251325905867752441203298113e-01Q),
  538. static_cast<storage_type>(9.40822633831754753519982722212443380e-01Q),
  539. static_cast<storage_type>(9.63971927277913791267666131197277222e-01Q),
  540. static_cast<storage_type>(9.81507877450250259193342994720216945e-01Q),
  541. static_cast<storage_type>(9.93128599185094924786122388471320278e-01Q),
  542. static_cast<storage_type>(9.98859031588277663838315576545863010e-01Q),
  543. };
  544. return data;
  545. }
  546. static std::array<storage_type, 21> const & weights()
  547. {
  548. static const std::array<storage_type, 21> data = {
  549. static_cast<storage_type>(7.66007119179996564450499015301017408e-02Q),
  550. static_cast<storage_type>(7.63778676720807367055028350380610018e-02Q),
  551. static_cast<storage_type>(7.57044976845566746595427753766165583e-02Q),
  552. static_cast<storage_type>(7.45828754004991889865814183624875286e-02Q),
  553. static_cast<storage_type>(7.30306903327866674951894176589131128e-02Q),
  554. static_cast<storage_type>(7.10544235534440683057903617232101674e-02Q),
  555. static_cast<storage_type>(6.86486729285216193456234118853678017e-02Q),
  556. static_cast<storage_type>(6.58345971336184221115635569693979431e-02Q),
  557. static_cast<storage_type>(6.26532375547811680258701221742549806e-02Q),
  558. static_cast<storage_type>(5.91114008806395723749672206485942171e-02Q),
  559. static_cast<storage_type>(5.51951053482859947448323724197773292e-02Q),
  560. static_cast<storage_type>(5.09445739237286919327076700503449487e-02Q),
  561. static_cast<storage_type>(4.64348218674976747202318809261075168e-02Q),
  562. static_cast<storage_type>(4.16688733279736862637883059368947380e-02Q),
  563. static_cast<storage_type>(3.66001697582007980305572407072110085e-02Q),
  564. static_cast<storage_type>(3.12873067770327989585431193238007379e-02Q),
  565. static_cast<storage_type>(2.58821336049511588345050670961531430e-02Q),
  566. static_cast<storage_type>(2.03883734612665235980102314327547051e-02Q),
  567. static_cast<storage_type>(1.46261692569712529837879603088683562e-02Q),
  568. static_cast<storage_type>(8.60026985564294219866178795010234725e-03Q),
  569. static_cast<storage_type>(3.07358371852053150121829324603098749e-03Q),
  570. };
  571. return data;
  572. }
  573. };
  574. #endif
  575. template <class T>
  576. class gauss_kronrod_detail<T, 41, 4>
  577. {
  578. public:
  579. static std::array<T, 21> const & abscissa()
  580. {
  581. static std::array<T, 21> data = { // LCOV_EXCL_START
  582. BOOST_MATH_HUGE_CONSTANT(T, 0, 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00),
  583. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.6526521133497333754640409398838211004796266813497500804795244384256342048336978241545114181556215606998505646364133e-02),
  584. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.5260546524092267550522024102267752791167622481841730660174156703809133685751696356987995886397049724808931527012542e-01),
  585. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.2778585114164507808049619536857462474308893768292747231463573920717134186355582779495212519096870803177373131560430e-01),
  586. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.0162786811491300432055535685859226061539650501373092456926374427956957435978384116066498234762220215751079886015902e-01),
  587. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.7370608871541956067254817702492723739574632170568271182794861351564576437305952789589568363453337894476772208852815e-01),
  588. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.4359317523872510319999221349264010784010101082300309613315028346299543059315258601993479156987847429893626854030516e-01),
  589. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.1086700195082709800436405095525099842549132920242683347234861989473497039076572814403168305086777919832943068843526e-01),
  590. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.7514044681971031534294603658642513281381264014771682537415885495717468074720062012357788489049470208285175093670561e-01),
  591. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.3605368072651502545283669622628593674338911679936846393944662254654126258543013255870319549576130658211710937772596e-01),
  592. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.9323765633475138480549071184593153338642585141021417904687378454301191710739219011546672416325022748282227809465165e-01),
  593. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.4633190646015079261430507035564159031073067956917644413954590606853535503815506468110411362064752061238490065167656e-01),
  594. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.9504142883755119835063883327278794295938959911578029703855163894322697871710382866701777890251824617748545658564370e-01),
  595. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.3911697182221882339452906170152068532962936506563737325249272553286109399932480991922934056595764922060422035306914e-01),
  596. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.7827681125228197607744299511307846671124526828251164853898086998248145904743220740840261624245683876748360309079747e-01),
  597. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.1223442825132590586775244120329811304918479742369177479588221915807089120871907893644472619292138737876039175464603e-01),
  598. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.4082263383175475351998272221244338027429557377965291059536839973186796006557571220888218676776618448841584569497535e-01),
  599. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.6397192727791379126766613119727722191206032780618885606353759389204158078438305698001812525596471563131043491596423e-01),
  600. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.8150787745025025919334299472021694456725093981023759869077533318793098857465723460898060491887511355706497739384103e-01),
  601. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9312859918509492478612238847132027822264713090165589614818413121798471762775378083944940249657220927472894034724419e-01),
  602. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9885903158827766383831557654586300999957020432629666866666860339324411793311982967839129772854179884971700274369367e-01),
  603. }; // LCOV_EXCL_STOP
  604. return data;
  605. }
  606. static std::array<T, 21> const & weights()
  607. {
  608. static std::array<T, 21> data = { // LCOV_EXCL_START
  609. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.6600711917999656445049901530101740827932500628670118055485349620314721456712029449597396569857880493210849110825276e-02),
  610. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.6377867672080736705502835038061001800801036764945996714946431116936745542061941050008345047482501253320401746334511e-02),
  611. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.5704497684556674659542775376616558263363155900414326194855223272348838596099414841886740468379707283366777797425290e-02),
  612. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.4582875400499188986581418362487528616116493572092273080047040726969899567887364227664202642942357104526915332274625e-02),
  613. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.3030690332786667495189417658913112760626845234552742380174250771849743831660040966804802312464527721645765620253776e-02),
  614. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.1054423553444068305790361723210167412912159322210143921628270586407381879789525901086146473278095159807542174985045e-02),
  615. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.8648672928521619345623411885367801715489704958239860400434264173923806029589970941711224257967651039544669425313433e-02),
  616. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.5834597133618422111563556969397943147223506343381443709751749639944420314384296347503523810096842402960802728781816e-02),
  617. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.2653237554781168025870122174254980585819744698897886186553324157100424088919284503451596742588386343548162830898103e-02),
  618. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.9111400880639572374967220648594217136419365977042191748388047204015262840407696611508732839851952697839735487615776e-02),
  619. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.5195105348285994744832372419777329194753456228153116909812131213177827707884692917845453999535518818940813085110223e-02),
  620. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.0944573923728691932707670050344948664836365809262579747517140086119113476866735641054822574173198900379392130050979e-02),
  621. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.6434821867497674720231880926107516842127071007077929289994127933243222585938804392953931185146446072587020288747981e-02),
  622. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.1668873327973686263788305936894738043960843153010324860966353235271889596379726462208702081068715463576895020003842e-02),
  623. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.6600169758200798030557240707211008487453496747498001651070009441973280061489266074044986901436324295513243878212345e-02),
  624. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.1287306777032798958543119323800737887769280362813337359554598005322423266047996771926031069705049476071896145456496e-02),
  625. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.5882133604951158834505067096153142999479118048674944526997797755374306421629440393392427198869345793286369198147609e-02),
  626. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.0388373461266523598010231432754705122838627940185929365371868214433006532030353671253640300679157504987977281782909e-02),
  627. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.4626169256971252983787960308868356163881050162249770342103474631076960029748751959380482484308382288261238476948520e-02),
  628. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.6002698556429421986617879501023472521289227667077976622450602031426535362696437838448828009554532025301579670206091e-03),
  629. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.0735837185205315012182932460309874880335046882543449198461628212114333665590378156706265241414469306987988292234740e-03),
  630. }; // LCOV_EXCL_STOP
  631. return data;
  632. }
  633. };
  634. #ifndef BOOST_HAS_FLOAT128
  635. template <class T>
  636. class gauss_kronrod_detail<T, 51, 0>
  637. {
  638. using storage_type = typename gauss_constant_category<T>::storage_type;
  639. public:
  640. static std::array<storage_type, 26> const & abscissa()
  641. {
  642. static constexpr std::array<storage_type, 26> data = {
  643. static_cast<storage_type>(0.00000000000000000000000000000000000e+00L),
  644. static_cast<storage_type>(6.15444830056850788865463923667966313e-02L),
  645. static_cast<storage_type>(1.22864692610710396387359818808036806e-01L),
  646. static_cast<storage_type>(1.83718939421048892015969888759528416e-01L),
  647. static_cast<storage_type>(2.43866883720988432045190362797451586e-01L),
  648. static_cast<storage_type>(3.03089538931107830167478909980339329e-01L),
  649. static_cast<storage_type>(3.61172305809387837735821730127640667e-01L),
  650. static_cast<storage_type>(4.17885382193037748851814394594572487e-01L),
  651. static_cast<storage_type>(4.73002731445714960522182115009192041e-01L),
  652. static_cast<storage_type>(5.26325284334719182599623778158010178e-01L),
  653. static_cast<storage_type>(5.77662930241222967723689841612654067e-01L),
  654. static_cast<storage_type>(6.26810099010317412788122681624517881e-01L),
  655. static_cast<storage_type>(6.73566368473468364485120633247622176e-01L),
  656. static_cast<storage_type>(7.17766406813084388186654079773297781e-01L),
  657. static_cast<storage_type>(7.59259263037357630577282865204360976e-01L),
  658. static_cast<storage_type>(7.97873797998500059410410904994306569e-01L),
  659. static_cast<storage_type>(8.33442628760834001421021108693569569e-01L),
  660. static_cast<storage_type>(8.65847065293275595448996969588340088e-01L),
  661. static_cast<storage_type>(8.94991997878275368851042006782804954e-01L),
  662. static_cast<storage_type>(9.20747115281701561746346084546330632e-01L),
  663. static_cast<storage_type>(9.42974571228974339414011169658470532e-01L),
  664. static_cast<storage_type>(9.61614986425842512418130033660167242e-01L),
  665. static_cast<storage_type>(9.76663921459517511498315386479594068e-01L),
  666. static_cast<storage_type>(9.88035794534077247637331014577406227e-01L),
  667. static_cast<storage_type>(9.95556969790498097908784946893901617e-01L),
  668. static_cast<storage_type>(9.99262104992609834193457486540340594e-01L),
  669. };
  670. return data;
  671. }
  672. static std::array<storage_type, 26> const & weights()
  673. {
  674. static constexpr std::array<storage_type, 26> data = {
  675. static_cast<storage_type>(6.15808180678329350787598242400645532e-02L),
  676. static_cast<storage_type>(6.14711898714253166615441319652641776e-02L),
  677. static_cast<storage_type>(6.11285097170530483058590304162927119e-02L),
  678. static_cast<storage_type>(6.05394553760458629453602675175654272e-02L),
  679. static_cast<storage_type>(5.97203403241740599790992919325618538e-02L),
  680. static_cast<storage_type>(5.86896800223942079619741758567877641e-02L),
  681. static_cast<storage_type>(5.74371163615678328535826939395064720e-02L),
  682. static_cast<storage_type>(5.59508112204123173082406863827473468e-02L),
  683. static_cast<storage_type>(5.42511298885454901445433704598756068e-02L),
  684. static_cast<storage_type>(5.23628858064074758643667121378727149e-02L),
  685. static_cast<storage_type>(5.02776790807156719633252594334400844e-02L),
  686. static_cast<storage_type>(4.79825371388367139063922557569147550e-02L),
  687. static_cast<storage_type>(4.55029130499217889098705847526603930e-02L),
  688. static_cast<storage_type>(4.28728450201700494768957924394951611e-02L),
  689. static_cast<storage_type>(4.00838255040323820748392844670756464e-02L),
  690. static_cast<storage_type>(3.71162714834155435603306253676198760e-02L),
  691. static_cast<storage_type>(3.40021302743293378367487952295512032e-02L),
  692. static_cast<storage_type>(3.07923001673874888911090202152285856e-02L),
  693. static_cast<storage_type>(2.74753175878517378029484555178110786e-02L),
  694. static_cast<storage_type>(2.40099456069532162200924891648810814e-02L),
  695. static_cast<storage_type>(2.04353711458828354565682922359389737e-02L),
  696. static_cast<storage_type>(1.68478177091282982315166675363363158e-02L),
  697. static_cast<storage_type>(1.32362291955716748136564058469762381e-02L),
  698. static_cast<storage_type>(9.47397338617415160720771052365532387e-03L),
  699. static_cast<storage_type>(5.56193213535671375804023690106552207e-03L),
  700. static_cast<storage_type>(1.98738389233031592650785188284340989e-03L),
  701. };
  702. return data;
  703. }
  704. };
  705. #else
  706. template <class T>
  707. class gauss_kronrod_detail<T, 51, 3>
  708. {
  709. using storage_type = typename gauss_constant_category<T>::storage_type;
  710. public:
  711. static std::array<storage_type, 26> const & abscissa()
  712. {
  713. static const std::array<storage_type, 26> data = {
  714. static_cast<storage_type>(0.00000000000000000000000000000000000e+00Q),
  715. static_cast<storage_type>(6.15444830056850788865463923667966313e-02Q),
  716. static_cast<storage_type>(1.22864692610710396387359818808036806e-01Q),
  717. static_cast<storage_type>(1.83718939421048892015969888759528416e-01Q),
  718. static_cast<storage_type>(2.43866883720988432045190362797451586e-01Q),
  719. static_cast<storage_type>(3.03089538931107830167478909980339329e-01Q),
  720. static_cast<storage_type>(3.61172305809387837735821730127640667e-01Q),
  721. static_cast<storage_type>(4.17885382193037748851814394594572487e-01Q),
  722. static_cast<storage_type>(4.73002731445714960522182115009192041e-01Q),
  723. static_cast<storage_type>(5.26325284334719182599623778158010178e-01Q),
  724. static_cast<storage_type>(5.77662930241222967723689841612654067e-01Q),
  725. static_cast<storage_type>(6.26810099010317412788122681624517881e-01Q),
  726. static_cast<storage_type>(6.73566368473468364485120633247622176e-01Q),
  727. static_cast<storage_type>(7.17766406813084388186654079773297781e-01Q),
  728. static_cast<storage_type>(7.59259263037357630577282865204360976e-01Q),
  729. static_cast<storage_type>(7.97873797998500059410410904994306569e-01Q),
  730. static_cast<storage_type>(8.33442628760834001421021108693569569e-01Q),
  731. static_cast<storage_type>(8.65847065293275595448996969588340088e-01Q),
  732. static_cast<storage_type>(8.94991997878275368851042006782804954e-01Q),
  733. static_cast<storage_type>(9.20747115281701561746346084546330632e-01Q),
  734. static_cast<storage_type>(9.42974571228974339414011169658470532e-01Q),
  735. static_cast<storage_type>(9.61614986425842512418130033660167242e-01Q),
  736. static_cast<storage_type>(9.76663921459517511498315386479594068e-01Q),
  737. static_cast<storage_type>(9.88035794534077247637331014577406227e-01Q),
  738. static_cast<storage_type>(9.95556969790498097908784946893901617e-01Q),
  739. static_cast<storage_type>(9.99262104992609834193457486540340594e-01Q),
  740. };
  741. return data;
  742. }
  743. static std::array<storage_type, 26> const & weights()
  744. {
  745. static const std::array<storage_type, 26> data = {
  746. static_cast<storage_type>(6.15808180678329350787598242400645532e-02Q),
  747. static_cast<storage_type>(6.14711898714253166615441319652641776e-02Q),
  748. static_cast<storage_type>(6.11285097170530483058590304162927119e-02Q),
  749. static_cast<storage_type>(6.05394553760458629453602675175654272e-02Q),
  750. static_cast<storage_type>(5.97203403241740599790992919325618538e-02Q),
  751. static_cast<storage_type>(5.86896800223942079619741758567877641e-02Q),
  752. static_cast<storage_type>(5.74371163615678328535826939395064720e-02Q),
  753. static_cast<storage_type>(5.59508112204123173082406863827473468e-02Q),
  754. static_cast<storage_type>(5.42511298885454901445433704598756068e-02Q),
  755. static_cast<storage_type>(5.23628858064074758643667121378727149e-02Q),
  756. static_cast<storage_type>(5.02776790807156719633252594334400844e-02Q),
  757. static_cast<storage_type>(4.79825371388367139063922557569147550e-02Q),
  758. static_cast<storage_type>(4.55029130499217889098705847526603930e-02Q),
  759. static_cast<storage_type>(4.28728450201700494768957924394951611e-02Q),
  760. static_cast<storage_type>(4.00838255040323820748392844670756464e-02Q),
  761. static_cast<storage_type>(3.71162714834155435603306253676198760e-02Q),
  762. static_cast<storage_type>(3.40021302743293378367487952295512032e-02Q),
  763. static_cast<storage_type>(3.07923001673874888911090202152285856e-02Q),
  764. static_cast<storage_type>(2.74753175878517378029484555178110786e-02Q),
  765. static_cast<storage_type>(2.40099456069532162200924891648810814e-02Q),
  766. static_cast<storage_type>(2.04353711458828354565682922359389737e-02Q),
  767. static_cast<storage_type>(1.68478177091282982315166675363363158e-02Q),
  768. static_cast<storage_type>(1.32362291955716748136564058469762381e-02Q),
  769. static_cast<storage_type>(9.47397338617415160720771052365532387e-03Q),
  770. static_cast<storage_type>(5.56193213535671375804023690106552207e-03Q),
  771. static_cast<storage_type>(1.98738389233031592650785188284340989e-03Q),
  772. };
  773. return data;
  774. }
  775. };
  776. #endif
  777. template <class T>
  778. class gauss_kronrod_detail<T, 51, 4>
  779. {
  780. public:
  781. static std::array<T, 26> const & abscissa()
  782. {
  783. static std::array<T, 26> data = { // LCOV_EXCL_START
  784. BOOST_MATH_HUGE_CONSTANT(T, 0, 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00),
  785. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.1544483005685078886546392366796631281724348039823545274305431751687279361558658545141048781022691067898008423227288e-02),
  786. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.2286469261071039638735981880803680553220534604978373842389353789270883496885841582643884994633105537597765980412320e-01),
  787. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.8371893942104889201596988875952841578528447834990555215034512653236752851109815617651867160645591242103823539931527e-01),
  788. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.4386688372098843204519036279745158640563315632598447642113565325038747278585595067977636776325034060327548499765742e-01),
  789. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.0308953893110783016747890998033932920041937876655194685731578452573120372337209717349617882111662416355753711853559e-01),
  790. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.6117230580938783773582173012764066742207834704337506979457877784674538239569654860329531506093761400789294612122812e-01),
  791. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.1788538219303774885181439459457248709336998140069528034955785068796932076966599548717224205109797297615032607570119e-01),
  792. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.7300273144571496052218211500919204133181773846162729090723082769560327584128603010315684778279363544192787010704498e-01),
  793. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.2632528433471918259962377815801017803683252320191114313002425180471455022502695302371008520604638341970901082293650e-01),
  794. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.7766293024122296772368984161265406739573503929151825664548350776102301275263202227671659646579649084013116066120581e-01),
  795. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.2681009901031741278812268162451788101954628995068510806525222008437260184181183053045236423845198752346149030569920e-01),
  796. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.7356636847346836448512063324762217588341672807274931705965696177828773684928421158196368568030932194044282149314388e-01),
  797. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.1776640681308438818665407977329778059771167555515582423493486823991612820974965089522905953765860328116692570706602e-01),
  798. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.5925926303735763057728286520436097638752201889833412091838973544501862882026240760763679724185230331463919586229073e-01),
  799. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.9787379799850005941041090499430656940863230009338267661706934499488650817643824077118950314443984031474353711531825e-01),
  800. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.3344262876083400142102110869356956946096411382352078602086471546171813247709012525322973947759168107133491065937347e-01),
  801. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.6584706529327559544899696958834008820284409402823690293965213246691432948180280120756708738064779055576005302835351e-01),
  802. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.9499199787827536885104200678280495417455484975358390306170168295917151090119945137118600693039178162093726882638296e-01),
  803. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.2074711528170156174634608454633063157457035996277199700642836501131385042631212407808952281702820179915510491592339e-01),
  804. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.4297457122897433941401116965847053190520157060899014192745249713729532254404926130890521815127348327109666786665572e-01),
  805. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.6161498642584251241813003366016724169212642963709676666624520141292893281185666917636407790823210892689040877316178e-01),
  806. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.7666392145951751149831538647959406774537055531440674467098742731616386753588055389644670948300617866819865983054648e-01),
  807. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.8803579453407724763733101457740622707248415209160748131449972199405186821347293686245404742032360498210710718706868e-01),
  808. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9555696979049809790878494689390161725756264940480817121080493113293348134372793448728802635294700756868258870429256e-01),
  809. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9926210499260983419345748654034059370452496042279618586228697762904524428167719073818746102238075978747461480736921e-01),
  810. }; // LCOV_EXCL_STOP
  811. return data;
  812. }
  813. static std::array<T, 26> const & weights()
  814. {
  815. static std::array<T, 26> data = { // LCOV_EXCL_START
  816. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.1580818067832935078759824240064553190436936903140808056908996403358367244202623293256774502185186717703954810463664e-02),
  817. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.1471189871425316661544131965264177586537962876885022711111683500151700796198726558483367566537422877227096643444043e-02),
  818. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.1128509717053048305859030416292711922678552321960938357322028070390133769952032831204895569347757809858568165047769e-02),
  819. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.0539455376045862945360267517565427162312365710457079923487043144554747810689514408013582515489930908693681447570811e-02),
  820. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.9720340324174059979099291932561853835363045476189975483372207816149988460708299020779612375010639778624011960832019e-02),
  821. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.8689680022394207961974175856787764139795646254828315293243700305012569486054157617049685031506591863121580010947248e-02),
  822. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.7437116361567832853582693939506471994832856823896682976509412313367495727224381199978598247737089593472710899482737e-02),
  823. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.5950811220412317308240686382747346820271035112771802428932791066115158268338607019365831655460314732208940609352540e-02),
  824. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.4251129888545490144543370459875606826076838441263383072163293312936923476650934130242315028422047795830492882862973e-02),
  825. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.2362885806407475864366712137872714887351550723707596350905793656046659248541276597504566497990926306481919129870507e-02),
  826. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.0277679080715671963325259433440084440587630604775975142050968279743014641141402310302584542633557037153607386127936e-02),
  827. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.7982537138836713906392255756914754983592207423271169651235865196757913880334117810235517477328110033499422471098658e-02),
  828. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.5502913049921788909870584752660393043707768935695327316724254392794299567957035458208970599641697203261236226745020e-02),
  829. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.2872845020170049476895792439495161101999504199883328877919242515738957655253932048951366960802592343905647433925806e-02),
  830. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.0083825504032382074839284467075646401410549266591308713115878386835777315058451955614116158949614066927183232852042e-02),
  831. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.7116271483415543560330625367619875995997802688047764805628702762773009669395760582294525748583875707140577080663373e-02),
  832. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.4002130274329337836748795229551203225670528250050443083264193121524339063344855010257660547708022429300203676502386e-02),
  833. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.0792300167387488891109020215228585600877162393292487644544830559965388047996492709248618249084851477787538356572832e-02),
  834. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.7475317587851737802948455517811078614796013288710603199613621069727810352835469926107822047433566792405123805901196e-02),
  835. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.4009945606953216220092489164881081392931528209659330290734972342536012282191913069778658241972047765300060007037359e-02),
  836. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.0435371145882835456568292235938973678758006097668937220074531550163622566841885855957623103354443247806459277197725e-02),
  837. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.6847817709128298231516667536336315840402654624706139411175769276842182270078960078544597372646532637619276509222462e-02),
  838. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.3236229195571674813656405846976238077578084997863654732213860488560614587634395544002156258192582265590155862296710e-02),
  839. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.4739733861741516072077105236553238716453268483726334971394029603529306140359023187904705754719643032594360138998941e-03),
  840. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.5619321353567137580402369010655220701769295496290984052961210793810038857581724171021610100708799763006942755331129e-03),
  841. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.9873838923303159265078518828434098894299804282505973837653346298985629336820118753523093675303476883723992297810124e-03),
  842. }; // LCOV_EXCL_STOP
  843. return data;
  844. }
  845. };
  846. #ifndef BOOST_HAS_FLOAT128
  847. template <class T>
  848. class gauss_kronrod_detail<T, 61, 0>
  849. {
  850. using storage_type = typename gauss_constant_category<T>::storage_type;
  851. public:
  852. static std::array<storage_type, 31> const & abscissa()
  853. {
  854. static constexpr std::array<storage_type, 31> data = {
  855. static_cast<storage_type>(0.00000000000000000000000000000000000e+00L),
  856. static_cast<storage_type>(5.14718425553176958330252131667225737e-02L),
  857. static_cast<storage_type>(1.02806937966737030147096751318000592e-01L),
  858. static_cast<storage_type>(1.53869913608583546963794672743255920e-01L),
  859. static_cast<storage_type>(2.04525116682309891438957671002024710e-01L),
  860. static_cast<storage_type>(2.54636926167889846439805129817805108e-01L),
  861. static_cast<storage_type>(3.04073202273625077372677107199256554e-01L),
  862. static_cast<storage_type>(3.52704725530878113471037207089373861e-01L),
  863. static_cast<storage_type>(4.00401254830394392535476211542660634e-01L),
  864. static_cast<storage_type>(4.47033769538089176780609900322854000e-01L),
  865. static_cast<storage_type>(4.92480467861778574993693061207708796e-01L),
  866. static_cast<storage_type>(5.36624148142019899264169793311072794e-01L),
  867. static_cast<storage_type>(5.79345235826361691756024932172540496e-01L),
  868. static_cast<storage_type>(6.20526182989242861140477556431189299e-01L),
  869. static_cast<storage_type>(6.60061064126626961370053668149270753e-01L),
  870. static_cast<storage_type>(6.97850494793315796932292388026640068e-01L),
  871. static_cast<storage_type>(7.33790062453226804726171131369527646e-01L),
  872. static_cast<storage_type>(7.67777432104826194917977340974503132e-01L),
  873. static_cast<storage_type>(7.99727835821839083013668942322683241e-01L),
  874. static_cast<storage_type>(8.29565762382768397442898119732501916e-01L),
  875. static_cast<storage_type>(8.57205233546061098958658510658943857e-01L),
  876. static_cast<storage_type>(8.82560535792052681543116462530225590e-01L),
  877. static_cast<storage_type>(9.05573307699907798546522558925958320e-01L),
  878. static_cast<storage_type>(9.26200047429274325879324277080474004e-01L),
  879. static_cast<storage_type>(9.44374444748559979415831324037439122e-01L),
  880. static_cast<storage_type>(9.60021864968307512216871025581797663e-01L),
  881. static_cast<storage_type>(9.73116322501126268374693868423706885e-01L),
  882. static_cast<storage_type>(9.83668123279747209970032581605662802e-01L),
  883. static_cast<storage_type>(9.91630996870404594858628366109485725e-01L),
  884. static_cast<storage_type>(9.96893484074649540271630050918695283e-01L),
  885. static_cast<storage_type>(9.99484410050490637571325895705810819e-01L),
  886. };
  887. return data;
  888. }
  889. static std::array<storage_type, 31> const & weights()
  890. {
  891. static constexpr std::array<storage_type, 31> data = {
  892. static_cast<storage_type>(5.14947294294515675583404336470993075e-02L),
  893. static_cast<storage_type>(5.14261285374590259338628792157812598e-02L),
  894. static_cast<storage_type>(5.12215478492587721706562826049442083e-02L),
  895. static_cast<storage_type>(5.08817958987496064922974730498046919e-02L),
  896. static_cast<storage_type>(5.04059214027823468408930856535850289e-02L),
  897. static_cast<storage_type>(4.97956834270742063578115693799423285e-02L),
  898. static_cast<storage_type>(4.90554345550297788875281653672381736e-02L),
  899. static_cast<storage_type>(4.81858617570871291407794922983045926e-02L),
  900. static_cast<storage_type>(4.71855465692991539452614781810994865e-02L),
  901. static_cast<storage_type>(4.60592382710069881162717355593735806e-02L),
  902. static_cast<storage_type>(4.48148001331626631923555516167232438e-02L),
  903. static_cast<storage_type>(4.34525397013560693168317281170732581e-02L),
  904. static_cast<storage_type>(4.19698102151642461471475412859697578e-02L),
  905. static_cast<storage_type>(4.03745389515359591119952797524681142e-02L),
  906. static_cast<storage_type>(3.86789456247275929503486515322810503e-02L),
  907. static_cast<storage_type>(3.68823646518212292239110656171359677e-02L),
  908. static_cast<storage_type>(3.49793380280600241374996707314678751e-02L),
  909. static_cast<storage_type>(3.29814470574837260318141910168539275e-02L),
  910. static_cast<storage_type>(3.09072575623877624728842529430922726e-02L),
  911. static_cast<storage_type>(2.87540487650412928439787853543342111e-02L),
  912. static_cast<storage_type>(2.65099548823331016106017093350754144e-02L),
  913. static_cast<storage_type>(2.41911620780806013656863707252320268e-02L),
  914. static_cast<storage_type>(2.18280358216091922971674857383389934e-02L),
  915. static_cast<storage_type>(1.94141411939423811734089510501284559e-02L),
  916. static_cast<storage_type>(1.69208891890532726275722894203220924e-02L),
  917. static_cast<storage_type>(1.43697295070458048124514324435800102e-02L),
  918. static_cast<storage_type>(1.18230152534963417422328988532505929e-02L),
  919. static_cast<storage_type>(9.27327965951776342844114689202436042e-03L),
  920. static_cast<storage_type>(6.63070391593129217331982636975016813e-03L),
  921. static_cast<storage_type>(3.89046112709988405126720184451550328e-03L),
  922. static_cast<storage_type>(1.38901369867700762455159122675969968e-03L),
  923. };
  924. return data;
  925. }
  926. };
  927. #else
  928. template <class T>
  929. class gauss_kronrod_detail<T, 61, 0>
  930. {
  931. using storage_type = typename gauss_constant_category<T>::storage_type;
  932. public:
  933. static std::array<storage_type, 31> const & abscissa()
  934. {
  935. static const std::array<storage_type, 31> data = {
  936. static_cast<storage_type>(0.00000000000000000000000000000000000e+00Q),
  937. static_cast<storage_type>(5.14718425553176958330252131667225737e-02Q),
  938. static_cast<storage_type>(1.02806937966737030147096751318000592e-01Q),
  939. static_cast<storage_type>(1.53869913608583546963794672743255920e-01Q),
  940. static_cast<storage_type>(2.04525116682309891438957671002024710e-01Q),
  941. static_cast<storage_type>(2.54636926167889846439805129817805108e-01Q),
  942. static_cast<storage_type>(3.04073202273625077372677107199256554e-01Q),
  943. static_cast<storage_type>(3.52704725530878113471037207089373861e-01Q),
  944. static_cast<storage_type>(4.00401254830394392535476211542660634e-01Q),
  945. static_cast<storage_type>(4.47033769538089176780609900322854000e-01Q),
  946. static_cast<storage_type>(4.92480467861778574993693061207708796e-01Q),
  947. static_cast<storage_type>(5.36624148142019899264169793311072794e-01Q),
  948. static_cast<storage_type>(5.79345235826361691756024932172540496e-01Q),
  949. static_cast<storage_type>(6.20526182989242861140477556431189299e-01Q),
  950. static_cast<storage_type>(6.60061064126626961370053668149270753e-01Q),
  951. static_cast<storage_type>(6.97850494793315796932292388026640068e-01Q),
  952. static_cast<storage_type>(7.33790062453226804726171131369527646e-01Q),
  953. static_cast<storage_type>(7.67777432104826194917977340974503132e-01Q),
  954. static_cast<storage_type>(7.99727835821839083013668942322683241e-01Q),
  955. static_cast<storage_type>(8.29565762382768397442898119732501916e-01Q),
  956. static_cast<storage_type>(8.57205233546061098958658510658943857e-01Q),
  957. static_cast<storage_type>(8.82560535792052681543116462530225590e-01Q),
  958. static_cast<storage_type>(9.05573307699907798546522558925958320e-01Q),
  959. static_cast<storage_type>(9.26200047429274325879324277080474004e-01Q),
  960. static_cast<storage_type>(9.44374444748559979415831324037439122e-01Q),
  961. static_cast<storage_type>(9.60021864968307512216871025581797663e-01Q),
  962. static_cast<storage_type>(9.73116322501126268374693868423706885e-01Q),
  963. static_cast<storage_type>(9.83668123279747209970032581605662802e-01Q),
  964. static_cast<storage_type>(9.91630996870404594858628366109485725e-01Q),
  965. static_cast<storage_type>(9.96893484074649540271630050918695283e-01Q),
  966. static_cast<storage_type>(9.99484410050490637571325895705810819e-01Q),
  967. };
  968. return data;
  969. }
  970. static std::array<storage_type, 31> const & weights()
  971. {
  972. static const std::array<storage_type, 31> data = {
  973. static_cast<storage_type>(5.14947294294515675583404336470993075e-02Q),
  974. static_cast<storage_type>(5.14261285374590259338628792157812598e-02Q),
  975. static_cast<storage_type>(5.12215478492587721706562826049442083e-02Q),
  976. static_cast<storage_type>(5.08817958987496064922974730498046919e-02Q),
  977. static_cast<storage_type>(5.04059214027823468408930856535850289e-02Q),
  978. static_cast<storage_type>(4.97956834270742063578115693799423285e-02Q),
  979. static_cast<storage_type>(4.90554345550297788875281653672381736e-02Q),
  980. static_cast<storage_type>(4.81858617570871291407794922983045926e-02Q),
  981. static_cast<storage_type>(4.71855465692991539452614781810994865e-02Q),
  982. static_cast<storage_type>(4.60592382710069881162717355593735806e-02Q),
  983. static_cast<storage_type>(4.48148001331626631923555516167232438e-02Q),
  984. static_cast<storage_type>(4.34525397013560693168317281170732581e-02Q),
  985. static_cast<storage_type>(4.19698102151642461471475412859697578e-02Q),
  986. static_cast<storage_type>(4.03745389515359591119952797524681142e-02Q),
  987. static_cast<storage_type>(3.86789456247275929503486515322810503e-02Q),
  988. static_cast<storage_type>(3.68823646518212292239110656171359677e-02Q),
  989. static_cast<storage_type>(3.49793380280600241374996707314678751e-02Q),
  990. static_cast<storage_type>(3.29814470574837260318141910168539275e-02Q),
  991. static_cast<storage_type>(3.09072575623877624728842529430922726e-02Q),
  992. static_cast<storage_type>(2.87540487650412928439787853543342111e-02Q),
  993. static_cast<storage_type>(2.65099548823331016106017093350754144e-02Q),
  994. static_cast<storage_type>(2.41911620780806013656863707252320268e-02Q),
  995. static_cast<storage_type>(2.18280358216091922971674857383389934e-02Q),
  996. static_cast<storage_type>(1.94141411939423811734089510501284559e-02Q),
  997. static_cast<storage_type>(1.69208891890532726275722894203220924e-02Q),
  998. static_cast<storage_type>(1.43697295070458048124514324435800102e-02Q),
  999. static_cast<storage_type>(1.18230152534963417422328988532505929e-02Q),
  1000. static_cast<storage_type>(9.27327965951776342844114689202436042e-03Q),
  1001. static_cast<storage_type>(6.63070391593129217331982636975016813e-03Q),
  1002. static_cast<storage_type>(3.89046112709988405126720184451550328e-03Q),
  1003. static_cast<storage_type>(1.38901369867700762455159122675969968e-03Q),
  1004. };
  1005. return data;
  1006. }
  1007. };
  1008. #endif
  1009. template <class T>
  1010. class gauss_kronrod_detail<T, 61, 4>
  1011. {
  1012. public:
  1013. static std::array<T, 31> const & abscissa()
  1014. {
  1015. static std::array<T, 31> data = { // LCOV_EXCL_START
  1016. BOOST_MATH_HUGE_CONSTANT(T, 0, 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00),
  1017. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.1471842555317695833025213166722573749141453666569564255160843987964755210427109055870090707285485841217089963590678e-02),
  1018. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.0280693796673703014709675131800059247190133296515840552101946914632788253917872738234797140786490207720254922664913e-01),
  1019. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.5386991360858354696379467274325592041855197124433846171896298291578714851081610139692310651074078557990111754952062e-01),
  1020. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.0452511668230989143895767100202470952410426459556377447604465028350321894663245495592565235317147819577892124850607e-01),
  1021. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.5463692616788984643980512981780510788278930330251842616428597508896353156907880290636628138423620257595521678255758e-01),
  1022. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.0407320227362507737267710719925655353115778980946272844421536998312150442387767304001423699909778588529370119457430e-01),
  1023. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.5270472553087811347103720708937386065363100802142562659418446890026941623319107866436039675211352945165817827083104e-01),
  1024. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.0040125483039439253547621154266063361104593297078395983186610656429170689311759061175527015710247383961903284673474e-01),
  1025. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.4703376953808917678060990032285400016240759386142440975447738172761535172858420700400688872124189834257262048739699e-01),
  1026. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.9248046786177857499369306120770879564426564096318697026073340982988422546396352776837047452262025983265531109327026e-01),
  1027. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.3662414814201989926416979331107279416417800693029710545274348291201490861897837863114116009718990258091585830703557e-01),
  1028. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.7934523582636169175602493217254049590705158881215289208126016612312833567812241903809970751783808208940322061083509e-01),
  1029. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.2052618298924286114047755643118929920736469282952813259505117012433531497488911774115258445532782106478789996137481e-01),
  1030. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.6006106412662696137005366814927075303835037480883390955067197339904937499734522076788020517029688190998858739703079e-01),
  1031. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.9785049479331579693229238802664006838235380065395465637972284673997672124315996069538163644008904690545069439941341e-01),
  1032. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.3379006245322680472617113136952764566938172775468549208701399518300016463613325382024664531597318795933262446521430e-01),
  1033. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.6777743210482619491797734097450313169488361723290845320649438736515857017299504505260960258623968420224697596501719e-01),
  1034. BOOST_MATH_HUGE_CONSTANT(T, 0, 7.9972783582183908301366894232268324073569842937778450923647349548686662567326007229195202524185356472023967927713548e-01),
  1035. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.2956576238276839744289811973250191643906869617034167880695298345365650658958163508295244350814016004371545455777732e-01),
  1036. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.5720523354606109895865851065894385682080017062359612850504551739119887225712932688031120704657195642614071367390794e-01),
  1037. BOOST_MATH_HUGE_CONSTANT(T, 0, 8.8256053579205268154311646253022559005668914714648423206832605312161626269519165572921583828573210485349058106849548e-01),
  1038. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.0557330769990779854652255892595831956897536366222841356404766397803760239449631913585074426842574155323901785046522e-01),
  1039. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.2620004742927432587932427708047400408647453682532906091103713367942299565110232681677288015055886244486106298320068e-01),
  1040. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.4437444474855997941583132403743912158564371496498093181748940139520917000657342753448871376849848523800667868447591e-01),
  1041. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.6002186496830751221687102558179766293035921740392339948566167242493995770706842922718944370380002378239172677454384e-01),
  1042. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.7311632250112626837469386842370688488763796428343933853755850185624118958166838288308561708261486365954975485787212e-01),
  1043. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.8366812327974720997003258160566280194031785470971136351718001015114429536479104370207597166035471368057762560137209e-01),
  1044. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9163099687040459485862836610948572485050033374616325510019923349807489603260796605556191495843575227494654783755353e-01),
  1045. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9689348407464954027163005091869528334088203811775079010809429780238769521016374081588201955806171741257405095963817e-01),
  1046. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9948441005049063757132589570581081946887394701850801923632642830748016674843587830656468823145435723317885056396548e-01),
  1047. }; // LCOV_EXCL_STOP
  1048. return data;
  1049. }
  1050. static std::array<T, 31> const & weights()
  1051. {
  1052. static std::array<T, 31> data = { // LCOV_EXCL_START
  1053. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.1494729429451567558340433647099307532736880396464168074637323362474083844397567724480716864880173808112573901197920e-02),
  1054. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.1426128537459025933862879215781259829552034862395987263855824172761589259406892072066110681184224608133314131500422e-02),
  1055. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.1221547849258772170656282604944208251146952425246327553509056805511015401279553971190412722969308620984161625812560e-02),
  1056. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.0881795898749606492297473049804691853384914260919239920771942080972542646780575571132056254070929858650733836163479e-02),
  1057. BOOST_MATH_HUGE_CONSTANT(T, 0, 5.0405921402782346840893085653585028902197018251622233664243959211066713308635283713447747907973700791599900911248852e-02),
  1058. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.9795683427074206357811569379942328539209602813696108951047392842948482646220377655098341924089250200477846596263918e-02),
  1059. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.9055434555029778887528165367238173605887405295296569579490717901328215644590555247522873065246297467067324397612445e-02),
  1060. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.8185861757087129140779492298304592605799236108429800057373350872433793583969368428942672063270298939865425225579922e-02),
  1061. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.7185546569299153945261478181099486482884807300628457194141861551725533289490897029020276525603515502104799540544222e-02),
  1062. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.6059238271006988116271735559373580594692875571824924004732379492293604006446052672252973438978639166425766841417488e-02),
  1063. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.4814800133162663192355551616723243757431392796373009889680201194063503947907899189061064792111919040540351834527742e-02),
  1064. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.3452539701356069316831728117073258074603308631703168064888805495738640839573863333942084117196541456054957383622173e-02),
  1065. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.1969810215164246147147541285969757790088656718992374820388720323852655511200365790379948462006156953358103259681948e-02),
  1066. BOOST_MATH_HUGE_CONSTANT(T, 0, 4.0374538951535959111995279752468114216126062126030255633998289613810846761059740961836828802959573901107306640876603e-02),
  1067. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.8678945624727592950348651532281050250923629821553846790376130679337402056620700554139109487533759557982632153728099e-02),
  1068. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.6882364651821229223911065617135967736955164781030337670005198584196134970154169862584193360751243227989492571664973e-02),
  1069. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.4979338028060024137499670731467875097226912794818719972208457232177786702008744219498470603846784465175225933802357e-02),
  1070. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.2981447057483726031814191016853927510599291213858385714519347641452316582381008804994515341969205985818543200837577e-02),
  1071. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.0907257562387762472884252943092272635270458523807153426840486964022086189874056947717446328187131273807982629114591e-02),
  1072. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.8754048765041292843978785354334211144679160542074930035102280759132174815469834227854660515366003136772757344886331e-02),
  1073. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.6509954882333101610601709335075414366517579522748565770867438338472138903658077617652522759934474895733739329287706e-02),
  1074. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.4191162078080601365686370725232026760391377828182462432228943562944885267501070688006470962871743661192935455117297e-02),
  1075. BOOST_MATH_HUGE_CONSTANT(T, 0, 2.1828035821609192297167485738338993401507296056834912773630422358720439403382559079356058602393879803560534375378340e-02),
  1076. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.9414141193942381173408951050128455851421014191431525770276066536497179079025540486072726114628763606440143557769099e-02),
  1077. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.6920889189053272627572289420322092368566703783835191139883410840546679978551861043620089451681146020853650713611444e-02),
  1078. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.4369729507045804812451432443580010195841899895001505873565899403000198662495821906144274682894222591414503342336172e-02),
  1079. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.1823015253496341742232898853250592896264406250607818326302431548265365155855182739401700032519141448997853772603766e-02),
  1080. BOOST_MATH_HUGE_CONSTANT(T, 0, 9.2732796595177634284411468920243604212700249381931076964956469143626665557434385492325784596343112153704094886248672e-03),
  1081. BOOST_MATH_HUGE_CONSTANT(T, 0, 6.6307039159312921733198263697501681336283882177812585973955597357837568277731921327731815844512598157843672104469554e-03),
  1082. BOOST_MATH_HUGE_CONSTANT(T, 0, 3.8904611270998840512672018445155032785151429848864649214200101281144733676455451061226273655941038347210163533085954e-03),
  1083. BOOST_MATH_HUGE_CONSTANT(T, 0, 1.3890136986770076245515912267596996810488412919632724534411055332301367130989865366956251556423820479579333920310978e-03),
  1084. }; // LCOV_EXCL_STOP
  1085. return data;
  1086. }
  1087. };
  1088. }
  1089. template <class Real, unsigned N, class Policy = boost::math::policies::policy<> >
  1090. class gauss_kronrod : public detail::gauss_kronrod_detail<Real, N, detail::gauss_constant_category<Real>::value>
  1091. {
  1092. typedef detail::gauss_kronrod_detail<Real, N, detail::gauss_constant_category<Real>::value> base;
  1093. public:
  1094. typedef Real value_type;
  1095. private:
  1096. template <class F>
  1097. static auto integrate_non_adaptive_m1_1(F f, Real* error = nullptr, Real* pL1 = nullptr)->decltype(std::declval<F>()(std::declval<Real>()))
  1098. {
  1099. typedef decltype(f(Real(0))) K;
  1100. using std::abs;
  1101. unsigned gauss_start = 2;
  1102. unsigned kronrod_start = 1;
  1103. unsigned gauss_order = (N - 1) / 2;
  1104. K kronrod_result = 0;
  1105. K gauss_result = 0;
  1106. K fp, fm;
  1107. if (gauss_order & 1)
  1108. {
  1109. fp = f(value_type(0));
  1110. kronrod_result = fp * static_cast<Real>(base::weights()[0]);
  1111. gauss_result += fp * static_cast<Real>(gauss<Real, (N - 1) / 2>::weights()[0]);
  1112. }
  1113. else
  1114. {
  1115. fp = f(value_type(0));
  1116. kronrod_result = fp * static_cast<Real>(base::weights()[0]);
  1117. gauss_start = 1;
  1118. kronrod_start = 2;
  1119. }
  1120. Real L1 = abs(kronrod_result);
  1121. for (unsigned i = gauss_start; i < base::abscissa().size(); i += 2)
  1122. {
  1123. fp = f(static_cast<Real>(base::abscissa()[i]));
  1124. fm = f(static_cast<Real>(-base::abscissa()[i]));
  1125. kronrod_result += (fp + fm) * static_cast<Real>(base::weights()[i]);
  1126. L1 += (abs(fp) + abs(fm)) * static_cast<Real>(base::weights()[i]);
  1127. gauss_result += (fp + fm) * static_cast<Real>(gauss<Real, (N - 1) / 2>::weights()[i / 2]);
  1128. }
  1129. for (unsigned i = kronrod_start; i < base::abscissa().size(); i += 2)
  1130. {
  1131. fp = f(static_cast<Real>(base::abscissa()[i]));
  1132. fm = f(static_cast<Real>(-base::abscissa()[i]));
  1133. kronrod_result += (fp + fm) * static_cast<Real>(base::weights()[i]);
  1134. L1 += (abs(fp) + abs(fm)) * static_cast<Real>(base::weights()[i]);
  1135. }
  1136. if (pL1)
  1137. *pL1 = L1;
  1138. if (error)
  1139. *error = (std::max)(static_cast<Real>(abs(kronrod_result - gauss_result)), static_cast<Real>(abs(kronrod_result * tools::epsilon<Real>() * Real(2))));
  1140. return kronrod_result;
  1141. }
  1142. template <class F>
  1143. struct recursive_info
  1144. {
  1145. F f;
  1146. Real tol;
  1147. };
  1148. template <class F>
  1149. static auto recursive_adaptive_integrate(const recursive_info<F>* info, Real a, Real b, unsigned max_levels, Real abs_tol, Real* error, Real* L1)->decltype(std::declval<F>()(std::declval<Real>()))
  1150. {
  1151. typedef decltype(info->f(Real(a))) K;
  1152. using std::abs;
  1153. Real error_local;
  1154. Real mean = (b + a) / 2;
  1155. Real scale = (b - a) / 2;
  1156. auto ff = [&](const Real& x)->K
  1157. {
  1158. return info->f(scale * x + mean);
  1159. };
  1160. K r1 = integrate_non_adaptive_m1_1(ff, &error_local, L1);
  1161. K estimate = scale * r1;
  1162. K tmp = estimate * info->tol;
  1163. Real abs_tol1 = abs(tmp);
  1164. if (abs_tol == 0)
  1165. abs_tol = abs_tol1;
  1166. if (max_levels && (abs_tol1 < error_local) && (abs_tol < error_local))
  1167. {
  1168. Real mid = (a + b) / 2;
  1169. Real L1_local;
  1170. estimate = recursive_adaptive_integrate(info, a, mid, max_levels - 1, abs_tol / 2, error, L1);
  1171. estimate += recursive_adaptive_integrate(info, mid, b, max_levels - 1, abs_tol / 2, &error_local, &L1_local);
  1172. if (error)
  1173. *error += error_local;
  1174. if (L1)
  1175. *L1 += L1_local;
  1176. return estimate;
  1177. }
  1178. if(L1)
  1179. *L1 *= scale;
  1180. if (error)
  1181. *error = error_local;
  1182. return estimate;
  1183. }
  1184. public:
  1185. template <class F>
  1186. static auto integrate(F f, Real a, Real b, unsigned max_depth = 15, Real tol = tools::root_epsilon<Real>(), Real* error = nullptr, Real* pL1 = nullptr)->decltype(std::declval<F>()(std::declval<Real>()))
  1187. {
  1188. typedef decltype(f(a)) K;
  1189. static_assert(!std::is_integral<K>::value,
  1190. "The return type cannot be integral, it must be either a real or complex floating point type.");
  1191. static const char* function = "boost::math::quadrature::gauss_kronrod<%1%>::integrate(f, %1%, %1%)";
  1192. if (!(boost::math::isnan)(a) && !(boost::math::isnan)(b))
  1193. {
  1194. // Infinite limits:
  1195. if ((a <= -tools::max_value<Real>()) && (b >= tools::max_value<Real>()))
  1196. {
  1197. auto u = [&](const Real& t)->K
  1198. {
  1199. Real t_sq = t*t;
  1200. Real inv = 1 / (1 - t_sq);
  1201. Real w = (1 + t_sq)*inv*inv;
  1202. Real arg = t*inv;
  1203. K res = f(arg)*w;
  1204. return res;
  1205. };
  1206. recursive_info<decltype(u)> info = { u, tol };
  1207. K res = recursive_adaptive_integrate(&info, Real(-1), Real(1), max_depth, Real(0), error, pL1);
  1208. return res;
  1209. }
  1210. // Right limit is infinite:
  1211. if ((boost::math::isfinite)(a) && (b >= tools::max_value<Real>()))
  1212. {
  1213. auto u = [&](const Real& t)->K
  1214. {
  1215. Real z = 1 / (t + 1);
  1216. Real arg = 2 * z + a - 1;
  1217. K res = f(arg)*z*z;
  1218. return res;
  1219. };
  1220. recursive_info<decltype(u)> info = { u, tol };
  1221. K Q = Real(2) * recursive_adaptive_integrate(&info, Real(-1), Real(1), max_depth, Real(0), error, pL1);
  1222. if (pL1)
  1223. {
  1224. *pL1 *= 2;
  1225. }
  1226. return Q;
  1227. }
  1228. if ((boost::math::isfinite)(b) && (a <= -tools::max_value<Real>()))
  1229. {
  1230. auto v = [&](const Real& t)->K
  1231. {
  1232. Real z = 1 / (t + 1);
  1233. Real arg = 2 * z - 1;
  1234. return f(b - arg) * z * z;
  1235. };
  1236. recursive_info<decltype(v)> info = { v, tol };
  1237. K Q = Real(2) * recursive_adaptive_integrate(&info, Real(-1), Real(1), max_depth, Real(0), error, pL1);
  1238. if (pL1)
  1239. {
  1240. *pL1 *= 2;
  1241. }
  1242. return Q;
  1243. }
  1244. if ((boost::math::isfinite)(a) && (boost::math::isfinite)(b))
  1245. {
  1246. if (a==b)
  1247. {
  1248. return K(0);
  1249. }
  1250. recursive_info<F> info = { f, tol };
  1251. if (b < a)
  1252. {
  1253. return -recursive_adaptive_integrate(&info, b, a, max_depth, Real(0), error, pL1);
  1254. }
  1255. return recursive_adaptive_integrate(&info, a, b, max_depth, Real(0), error, pL1);
  1256. }
  1257. }
  1258. return static_cast<K>(policies::raise_domain_error(function, "The domain of integration is not sensible; please check the bounds.", a, Policy()));
  1259. }
  1260. };
  1261. } // namespace quadrature
  1262. } // namespace math
  1263. } // namespace boost
  1264. #ifdef _MSC_VER
  1265. #pragma warning(pop)
  1266. #endif
  1267. #endif // BOOST_MATH_QUADRATURE_GAUSS_KRONROD_HPP