brintos

brintos / llvm-project-archived public Read only

0
0
Text · 49.7 KiB · 91ffcf0 Raw
905 lines · plain
1//  Copyright John Maddock 2015.2//  Use, modification and distribution are subject to the3//  Boost Software License, Version 1.0. (See accompanying file4//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)5 6#ifndef BOOST_MATH_QUADRATURE_GAUSS_HPP7#define BOOST_MATH_QUADRATURE_GAUSS_HPP8 9#ifdef _MSC_VER10#pragma once11#endif12 13#include <limits>14#include <vector>15#include <boost/math/special_functions/legendre.hpp>16#include <boost/math/constants/constants.hpp>17 18#ifdef _MSC_VER19#pragma warning(push)20#pragma warning(disable:4127)21#endif22 23namespace boost { namespace math{ namespace quadrature{ namespace detail{24 25template <class T>26struct gauss_constant_category27{28   static const unsigned value =29      (std::numeric_limits<T>::is_specialized == 0) ? 999 :30      (std::numeric_limits<T>::radix == 2) ?31      (32#ifdef BOOST_HAS_FLOAT12833         (std::numeric_limits<T>::digits <= 113) && std::is_constructible<T, __float128>::value ? 0 :34#else35         (std::numeric_limits<T>::digits <= std::numeric_limits<long double>::digits) && std::is_constructible<T, long double>::value ? 0 :36#endif37         (std::numeric_limits<T>::digits10 <= 110) && std::is_constructible<T, const char*>::value ? 4 : 99938      ) : (std::numeric_limits<T>::digits10 <= 110) && std::is_constructible<T, const char*>::value ? 4 : 999;39   40   using storage_type =41      std::conditional_t<(std::numeric_limits<T>::is_specialized == 0), T,42         std::conditional_t<(std::numeric_limits<T>::radix == 2),43            std::conditional_t< ((std::numeric_limits<T>::digits <= std::numeric_limits<float>::digits) && std::is_constructible<T, float>::value),44               float,45               std::conditional_t<((std::numeric_limits<T>::digits <= std::numeric_limits<double>::digits) && std::is_constructible<T, double>::value),46                  double,47                  std::conditional_t<((std::numeric_limits<T>::digits <= std::numeric_limits<long double>::digits) && std::is_constructible<T, long double>::value),48                     long double,49#ifdef BOOST_HAS_FLOAT12850                     std::conditional_t<((std::numeric_limits<T>::digits <= 113) && std::is_constructible<T, __float128>::value),51                        __float128,52                        T53                     >54                  >55#else56                     T57                  >58#endif59               >60            >, T61         >62      >;63};64 65#ifndef BOOST_MATH_GAUSS_NO_COMPUTE_ON_DEMAND66 67template <class Real, unsigned N, unsigned Category>68class gauss_detail69{70   static std::vector<Real> calculate_weights()71   {72      std::vector<Real> result(abscissa().size(), 0);73      for (unsigned i = 0; i < abscissa().size(); ++i)74      {75         Real x = abscissa()[i];76         Real p = boost::math::legendre_p_prime(N, x);77         result[i] = 2 / ((1 - x * x) * p * p);78      }79      return result;80   }81public:82   static const std::vector<Real>& abscissa()83   {84      static std::vector<Real> data = boost::math::legendre_p_zeros<Real>(N);85      return data;86   }87   static const std::vector<Real>& weights()88   {89      static std::vector<Real> data = calculate_weights();90      return data;91   }92};93 94#else95 96template <class Real, unsigned N, unsigned Category>97class gauss_detail;98 99#endif100#ifndef BOOST_HAS_FLOAT128101template <class T>102class gauss_detail<T, 7, 0>103{104   using storage_type = typename gauss_constant_category<T>::storage_type;105public:106   static std::array<storage_type, 4> const & abscissa()107   {108      static constexpr std::array<storage_type, 4> data = {109         static_cast<storage_type>(0.00000000000000000000000000000000000e+00L),110         static_cast<storage_type>(4.05845151377397166906606412076961463e-01L),111         static_cast<storage_type>(7.41531185599394439863864773280788407e-01L),112         static_cast<storage_type>(9.49107912342758524526189684047851262e-01L),113      };114      return data;115   }116   static std::array<storage_type, 4> const & weights()117   {118      static constexpr std::array<storage_type, 4> data = {119         static_cast<storage_type>(4.17959183673469387755102040816326531e-01L),120         static_cast<storage_type>(3.81830050505118944950369775488975134e-01L),121         static_cast<storage_type>(2.79705391489276667901467771423779582e-01L),122         static_cast<storage_type>(1.29484966168869693270611432679082018e-01L),123      };124      return data;125   }126};127#else128template <class T>129class gauss_detail<T, 7, 0>130{131   using storage_type = typename gauss_constant_category<T>::storage_type;132public:133   static std::array<storage_type, 4> const & abscissa()134   {135      static const std::array<storage_type, 4> data = {136         static_cast<storage_type>(0.00000000000000000000000000000000000e+00Q),137         static_cast<storage_type>(4.05845151377397166906606412076961463e-01Q),138         static_cast<storage_type>(7.41531185599394439863864773280788407e-01Q),139         static_cast<storage_type>(9.49107912342758524526189684047851262e-01Q),140      };141      return data;142   }143   static std::array<storage_type, 4> const & weights()144   {145      static const std::array<storage_type, 4> data = {146         static_cast<storage_type>(4.17959183673469387755102040816326531e-01Q),147         static_cast<storage_type>(3.81830050505118944950369775488975134e-01Q),148         static_cast<storage_type>(2.79705391489276667901467771423779582e-01Q),149         static_cast<storage_type>(1.29484966168869693270611432679082018e-01Q),150      };151      return data;152   }153};154#endif155template <class T>156class gauss_detail<T, 7, 4>157{158public:159   static  std::array<T, 4> const & abscissa()160   {161      static  std::array<T, 4> data = { // LCOV_EXCL_START162         BOOST_MATH_HUGE_CONSTANT(T, 0, 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00),163         BOOST_MATH_HUGE_CONSTANT(T, 0, 4.0584515137739716690660641207696146334738201409937012638704325179466381322612565532831268972774658776528675866604802e-01),164         BOOST_MATH_HUGE_CONSTANT(T, 0, 7.4153118559939443986386477328078840707414764714139026011995535196742987467218051379282683236686324705969251809311201e-01),165         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.4910791234275852452618968404785126240077093767061778354876910391306333035484014080573077002792572414430073966699522e-01),166      }; // LCOV_EXCL_STOP167      return data;168   }169   static  std::array<T, 4> const & weights()170   {171      static  std::array<T, 4> data = { // LCOV_EXCL_START172         BOOST_MATH_HUGE_CONSTANT(T, 0, 4.1795918367346938775510204081632653061224489795918367346938775510204081632653061224489795918367346938775510204081633e-01),173         BOOST_MATH_HUGE_CONSTANT(T, 0, 3.8183005050511894495036977548897513387836508353386273475108345103070554643412970834868465934404480145031467176458536e-01),174         BOOST_MATH_HUGE_CONSTANT(T, 0, 2.7970539148927666790146777142377958248692506522659876453701403269361881043056267681324094290119761876632337521337205e-01),175         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.2948496616886969327061143267908201832858740225994666397720863872465523497204230871562541816292084508948440200163443e-01),176      }; // LCOV_EXCL_STOP177      return data;178   }179};180#ifndef BOOST_HAS_FLOAT128181template <class T>182class gauss_detail<T, 10, 0>183{184   using storage_type = typename gauss_constant_category<T>::storage_type;185public:186   static std::array<storage_type, 5> const & abscissa()187   {188      static constexpr std::array<storage_type, 5> data = {189         static_cast<storage_type>(1.48874338981631210884826001129719985e-01L),190         static_cast<storage_type>(4.33395394129247190799265943165784162e-01L),191         static_cast<storage_type>(6.79409568299024406234327365114873576e-01L),192         static_cast<storage_type>(8.65063366688984510732096688423493049e-01L),193         static_cast<storage_type>(9.73906528517171720077964012084452053e-01L),194      };195      return data;196   }197   static std::array<storage_type, 5> const & weights()198   {199      static constexpr std::array<storage_type, 5> data = {200         static_cast<storage_type>(2.95524224714752870173892994651338329e-01L),201         static_cast<storage_type>(2.69266719309996355091226921569469353e-01L),202         static_cast<storage_type>(2.19086362515982043995534934228163192e-01L),203         static_cast<storage_type>(1.49451349150580593145776339657697332e-01L),204         static_cast<storage_type>(6.66713443086881375935688098933317929e-02L),205      };206      return data;207   }208};209#else210template <class T>211class gauss_detail<T, 10, 0>212{213   using storage_type = typename gauss_constant_category<T>::storage_type;214public:215   static std::array<storage_type, 5> const & abscissa()216   {217      static const std::array<storage_type, 5> data = {218         static_cast<storage_type>(1.48874338981631210884826001129719985e-01Q),219         static_cast<storage_type>(4.33395394129247190799265943165784162e-01Q),220         static_cast<storage_type>(6.79409568299024406234327365114873576e-01Q),221         static_cast<storage_type>(8.65063366688984510732096688423493049e-01Q),222         static_cast<storage_type>(9.73906528517171720077964012084452053e-01Q),223      };224      return data;225   }226   static std::array<storage_type, 5> const & weights()227   {228      static const std::array<storage_type, 5> data = {229         static_cast<storage_type>(2.95524224714752870173892994651338329e-01Q),230         static_cast<storage_type>(2.69266719309996355091226921569469353e-01Q),231         static_cast<storage_type>(2.19086362515982043995534934228163192e-01Q),232         static_cast<storage_type>(1.49451349150580593145776339657697332e-01Q),233         static_cast<storage_type>(6.66713443086881375935688098933317929e-02Q),234      };235      return data;236   }237};238#endif239template <class T>240class gauss_detail<T, 10, 4>241{242public:243   static  std::array<T, 5> const & abscissa()244   {245      static  std::array<T, 5> data = { // LCOV_EXCL_START246         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.4887433898163121088482600112971998461756485942069169570798925351590361735566852137117762979946369123003116080525534e-01),247         BOOST_MATH_HUGE_CONSTANT(T, 0, 4.3339539412924719079926594316578416220007183765624649650270151314376698907770350122510275795011772122368293504099894e-01),248         BOOST_MATH_HUGE_CONSTANT(T, 0, 6.7940956829902440623432736511487357576929471183480946766481718895255857539507492461507857357048037949983390204739932e-01),249         BOOST_MATH_HUGE_CONSTANT(T, 0, 8.6506336668898451073209668842349304852754301496533045252195973184537475513805556135679072894604577069440463108641177e-01),250         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.7390652851717172007796401208445205342826994669238211923121206669659520323463615962572356495626855625823304251877421e-01),251      }; // LCOV_EXCL_STOP252      return data;253   }254   static  std::array<T, 5> const & weights()255   {256      static  std::array<T, 5> data = { // LCOV_EXCL_START257         BOOST_MATH_HUGE_CONSTANT(T, 0, 2.9552422471475287017389299465133832942104671702685360135430802975599593821715232927035659579375421672271716440125256e-01),258         BOOST_MATH_HUGE_CONSTANT(T, 0, 2.6926671930999635509122692156946935285975993846088379580056327624215343231917927676422663670925276075559581145036870e-01),259         BOOST_MATH_HUGE_CONSTANT(T, 0, 2.1908636251598204399553493422816319245877187052267708988095654363519991065295128124268399317720219278659121687281289e-01),260         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.4945134915058059314577633965769733240255663966942736783547726875323865472663001094594726463473195191400575256104544e-01),261         BOOST_MATH_HUGE_CONSTANT(T, 0, 6.6671344308688137593568809893331792857864834320158145128694881613412064084087101776785509685058877821090054714520419e-02),262      }; // LCOV_EXCL_STOP263      return data;264   }265};266 267#ifndef BOOST_HAS_FLOAT128268template <class T>269class gauss_detail<T, 15, 0>270{271   using storage_type = typename gauss_constant_category<T>::storage_type;272public:273   static std::array<storage_type, 8> const & abscissa()274   {275      static constexpr std::array<storage_type, 8> data = {276         static_cast<storage_type>(0.00000000000000000000000000000000000e+00L),277         static_cast<storage_type>(2.01194093997434522300628303394596208e-01L),278         static_cast<storage_type>(3.94151347077563369897207370981045468e-01L),279         static_cast<storage_type>(5.70972172608538847537226737253910641e-01L),280         static_cast<storage_type>(7.24417731360170047416186054613938010e-01L),281         static_cast<storage_type>(8.48206583410427216200648320774216851e-01L),282         static_cast<storage_type>(9.37273392400705904307758947710209471e-01L),283         static_cast<storage_type>(9.87992518020485428489565718586612581e-01L),284      };285      return data;286   }287   static std::array<storage_type, 8> const & weights()288   {289      static constexpr std::array<storage_type, 8> data = {290         static_cast<storage_type>(2.02578241925561272880620199967519315e-01L),291         static_cast<storage_type>(1.98431485327111576456118326443839325e-01L),292         static_cast<storage_type>(1.86161000015562211026800561866422825e-01L),293         static_cast<storage_type>(1.66269205816993933553200860481208811e-01L),294         static_cast<storage_type>(1.39570677926154314447804794511028323e-01L),295         static_cast<storage_type>(1.07159220467171935011869546685869303e-01L),296         static_cast<storage_type>(7.03660474881081247092674164506673385e-02L),297         static_cast<storage_type>(3.07532419961172683546283935772044177e-02L),298      };299      return data;300   }301};302#else303template <class T>304class gauss_detail<T, 15, 0>305{306   using storage_type = typename gauss_constant_category<T>::storage_type;307public:308   static std::array<storage_type, 8> const & abscissa()309   {310      static const std::array<storage_type, 8> data = {311         static_cast<storage_type>(0.00000000000000000000000000000000000e+00Q),312         static_cast<storage_type>(2.01194093997434522300628303394596208e-01Q),313         static_cast<storage_type>(3.94151347077563369897207370981045468e-01Q),314         static_cast<storage_type>(5.70972172608538847537226737253910641e-01Q),315         static_cast<storage_type>(7.24417731360170047416186054613938010e-01Q),316         static_cast<storage_type>(8.48206583410427216200648320774216851e-01Q),317         static_cast<storage_type>(9.37273392400705904307758947710209471e-01Q),318         static_cast<storage_type>(9.87992518020485428489565718586612581e-01Q),319      };320      return data;321   }322   static std::array<storage_type, 8> const & weights()323   {324      static const std::array<storage_type, 8> data = {325         static_cast<storage_type>(2.02578241925561272880620199967519315e-01Q),326         static_cast<storage_type>(1.98431485327111576456118326443839325e-01Q),327         static_cast<storage_type>(1.86161000015562211026800561866422825e-01Q),328         static_cast<storage_type>(1.66269205816993933553200860481208811e-01Q),329         static_cast<storage_type>(1.39570677926154314447804794511028323e-01Q),330         static_cast<storage_type>(1.07159220467171935011869546685869303e-01Q),331         static_cast<storage_type>(7.03660474881081247092674164506673385e-02Q),332         static_cast<storage_type>(3.07532419961172683546283935772044177e-02Q),333      };334      return data;335   }336};337#endif338template <class T>339class gauss_detail<T, 15, 4>340{341public:342   static  std::array<T, 8> const & abscissa()343   {344      static  std::array<T, 8> data = { // LCOV_EXCL_START345         BOOST_MATH_HUGE_CONSTANT(T, 0, 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00),346         BOOST_MATH_HUGE_CONSTANT(T, 0, 2.0119409399743452230062830339459620781283645446263767961594972460994823900302018760183625806752105908967902257386509e-01),347         BOOST_MATH_HUGE_CONSTANT(T, 0, 3.9415134707756336989720737098104546836275277615869825503116534395160895778696141797549711416165976202589352169635648e-01),348         BOOST_MATH_HUGE_CONSTANT(T, 0, 5.7097217260853884753722673725391064123838639628274960485326541705419537986975857948341462856982614477912646497026257e-01),349         BOOST_MATH_HUGE_CONSTANT(T, 0, 7.2441773136017004741618605461393800963089929458410256355142342070412378167792521899610109760313432626923598549381925e-01),350         BOOST_MATH_HUGE_CONSTANT(T, 0, 8.4820658341042721620064832077421685136625617473699263409572755876067507517414548519760771975082148085090373835713340e-01),351         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.3727339240070590430775894771020947124399627351530445790136307635020297379704552795054758617426808659746824044603157e-01),352         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.8799251802048542848956571858661258114697281712376148999999751558738843736901942471272205036831914497667516843990079e-01),353      }; // LCOV_EXCL_STOP354      return data;355   }356   static  std::array<T, 8> const & weights()357   {358      static  std::array<T, 8> data = { // LCOV_EXCL_START359         BOOST_MATH_HUGE_CONSTANT(T, 0, 2.0257824192556127288062019996751931483866215800947735679670411605143539875474607409339344071278803213535148267082999e-01),360         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.9843148532711157645611832644383932481869255995754199348473792792912479753343426813331499916481782320766020854889310e-01),361         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.8616100001556221102680056186642282450622601227792840281549572731001325550269916061894976888609932360539977709001384e-01),362         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.6626920581699393355320086048120881113090018009841290732186519056355356321227851771070517429241553621484461540657185e-01),363         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.3957067792615431444780479451102832252085027531551124320239112863108844454190781168076825736357133363814908889327664e-01),364         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.0715922046717193501186954668586930341554371575810198068702238912187799485231579972568585713760862404439808767837506e-01),365         BOOST_MATH_HUGE_CONSTANT(T, 0, 7.0366047488108124709267416450667338466708032754330719825907292914387055512874237044840452066693939219355489858595041e-02),366         BOOST_MATH_HUGE_CONSTANT(T, 0, 3.0753241996117268354628393577204417721748144833434074264228285504237189467117168039038770732399404002516991188859473e-02),367      }; // LCOV_EXCL_STOP368      return data;369   }370};371 372#ifndef BOOST_HAS_FLOAT128373template <class T>374class gauss_detail<T, 20, 0>375{376   using storage_type = typename gauss_constant_category<T>::storage_type;377public:378   static std::array<storage_type, 10> const & abscissa()379   {380      static constexpr std::array<storage_type, 10> data = {381         static_cast<storage_type>(7.65265211334973337546404093988382110e-02L),382         static_cast<storage_type>(2.27785851141645078080496195368574625e-01L),383         static_cast<storage_type>(3.73706088715419560672548177024927237e-01L),384         static_cast<storage_type>(5.10867001950827098004364050955250998e-01L),385         static_cast<storage_type>(6.36053680726515025452836696226285937e-01L),386         static_cast<storage_type>(7.46331906460150792614305070355641590e-01L),387         static_cast<storage_type>(8.39116971822218823394529061701520685e-01L),388         static_cast<storage_type>(9.12234428251325905867752441203298113e-01L),389         static_cast<storage_type>(9.63971927277913791267666131197277222e-01L),390         static_cast<storage_type>(9.93128599185094924786122388471320278e-01L),391      };392      return data;393   }394   static std::array<storage_type, 10> const & weights()395   {396      static constexpr std::array<storage_type, 10> data = {397         static_cast<storage_type>(1.52753387130725850698084331955097593e-01L),398         static_cast<storage_type>(1.49172986472603746787828737001969437e-01L),399         static_cast<storage_type>(1.42096109318382051329298325067164933e-01L),400         static_cast<storage_type>(1.31688638449176626898494499748163135e-01L),401         static_cast<storage_type>(1.18194531961518417312377377711382287e-01L),402         static_cast<storage_type>(1.01930119817240435036750135480349876e-01L),403         static_cast<storage_type>(8.32767415767047487247581432220462061e-02L),404         static_cast<storage_type>(6.26720483341090635695065351870416064e-02L),405         static_cast<storage_type>(4.06014298003869413310399522749321099e-02L),406         static_cast<storage_type>(1.76140071391521183118619623518528164e-02L),407      };408      return data;409   }410};411#else412template <class T>413class gauss_detail<T, 20, 0>414{415   using storage_type = typename gauss_constant_category<T>::storage_type;416public:417   static std::array<storage_type, 10> const & abscissa()418   {419      static const std::array<storage_type, 10> data = {420         static_cast<storage_type>(7.65265211334973337546404093988382110e-02Q),421         static_cast<storage_type>(2.27785851141645078080496195368574625e-01Q),422         static_cast<storage_type>(3.73706088715419560672548177024927237e-01Q),423         static_cast<storage_type>(5.10867001950827098004364050955250998e-01Q),424         static_cast<storage_type>(6.36053680726515025452836696226285937e-01Q),425         static_cast<storage_type>(7.46331906460150792614305070355641590e-01Q),426         static_cast<storage_type>(8.39116971822218823394529061701520685e-01Q),427         static_cast<storage_type>(9.12234428251325905867752441203298113e-01Q),428         static_cast<storage_type>(9.63971927277913791267666131197277222e-01Q),429         static_cast<storage_type>(9.93128599185094924786122388471320278e-01Q),430      };431      return data;432   }433   static std::array<storage_type, 10> const & weights()434   {435      static const std::array<storage_type, 10> data = {436         static_cast<storage_type>(1.52753387130725850698084331955097593e-01Q),437         static_cast<storage_type>(1.49172986472603746787828737001969437e-01Q),438         static_cast<storage_type>(1.42096109318382051329298325067164933e-01Q),439         static_cast<storage_type>(1.31688638449176626898494499748163135e-01Q),440         static_cast<storage_type>(1.18194531961518417312377377711382287e-01Q),441         static_cast<storage_type>(1.01930119817240435036750135480349876e-01Q),442         static_cast<storage_type>(8.32767415767047487247581432220462061e-02Q),443         static_cast<storage_type>(6.26720483341090635695065351870416064e-02Q),444         static_cast<storage_type>(4.06014298003869413310399522749321099e-02Q),445         static_cast<storage_type>(1.76140071391521183118619623518528164e-02Q),446      };447      return data;448   }449};450#endif451template <class T>452class gauss_detail<T, 20, 4>453{454public:455   static  std::array<T, 10> const & abscissa()456   {457      static  std::array<T, 10> data = { // LCOV_EXCL_START458         BOOST_MATH_HUGE_CONSTANT(T, 0, 7.6526521133497333754640409398838211004796266813497500804795244384256342048336978241545114181556215606998505646364133e-02),459         BOOST_MATH_HUGE_CONSTANT(T, 0, 2.2778585114164507808049619536857462474308893768292747231463573920717134186355582779495212519096870803177373131560430e-01),460         BOOST_MATH_HUGE_CONSTANT(T, 0, 3.7370608871541956067254817702492723739574632170568271182794861351564576437305952789589568363453337894476772208852815e-01),461         BOOST_MATH_HUGE_CONSTANT(T, 0, 5.1086700195082709800436405095525099842549132920242683347234861989473497039076572814403168305086777919832943068843526e-01),462         BOOST_MATH_HUGE_CONSTANT(T, 0, 6.3605368072651502545283669622628593674338911679936846393944662254654126258543013255870319549576130658211710937772596e-01),463         BOOST_MATH_HUGE_CONSTANT(T, 0, 7.4633190646015079261430507035564159031073067956917644413954590606853535503815506468110411362064752061238490065167656e-01),464         BOOST_MATH_HUGE_CONSTANT(T, 0, 8.3911697182221882339452906170152068532962936506563737325249272553286109399932480991922934056595764922060422035306914e-01),465         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.1223442825132590586775244120329811304918479742369177479588221915807089120871907893644472619292138737876039175464603e-01),466         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.6397192727791379126766613119727722191206032780618885606353759389204158078438305698001812525596471563131043491596423e-01),467         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9312859918509492478612238847132027822264713090165589614818413121798471762775378083944940249657220927472894034724419e-01),468      }; // LCOV_EXCL_STOP469      return data;470   }471   static  std::array<T, 10> const & weights()472   {473      static  std::array<T, 10> data = { // LCOV_EXCL_START474         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.5275338713072585069808433195509759349194864511237859727470104981759745316273778153557248783650390593544001842813788e-01),475         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.4917298647260374678782873700196943669267990408136831649621121780984442259558678069396132603521048105170913854567338e-01),476         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.4209610931838205132929832506716493303451541339202030333736708298382808749793436761694922428320058260133068573666201e-01),477         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.3168863844917662689849449974816313491611051114698352699643649370885435642948093314355797518397262924510598005463625e-01),478         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.1819453196151841731237737771138228700504121954896877544688995202017474835051151630572868782581901744606267543092317e-01),479         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.0193011981724043503675013548034987616669165602339255626197161619685232202539434647534931576947985821375859035525483e-01),480         BOOST_MATH_HUGE_CONSTANT(T, 0, 8.3276741576704748724758143222046206100177828583163290744882060785693082894079419471375190843790839349096116111932764e-02),481         BOOST_MATH_HUGE_CONSTANT(T, 0, 6.2672048334109063569506535187041606351601076578436364099584345437974811033665678644563766056832203512603253399592073e-02),482         BOOST_MATH_HUGE_CONSTANT(T, 0, 4.0601429800386941331039952274932109879090639989951536817606854561832296750987328295538920623044384976189825709675075e-02),483         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.7614007139152118311861962351852816362143105543336732524349326677348419259621847817403105542146097668703716227512570e-02),484      }; // LCOV_EXCL_STOP485      return data;486   }487};488 489#ifndef BOOST_HAS_FLOAT128490template <class T>491class gauss_detail<T, 25, 0>492{493   using storage_type = typename gauss_constant_category<T>::storage_type;494public:495   static std::array<storage_type, 13> const & abscissa()496   {497      static constexpr std::array<storage_type, 13> data = {498         static_cast<storage_type>(0.00000000000000000000000000000000000e+00L),499         static_cast<storage_type>(1.22864692610710396387359818808036806e-01L),500         static_cast<storage_type>(2.43866883720988432045190362797451586e-01L),501         static_cast<storage_type>(3.61172305809387837735821730127640667e-01L),502         static_cast<storage_type>(4.73002731445714960522182115009192041e-01L),503         static_cast<storage_type>(5.77662930241222967723689841612654067e-01L),504         static_cast<storage_type>(6.73566368473468364485120633247622176e-01L),505         static_cast<storage_type>(7.59259263037357630577282865204360976e-01L),506         static_cast<storage_type>(8.33442628760834001421021108693569569e-01L),507         static_cast<storage_type>(8.94991997878275368851042006782804954e-01L),508         static_cast<storage_type>(9.42974571228974339414011169658470532e-01L),509         static_cast<storage_type>(9.76663921459517511498315386479594068e-01L),510         static_cast<storage_type>(9.95556969790498097908784946893901617e-01L),511      };512      return data;513   }514   static std::array<storage_type, 13> const & weights()515   {516      static constexpr std::array<storage_type, 13> data = {517         static_cast<storage_type>(1.23176053726715451203902873079050142e-01L),518         static_cast<storage_type>(1.22242442990310041688959518945851506e-01L),519         static_cast<storage_type>(1.19455763535784772228178126512901047e-01L),520         static_cast<storage_type>(1.14858259145711648339325545869555809e-01L),521         static_cast<storage_type>(1.08519624474263653116093957050116619e-01L),522         static_cast<storage_type>(1.00535949067050644202206890392685827e-01L),523         static_cast<storage_type>(9.10282619829636498114972207028916534e-02L),524         static_cast<storage_type>(8.01407003350010180132349596691113023e-02L),525         static_cast<storage_type>(6.80383338123569172071871856567079686e-02L),526         static_cast<storage_type>(5.49046959758351919259368915404733242e-02L),527         static_cast<storage_type>(4.09391567013063126556234877116459537e-02L),528         static_cast<storage_type>(2.63549866150321372619018152952991449e-02L),529         static_cast<storage_type>(1.13937985010262879479029641132347736e-02L),530      };531      return data;532   }533};534#else535template <class T>536class gauss_detail<T, 25, 0>537{538   using storage_type = typename gauss_constant_category<T>::storage_type;539public:540   static std::array<storage_type, 13> const & abscissa()541   {542      static const std::array<storage_type, 13> data = {543         static_cast<storage_type>(0.00000000000000000000000000000000000e+00Q),544         static_cast<storage_type>(1.22864692610710396387359818808036806e-01Q),545         static_cast<storage_type>(2.43866883720988432045190362797451586e-01Q),546         static_cast<storage_type>(3.61172305809387837735821730127640667e-01Q),547         static_cast<storage_type>(4.73002731445714960522182115009192041e-01Q),548         static_cast<storage_type>(5.77662930241222967723689841612654067e-01Q),549         static_cast<storage_type>(6.73566368473468364485120633247622176e-01Q),550         static_cast<storage_type>(7.59259263037357630577282865204360976e-01Q),551         static_cast<storage_type>(8.33442628760834001421021108693569569e-01Q),552         static_cast<storage_type>(8.94991997878275368851042006782804954e-01Q),553         static_cast<storage_type>(9.42974571228974339414011169658470532e-01Q),554         static_cast<storage_type>(9.76663921459517511498315386479594068e-01Q),555         static_cast<storage_type>(9.95556969790498097908784946893901617e-01Q),556      };557      return data;558   }559   static std::array<storage_type, 13> const & weights()560   {561      static const std::array<storage_type, 13> data = {562         static_cast<storage_type>(1.23176053726715451203902873079050142e-01Q),563         static_cast<storage_type>(1.22242442990310041688959518945851506e-01Q),564         static_cast<storage_type>(1.19455763535784772228178126512901047e-01Q),565         static_cast<storage_type>(1.14858259145711648339325545869555809e-01Q),566         static_cast<storage_type>(1.08519624474263653116093957050116619e-01Q),567         static_cast<storage_type>(1.00535949067050644202206890392685827e-01Q),568         static_cast<storage_type>(9.10282619829636498114972207028916534e-02Q),569         static_cast<storage_type>(8.01407003350010180132349596691113023e-02Q),570         static_cast<storage_type>(6.80383338123569172071871856567079686e-02Q),571         static_cast<storage_type>(5.49046959758351919259368915404733242e-02Q),572         static_cast<storage_type>(4.09391567013063126556234877116459537e-02Q),573         static_cast<storage_type>(2.63549866150321372619018152952991449e-02Q),574         static_cast<storage_type>(1.13937985010262879479029641132347736e-02Q),575      };576      return data;577   }578};579#endif580template <class T>581class gauss_detail<T, 25, 4>582{583public:584   static  std::array<T, 13> const & abscissa()585   {586      static  std::array<T, 13> data = { // LCOV_EXCL_START587         BOOST_MATH_HUGE_CONSTANT(T, 0, 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00),588         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.2286469261071039638735981880803680553220534604978373842389353789270883496885841582643884994633105537597765980412320e-01),589         BOOST_MATH_HUGE_CONSTANT(T, 0, 2.4386688372098843204519036279745158640563315632598447642113565325038747278585595067977636776325034060327548499765742e-01),590         BOOST_MATH_HUGE_CONSTANT(T, 0, 3.6117230580938783773582173012764066742207834704337506979457877784674538239569654860329531506093761400789294612122812e-01),591         BOOST_MATH_HUGE_CONSTANT(T, 0, 4.7300273144571496052218211500919204133181773846162729090723082769560327584128603010315684778279363544192787010704498e-01),592         BOOST_MATH_HUGE_CONSTANT(T, 0, 5.7766293024122296772368984161265406739573503929151825664548350776102301275263202227671659646579649084013116066120581e-01),593         BOOST_MATH_HUGE_CONSTANT(T, 0, 6.7356636847346836448512063324762217588341672807274931705965696177828773684928421158196368568030932194044282149314388e-01),594         BOOST_MATH_HUGE_CONSTANT(T, 0, 7.5925926303735763057728286520436097638752201889833412091838973544501862882026240760763679724185230331463919586229073e-01),595         BOOST_MATH_HUGE_CONSTANT(T, 0, 8.3344262876083400142102110869356956946096411382352078602086471546171813247709012525322973947759168107133491065937347e-01),596         BOOST_MATH_HUGE_CONSTANT(T, 0, 8.9499199787827536885104200678280495417455484975358390306170168295917151090119945137118600693039178162093726882638296e-01),597         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.4297457122897433941401116965847053190520157060899014192745249713729532254404926130890521815127348327109666786665572e-01),598         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.7666392145951751149831538647959406774537055531440674467098742731616386753588055389644670948300617866819865983054648e-01),599         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9555696979049809790878494689390161725756264940480817121080493113293348134372793448728802635294700756868258870429256e-01),600      }; // LCOV_EXCL_STOP601      return data;602   }603   static  std::array<T, 13> const & weights()604   {605      static  std::array<T, 13> data = { // LCOV_EXCL_START606         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.2317605372671545120390287307905014243823362751815166539135219731691200794926142128460112517504958377310054583945994e-01),607         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.2224244299031004168895951894585150583505924756305904090758008223203896721918010243033540891078906637115620156845304e-01),608         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.1945576353578477222817812651290104739017670141372642551958788133518409022018773502442869720975271321374348568426235e-01),609         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.1485825914571164833932554586955580864093619166818014959151499003148279667112542256534429898558156273250513652351744e-01),610         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.0851962447426365311609395705011661934007758798672201615649430734883929279360844269339768350029654172135832773427565e-01),611         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.0053594906705064420220689039268582698846609452814190706986904199941294815904602968195565620373258211755226681206658e-01),612         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.1028261982963649811497220702891653380992558959334310970483768967017384678410526902484398142953718885872521590850372e-02),613         BOOST_MATH_HUGE_CONSTANT(T, 0, 8.0140700335001018013234959669111302290225732853675893716201462973612828934801289559457377714225318048243957479325813e-02),614         BOOST_MATH_HUGE_CONSTANT(T, 0, 6.8038333812356917207187185656707968554709494354636562615071226410003654051711473106651522969481873733098761760660898e-02),615         BOOST_MATH_HUGE_CONSTANT(T, 0, 5.4904695975835191925936891540473324160109985553111349048508498244593774678436511895711924079433444763756746828817613e-02),616         BOOST_MATH_HUGE_CONSTANT(T, 0, 4.0939156701306312655623487711645953660845783364104346504698414899297432880215512770478971055110424130123527015425511e-02),617         BOOST_MATH_HUGE_CONSTANT(T, 0, 2.6354986615032137261901815295299144935963281703322468755366165783870934008879499371529821528172928890350362464605104e-02),618         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.1393798501026287947902964113234773603320526292909696448948061116189891729766743355923677112945033505688431618009664e-02),619      }; // LCOV_EXCL_STOP620      return data;621   }622};623 624 625#ifndef BOOST_HAS_FLOAT128626template <class T>627class gauss_detail<T, 30, 0>628{629   using storage_type = typename gauss_constant_category<T>::storage_type;630public:631   static std::array<storage_type, 15> const & abscissa()632   {633      static constexpr std::array<storage_type, 15> data = {634         static_cast<storage_type>(5.14718425553176958330252131667225737e-02L),635         static_cast<storage_type>(1.53869913608583546963794672743255920e-01L),636         static_cast<storage_type>(2.54636926167889846439805129817805108e-01L),637         static_cast<storage_type>(3.52704725530878113471037207089373861e-01L),638         static_cast<storage_type>(4.47033769538089176780609900322854000e-01L),639         static_cast<storage_type>(5.36624148142019899264169793311072794e-01L),640         static_cast<storage_type>(6.20526182989242861140477556431189299e-01L),641         static_cast<storage_type>(6.97850494793315796932292388026640068e-01L),642         static_cast<storage_type>(7.67777432104826194917977340974503132e-01L),643         static_cast<storage_type>(8.29565762382768397442898119732501916e-01L),644         static_cast<storage_type>(8.82560535792052681543116462530225590e-01L),645         static_cast<storage_type>(9.26200047429274325879324277080474004e-01L),646         static_cast<storage_type>(9.60021864968307512216871025581797663e-01L),647         static_cast<storage_type>(9.83668123279747209970032581605662802e-01L),648         static_cast<storage_type>(9.96893484074649540271630050918695283e-01L),649      };650      return data;651   }652   static std::array<storage_type, 15> const & weights()653   {654      static constexpr std::array<storage_type, 15> data = {655         static_cast<storage_type>(1.02852652893558840341285636705415044e-01L),656         static_cast<storage_type>(1.01762389748405504596428952168554045e-01L),657         static_cast<storage_type>(9.95934205867952670627802821035694765e-02L),658         static_cast<storage_type>(9.63687371746442596394686263518098651e-02L),659         static_cast<storage_type>(9.21225222377861287176327070876187672e-02L),660         static_cast<storage_type>(8.68997872010829798023875307151257026e-02L),661         static_cast<storage_type>(8.07558952294202153546949384605297309e-02L),662         static_cast<storage_type>(7.37559747377052062682438500221907342e-02L),663         static_cast<storage_type>(6.59742298821804951281285151159623612e-02L),664         static_cast<storage_type>(5.74931562176190664817216894020561288e-02L),665         static_cast<storage_type>(4.84026728305940529029381404228075178e-02L),666         static_cast<storage_type>(3.87991925696270495968019364463476920e-02L),667         static_cast<storage_type>(2.87847078833233693497191796112920436e-02L),668         static_cast<storage_type>(1.84664683110909591423021319120472691e-02L),669         static_cast<storage_type>(7.96819249616660561546588347467362245e-03L),670      };671      return data;672   }673};674#else675template <class T>676class gauss_detail<T, 30, 0>677{678   using storage_type = typename gauss_constant_category<T>::storage_type;679public:680   static std::array<storage_type, 15> const & abscissa()681   {682      static const std::array<storage_type, 15> data = {683         static_cast<storage_type>(5.14718425553176958330252131667225737e-02Q),684         static_cast<storage_type>(1.53869913608583546963794672743255920e-01Q),685         static_cast<storage_type>(2.54636926167889846439805129817805108e-01Q),686         static_cast<storage_type>(3.52704725530878113471037207089373861e-01Q),687         static_cast<storage_type>(4.47033769538089176780609900322854000e-01Q),688         static_cast<storage_type>(5.36624148142019899264169793311072794e-01Q),689         static_cast<storage_type>(6.20526182989242861140477556431189299e-01Q),690         static_cast<storage_type>(6.97850494793315796932292388026640068e-01Q),691         static_cast<storage_type>(7.67777432104826194917977340974503132e-01Q),692         static_cast<storage_type>(8.29565762382768397442898119732501916e-01Q),693         static_cast<storage_type>(8.82560535792052681543116462530225590e-01Q),694         static_cast<storage_type>(9.26200047429274325879324277080474004e-01Q),695         static_cast<storage_type>(9.60021864968307512216871025581797663e-01Q),696         static_cast<storage_type>(9.83668123279747209970032581605662802e-01Q),697         static_cast<storage_type>(9.96893484074649540271630050918695283e-01Q),698      };699      return data;700   }701   static std::array<storage_type, 15> const & weights()702   {703      static const std::array<storage_type, 15> data = {704         static_cast<storage_type>(1.02852652893558840341285636705415044e-01Q),705         static_cast<storage_type>(1.01762389748405504596428952168554045e-01Q),706         static_cast<storage_type>(9.95934205867952670627802821035694765e-02Q),707         static_cast<storage_type>(9.63687371746442596394686263518098651e-02Q),708         static_cast<storage_type>(9.21225222377861287176327070876187672e-02Q),709         static_cast<storage_type>(8.68997872010829798023875307151257026e-02Q),710         static_cast<storage_type>(8.07558952294202153546949384605297309e-02Q),711         static_cast<storage_type>(7.37559747377052062682438500221907342e-02Q),712         static_cast<storage_type>(6.59742298821804951281285151159623612e-02Q),713         static_cast<storage_type>(5.74931562176190664817216894020561288e-02Q),714         static_cast<storage_type>(4.84026728305940529029381404228075178e-02Q),715         static_cast<storage_type>(3.87991925696270495968019364463476920e-02Q),716         static_cast<storage_type>(2.87847078833233693497191796112920436e-02Q),717         static_cast<storage_type>(1.84664683110909591423021319120472691e-02Q),718         static_cast<storage_type>(7.96819249616660561546588347467362245e-03Q),719      };720      return data;721   }722};723#endif724template <class T>725class gauss_detail<T, 30, 4>726{727public:728   static  std::array<T, 15> const & abscissa()729   {730      static  std::array<T, 15> data = { // LCOV_EXCL_START731         BOOST_MATH_HUGE_CONSTANT(T, 0, 5.1471842555317695833025213166722573749141453666569564255160843987964755210427109055870090707285485841217089963590678e-02),732         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.5386991360858354696379467274325592041855197124433846171896298291578714851081610139692310651074078557990111754952062e-01),733         BOOST_MATH_HUGE_CONSTANT(T, 0, 2.5463692616788984643980512981780510788278930330251842616428597508896353156907880290636628138423620257595521678255758e-01),734         BOOST_MATH_HUGE_CONSTANT(T, 0, 3.5270472553087811347103720708937386065363100802142562659418446890026941623319107866436039675211352945165817827083104e-01),735         BOOST_MATH_HUGE_CONSTANT(T, 0, 4.4703376953808917678060990032285400016240759386142440975447738172761535172858420700400688872124189834257262048739699e-01),736         BOOST_MATH_HUGE_CONSTANT(T, 0, 5.3662414814201989926416979331107279416417800693029710545274348291201490861897837863114116009718990258091585830703557e-01),737         BOOST_MATH_HUGE_CONSTANT(T, 0, 6.2052618298924286114047755643118929920736469282952813259505117012433531497488911774115258445532782106478789996137481e-01),738         BOOST_MATH_HUGE_CONSTANT(T, 0, 6.9785049479331579693229238802664006838235380065395465637972284673997672124315996069538163644008904690545069439941341e-01),739         BOOST_MATH_HUGE_CONSTANT(T, 0, 7.6777743210482619491797734097450313169488361723290845320649438736515857017299504505260960258623968420224697596501719e-01),740         BOOST_MATH_HUGE_CONSTANT(T, 0, 8.2956576238276839744289811973250191643906869617034167880695298345365650658958163508295244350814016004371545455777732e-01),741         BOOST_MATH_HUGE_CONSTANT(T, 0, 8.8256053579205268154311646253022559005668914714648423206832605312161626269519165572921583828573210485349058106849548e-01),742         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.2620004742927432587932427708047400408647453682532906091103713367942299565110232681677288015055886244486106298320068e-01),743         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.6002186496830751221687102558179766293035921740392339948566167242493995770706842922718944370380002378239172677454384e-01),744         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.8366812327974720997003258160566280194031785470971136351718001015114429536479104370207597166035471368057762560137209e-01),745         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9689348407464954027163005091869528334088203811775079010809429780238769521016374081588201955806171741257405095963817e-01),746      }; // LCOV_EXCL_STOP747      return data;748   }749   static  std::array<T, 15> const & weights()750   {751      static  std::array<T, 15> data = { // LCOV_EXCL_START752         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.0285265289355884034128563670541504386837555706492822258631898667601623865660942939262884632188870916503815852709086e-01),753         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.0176238974840550459642895216855404463270628948712684086426094541964251360531767494547599781978391198881693385887696e-01),754         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.9593420586795267062780282103569476529869263666704277221365146183946660389908809018092299289324184705373523229592037e-02),755         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.6368737174644259639468626351809865096406461430160245912994275732837534742003123724951247818104195363343093583583429e-02),756         BOOST_MATH_HUGE_CONSTANT(T, 0, 9.2122522237786128717632707087618767196913234418234107527675047001973047070094168298464052916811907158954949394100501e-02),757         BOOST_MATH_HUGE_CONSTANT(T, 0, 8.6899787201082979802387530715125702576753328743545344012222129882153582254261494247955033509639105330215477601953921e-02),758         BOOST_MATH_HUGE_CONSTANT(T, 0, 8.0755895229420215354694938460529730875892803708439299890258593706051180567026345604212402769217808080749416147400962e-02),759         BOOST_MATH_HUGE_CONSTANT(T, 0, 7.3755974737705206268243850022190734153770526037049438941269182374599399314635211710401352716638183270192254236882630e-02),760         BOOST_MATH_HUGE_CONSTANT(T, 0, 6.5974229882180495128128515115962361237442953656660378967031516042143672466094179365819913911598737439478205808271237e-02),761         BOOST_MATH_HUGE_CONSTANT(T, 0, 5.7493156217619066481721689402056128797120670721763134548715799003232147409954376925211999650950125355559974348279846e-02),762         BOOST_MATH_HUGE_CONSTANT(T, 0, 4.8402672830594052902938140422807517815271809197372736345191936791805425677102152797767439563562263454374645955072007e-02),763         BOOST_MATH_HUGE_CONSTANT(T, 0, 3.8799192569627049596801936446347692033200976766395352107732789705946970952769793919055026279035105656340228558382274e-02),764         BOOST_MATH_HUGE_CONSTANT(T, 0, 2.8784707883323369349719179611292043639588894546287496474180122608145988940013933101730206711484171554940392262251283e-02),765         BOOST_MATH_HUGE_CONSTANT(T, 0, 1.8466468311090959142302131912047269096206533968181403371298365514585599521307973654080519029675417955638095832046164e-02),766         BOOST_MATH_HUGE_CONSTANT(T, 0, 7.9681924961666056154658834746736224504806965871517212294851633569200384329013332941536616922861735209846506562158817e-03),767      }; // LCOV_EXCL_STOP768      return data;769   }770};771 772}773 774template <class Real, unsigned N, class Policy = boost::math::policies::policy<> >775class gauss : public detail::gauss_detail<Real, N, detail::gauss_constant_category<Real>::value>776{777   typedef detail::gauss_detail<Real, N, detail::gauss_constant_category<Real>::value> base;778public:779 780   template <class F>781   static auto integrate(F f, Real* pL1 = nullptr)->decltype(std::declval<F>()(std::declval<Real>()))782   {783     // In many math texts, K represents the field of real or complex numbers.784     // Too bad we can't put blackboard bold into C++ source!785      typedef decltype(f(Real(0))) K;786      static_assert(!std::is_integral<K>::value,787                   "The return type cannot be integral, it must be either a real or complex floating point type.");788      using std::abs;789      unsigned non_zero_start = 1;790      K result = Real(0);791      if (N & 1) {792         result = f(Real(0)) * static_cast<Real>(base::weights()[0]);793      }794      else {795         result = 0;796         non_zero_start = 0;797      }798      Real L1 = abs(result);799      for (unsigned i = non_zero_start; i < base::abscissa().size(); ++i)800      {801         K fp = f(static_cast<Real>(base::abscissa()[i]));802         K fm = f(static_cast<Real>(-base::abscissa()[i]));803         result += (fp + fm) * static_cast<Real>(base::weights()[i]);804         L1 += (abs(fp) + abs(fm)) * static_cast<Real>(base::weights()[i]);805      }806      if (pL1)807         *pL1 = L1;808      return result;809   }810   template <class F>811   static auto integrate(F f, Real a, Real b, Real* pL1 = nullptr)->decltype(std::declval<F>()(std::declval<Real>()))812   {813      typedef decltype(f(a)) K;814      static const char* function = "boost::math::quadrature::gauss<%1%>::integrate(f, %1%, %1%)";815      if (!(boost::math::isnan)(a) && !(boost::math::isnan)(b))816      {817         // Infinite limits:818         Real min_inf = -tools::max_value<Real>();819         if ((a <= min_inf) && (b >= tools::max_value<Real>()))820         {821            auto u = [&](const Real& t)->K822            {823               Real t_sq = t*t;824               Real inv = 1 / (1 - t_sq);825               K res = f(t*inv)*(1 + t_sq)*inv*inv;826               return res;827            };828            return integrate(u, pL1);829         }830 831         // Right limit is infinite:832         if ((boost::math::isfinite)(a) && (b >= tools::max_value<Real>()))833         {834            auto u = [&](const Real& t)->K835            {836               Real z = 1 / (t + 1);837               Real arg = 2 * z + a - 1;838               K res = f(arg)*z*z;839               return res;840            };841            K Q = Real(2) * integrate(u, pL1);842            if (pL1)843            {844               *pL1 *= 2;845            }846            return Q;847         }848 849         if ((boost::math::isfinite)(b) && (a <= -tools::max_value<Real>()))850         {851            auto v = [&](const Real& t)->K852            {853               Real z = 1 / (t + 1);854               Real arg = 2 * z - 1;855               K res = f(b - arg) * z * z;856               return res;857            };858            K Q = Real(2) * integrate(v, pL1);859            if (pL1)860            {861               *pL1 *= 2;862            }863            return Q;864         }865 866         if ((boost::math::isfinite)(a) && (boost::math::isfinite)(b))867         {868            if (a == b)869            {870               return K(0);871            }872            if (b < a)873            {874               return -integrate(f, b, a, pL1);875            }876            Real avg = (a + b)*constants::half<Real>();877            Real scale = (b - a)*constants::half<Real>();878 879            auto u = [&](Real z)->K880            {881               return f(avg + scale*z);882            };883            K Q = scale*integrate(u, pL1);884 885            if (pL1)886            {887               *pL1 *= scale;888            }889            return Q;890         }891      }892      return static_cast<K>(policies::raise_domain_error(function, "The domain of integration is not sensible; please check the bounds.", a, Policy()));893   }894};895 896} // namespace quadrature897} // namespace math898} // namespace boost899 900#ifdef _MSC_VER901#pragma warning(pop)902#endif903 904#endif // BOOST_MATH_QUADRATURE_GAUSS_HPP905