68 struct gsl_function_struct
70 double (*
function) (
double x,
void * params);
74 #define GSL_FN_EVAL(F,x) (*((F)->function))(x,(F)->params)
91 gsl_integration_workspace;
93 gsl_integration_workspace *
101 double epsabs,
double epsrel,
size_t limit,
103 gsl_integration_workspace * workspace,
104 double *
result,
double *abserr);
109 double epsabs,
double epsrel,
size_t limit,
110 gsl_integration_workspace * workspace,
111 double *
result,
double * abserr) ;
115 double epsabs,
double epsrel,
size_t limit,
116 gsl_integration_workspace * workspace,
117 double *
result,
double *abserr) ;
122 double epsabs,
double epsrel,
size_t limit,
123 gsl_integration_workspace * workspace,
124 double *
result,
double *abserr) ;
129 double epsabs,
double epsrel,
size_t limit,
130 gsl_integration_workspace * workspace,
131 double *
result,
double *abserr) ;
143 RooRealVar maxSeg(
"maxSeg",
"maximum number of segments",100) ;
144 RooCategory method(
"method",
"Integration method for each segment") ;
175 _epsAbs(config.epsRel()),
176 _epsRel(config.epsAbs()),
197 _epsAbs(config.epsRel()),
198 _epsRel(config.epsAbs()),
261 coutE(
Integration) <<
"RooAdaptiveGaussKronrodIntegrator1D::setLimits: cannot override integrand's limits" << endl;
288 if (!infLo && !infHi) {
290 }
else if (infLo && infHi) {
292 }
else if (infLo && !infHi) {
384 #define GSL_SUCCESS 0
387 #define GSL_EBADTOL 13
389 #define GSL_ERROR(a,b) oocoutE((TObject*)0,Integration) << "RooAdaptiveGaussKronrodIntegrator1D::integral() ERROR: " << a << endl ; return b ;
390 #define GSL_DBL_MIN 2.2250738585072014e-308
391 #define GSL_DBL_MAX 1.7976931348623157e+308
392 #define GSL_DBL_EPSILON 2.2204460492503131e-16
395 #define GSL_EMAXITER 3
397 #define GSL_EFAILED 5
398 #define GSL_EDIVERGE 6
401 #define GSL_ERROR_VAL(reason, gsl_errno, value) return value ;
403 #define GSL_MAX(a,b) ((a) > (b) ? (a) : (b))
419 #define GSL_COERCE_DBL(x) (gsl_coerce_double(x))
432 double *
result,
double *abserr,
433 double *defabs,
double *resabs);
436 double *
result,
double *abserr,
437 double *resabs,
double *resasc);
440 double *
result,
double *abserr,
441 double *resabs,
double *resasc);
444 double *
result,
double *abserr,
445 double *resabs,
double *resasc);
448 double *
result,
double *abserr,
449 double *resabs,
double *resasc);
452 double *
result,
double *abserr,
453 double *resabs,
double *resasc);
456 double *
result,
double *abserr,
457 double *resabs,
double *resasc);
460 double *cheb12,
double *cheb24);
478 const double wg[],
const double wgk[],
479 double fv1[],
double fv2[],
481 double *
result,
double * abserr,
482 double * resabs,
double * resasc);
487 double epsabs,
double epsrel,
size_t limit,
489 gsl_integration_workspace * workspace,
490 double *
result,
double *abserr);
495 void initialise (gsl_integration_workspace * workspace,
double a,
double b);
498 void initialise (gsl_integration_workspace * workspace,
double a,
double b)
501 workspace->nrmax = 0;
503 workspace->alist[0] =
a;
504 workspace->blist[0] = b;
505 workspace->rlist[0] = 0.0;
506 workspace->elist[0] = 0.0;
507 workspace->order[0] = 0;
508 workspace->level[0] = 0;
510 workspace->maximum_level = 0;
516 double result,
double error);
520 double result,
double error)
523 workspace->rlist[0] =
result;
524 workspace->elist[0] = error;
529 qpsrt (gsl_integration_workspace * workspace);
532 void qpsrt (gsl_integration_workspace * workspace)
534 const size_t last = workspace->size - 1;
535 const size_t limit = workspace->limit;
537 double * elist = workspace->elist;
538 size_t * order = workspace->order;
544 size_t i_nrmax = workspace->nrmax;
545 size_t i_maxerr = order[i_nrmax] ;
553 workspace->i = i_maxerr ;
557 errmax = elist[i_maxerr] ;
564 while (i_nrmax > 0 && errmax > elist[order[i_nrmax - 1]])
566 order[i_nrmax] = order[i_nrmax - 1] ;
574 if(last < (limit/2 + 2))
580 top = limit - last + 1;
591 while (i < top && errmax < elist[order[i]])
593 order[i-1] = order[i] ;
597 order[i-1] = i_maxerr ;
601 errmin = elist[last] ;
605 while (k > i - 2 && errmin >= elist[order[k]])
607 order[k+1] = order[k] ;
615 i_maxerr = order[i_nrmax] ;
617 workspace->i = i_maxerr ;
618 workspace->nrmax = i_nrmax ;
625 void update (gsl_integration_workspace * workspace,
626 double a1,
double b1,
double area1,
double error1,
627 double a2,
double b2,
double area2,
double error2);
630 retrieve (
const gsl_integration_workspace * workspace,
631 double *
a,
double * b,
double *
r,
double * e);
636 void update (gsl_integration_workspace * workspace,
637 double a1,
double b1,
double area1,
double error1,
638 double a2,
double b2,
double area2,
double error2)
640 double * alist = workspace->alist ;
641 double * blist = workspace->blist ;
642 double * rlist = workspace->rlist ;
643 double * elist = workspace->elist ;
644 size_t * level = workspace->level ;
646 const size_t i_max = workspace->i ;
647 const size_t i_new = workspace->size ;
649 const size_t new_level = workspace->level[i_max] + 1;
656 rlist[i_max] = area2;
657 elist[i_max] = error2;
658 level[i_max] = new_level;
662 rlist[i_new] = area1;
663 elist[i_new] = error1;
664 level[i_new] = new_level;
669 rlist[i_max] = area1;
670 elist[i_max] = error1;
671 level[i_max] = new_level;
675 rlist[i_new] = area2;
676 elist[i_new] = error2;
677 level[i_new] = new_level;
682 if (new_level > workspace->maximum_level)
684 workspace->maximum_level = new_level;
691 retrieve (
const gsl_integration_workspace * workspace,
692 double *
a,
double * b,
double *
r,
double * e)
694 const size_t i = workspace->i;
695 double * alist = workspace->alist;
696 double * blist = workspace->blist;
697 double * rlist = workspace->rlist;
698 double * elist = workspace->elist;
707 sum_results (
const gsl_integration_workspace * workspace);
712 const double *
const rlist = workspace->rlist ;
713 const size_t n = workspace->size;
716 double result_sum = 0;
718 for (k = 0; k <
n; k++)
720 result_sum += rlist[k];
735 double tmp = (1 + 100 * e) * (
fabs (a2) + 1000 * u);
745 const double a,
const double b,
746 const double epsabs,
const double epsrel,
748 gsl_integration_workspace * workspace,
749 double *
result,
double * abserr,
755 double epsabs,
double epsrel,
size_t limit,
757 gsl_integration_workspace * workspace,
758 double *
result,
double * abserr)
794 status =
qag (f, a, b, epsabs, epsrel, limit,
804 const double a,
const double b,
805 const double epsabs,
const double epsrel,
807 gsl_integration_workspace * workspace,
808 double *
result,
double *abserr,
812 double result0, abserr0, resabs0, resasc0;
814 size_t iteration = 0;
815 int roundoff_type1 = 0, roundoff_type2 = 0, error_type = 0;
826 if (limit > workspace->limit)
831 if (epsabs <= 0 && (epsrel < 50 *
GSL_DBL_EPSILON || epsrel < 0.5e-28))
833 GSL_ERROR (
"tolerance cannot be acheived with given epsabs and epsrel",
839 q (f, a, b, &result0, &abserr0, &resabs0, &resasc0);
851 if (abserr0 <= round_off && abserr0 > tolerance)
856 GSL_ERROR (
"cannot reach tolerance because of roundoff error "
859 else if ((abserr0 <= tolerance && abserr0 != resasc0) || abserr0 == 0.0)
881 double a1, b1, a2, b2;
882 double a_i, b_i, r_i, e_i;
883 double area1 = 0, area2 = 0, area12 = 0;
884 double error1 = 0, error2 = 0, error12 = 0;
885 double resasc1, resasc2;
886 double resabs1, resabs2;
890 retrieve (workspace, &a_i, &b_i, &r_i, &e_i);
893 b1 = 0.5 * (a_i + b_i);
897 q (f, a1, b1, &area1, &error1, &resabs1, &resasc1);
898 q (f, a2, b2, &area2, &error2, &resabs2, &resasc2);
900 area12 = area1 + area2;
901 error12 = error1 + error2;
903 errsum += (error12 - e_i);
904 area += area12 - r_i;
906 if (resasc1 != error1 && resasc2 != error2)
908 double delta = r_i - area12;
910 if (
fabs (delta) <= 1.0e-5 *
fabs (area12) && error12 >= 0.99 * e_i)
914 if (iteration >= 10 && error12 > e_i)
922 if (errsum > tolerance)
924 if (roundoff_type1 >= 6 || roundoff_type2 >= 20)
938 update (workspace, a1, b1, area1, error1, a2, b2, area2, error2);
940 retrieve (workspace, &a_i, &b_i, &r_i, &e_i);
945 while (iteration < limit && !error_type && errsum > tolerance);
950 if (errsum <= tolerance)
954 else if (error_type == 2)
956 GSL_ERROR (
"roundoff error prevents tolerance from being achieved",
959 else if (error_type == 3)
961 GSL_ERROR (
"bad integrand behavior found in the integration interval",
964 else if (iteration == limit)
974 static double rescale_error (
double err,
const double result_abs,
const double result_asc) ;
977 rescale_error (
double err,
const double result_abs,
const double result_asc)
981 if (result_asc != 0 && err != 0)
983 double scale =
TMath::Power((200 * err / result_asc), 1.5) ;
987 err = result_asc * scale ;
1010 const double xgk[],
const double wg[],
const double wgk[],
1011 double fv1[],
double fv2[],
1013 double *
result,
double *abserr,
1014 double *resabs,
double *resasc)
1017 const double center = 0.5 * (a + b);
1018 const double half_length = 0.5 * (b -
a);
1019 const double abs_half_length =
fabs (half_length);
1022 double result_gauss = 0;
1023 double result_kronrod = f_center * wgk[n - 1];
1025 double result_abs =
fabs (result_kronrod);
1026 double result_asc = 0;
1027 double mean = 0, err = 0;
1033 result_gauss = f_center * wg[n / 2 - 1];
1036 for (j = 0; j < (n - 1) / 2; j++)
1038 const int jtw = j * 2 + 1;
1039 const double abscissa = half_length * xgk[jtw];
1040 const double fval1 =
GSL_FN_EVAL (f, center - abscissa);
1041 const double fval2 =
GSL_FN_EVAL (f, center + abscissa);
1042 const double fsum = fval1 + fval2;
1045 result_gauss += wg[j] * fsum;
1046 result_kronrod += wgk[jtw] * fsum;
1047 result_abs += wgk[jtw] * (
fabs (fval1) +
fabs (fval2));
1050 for (j = 0; j < n / 2; j++)
1053 const double abscissa = half_length * xgk[jtwm1];
1054 const double fval1 =
GSL_FN_EVAL (f, center - abscissa);
1055 const double fval2 =
GSL_FN_EVAL (f, center + abscissa);
1058 result_kronrod += wgk[jtwm1] * (fval1 + fval2);
1059 result_abs += wgk[jtwm1] * (
fabs (fval1) +
fabs (fval2));
1062 mean = result_kronrod * 0.5;
1064 result_asc = wgk[n - 1] *
fabs (f_center - mean);
1066 for (j = 0; j < n - 1; j++)
1068 result_asc += wgk[j] * (
fabs (fv1[j] - mean) +
fabs (fv2[j] - mean));
1073 err = (result_kronrod - result_gauss) * half_length;
1075 result_kronrod *= half_length;
1076 result_abs *= abs_half_length;
1077 result_asc *= abs_half_length;
1079 *result = result_kronrod;
1080 *resabs = result_abs;
1081 *resasc = result_asc;
1092 0.991455371120812639206854697526329,
1093 0.949107912342758524526189684047851,
1094 0.864864423359769072789712788640926,
1095 0.741531185599394439863864773280788,
1096 0.586087235467691130294144838258730,
1097 0.405845151377397166906606412076961,
1098 0.207784955007898467600689403773245,
1099 0.000000000000000000000000000000000
1107 0.129484966168869693270611432679082,
1108 0.279705391489276667901467771423780,
1109 0.381830050505118944950369775488975,
1110 0.417959183673469387755102040816327
1115 0.022935322010529224963732008058970,
1116 0.063092092629978553290700663189204,
1117 0.104790010322250183839876322541518,
1118 0.140653259715525918745189590510238,
1119 0.169004726639267902826583426598550,
1120 0.190350578064785409913256402421014,
1121 0.204432940075298892414161999234649,
1122 0.209482141084727828012999174891714
1127 double *
result,
double *abserr,
1128 double *resabs,
double *resasc)
1130 double fv1[8], fv2[8];
1132 gsl_integration_qk (8,
xgkA,
wgA,
wgkA, fv1, fv2, f, a, b, result, abserr, resabs, resasc);
1141 0.995657163025808080735527280689003,
1142 0.973906528517171720077964012084452,
1143 0.930157491355708226001207180059508,
1144 0.865063366688984510732096688423493,
1145 0.780817726586416897063717578345042,
1146 0.679409568299024406234327365114874,
1147 0.562757134668604683339000099272694,
1148 0.433395394129247190799265943165784,
1149 0.294392862701460198131126603103866,
1150 0.148874338981631210884826001129720,
1151 0.000000000000000000000000000000000
1159 0.066671344308688137593568809893332,
1160 0.149451349150580593145776339657697,
1161 0.219086362515982043995534934228163,
1162 0.269266719309996355091226921569469,
1163 0.295524224714752870173892994651338
1168 0.011694638867371874278064396062192,
1169 0.032558162307964727478818972459390,
1170 0.054755896574351996031381300244580,
1171 0.075039674810919952767043140916190,
1172 0.093125454583697605535065465083366,
1173 0.109387158802297641899210590325805,
1174 0.123491976262065851077958109831074,
1175 0.134709217311473325928054001771707,
1176 0.142775938577060080797094273138717,
1177 0.147739104901338491374841515972068,
1178 0.149445554002916905664936468389821
1184 double *
result,
double *abserr,
1185 double *resabs,
double *resasc)
1187 double fv1[11], fv2[11];
1189 gsl_integration_qk (11,
xgkB,
wgB,
wgkB, fv1, fv2, f, a, b, result, abserr, resabs, resasc);
1198 0.998002298693397060285172840152271,
1199 0.987992518020485428489565718586613,
1200 0.967739075679139134257347978784337,
1201 0.937273392400705904307758947710209,
1202 0.897264532344081900882509656454496,
1203 0.848206583410427216200648320774217,
1204 0.790418501442465932967649294817947,
1205 0.724417731360170047416186054613938,
1206 0.650996741297416970533735895313275,
1207 0.570972172608538847537226737253911,
1208 0.485081863640239680693655740232351,
1209 0.394151347077563369897207370981045,
1210 0.299180007153168812166780024266389,
1211 0.201194093997434522300628303394596,
1212 0.101142066918717499027074231447392,
1213 0.000000000000000000000000000000000
1221 0.030753241996117268354628393577204,
1222 0.070366047488108124709267416450667,
1223 0.107159220467171935011869546685869,
1224 0.139570677926154314447804794511028,
1225 0.166269205816993933553200860481209,
1226 0.186161000015562211026800561866423,
1227 0.198431485327111576456118326443839,
1228 0.202578241925561272880620199967519
1233 0.005377479872923348987792051430128,
1234 0.015007947329316122538374763075807,
1235 0.025460847326715320186874001019653,
1236 0.035346360791375846222037948478360,
1237 0.044589751324764876608227299373280,
1238 0.053481524690928087265343147239430,
1239 0.062009567800670640285139230960803,
1240 0.069854121318728258709520077099147,
1241 0.076849680757720378894432777482659,
1242 0.083080502823133021038289247286104,
1243 0.088564443056211770647275443693774,
1244 0.093126598170825321225486872747346,
1245 0.096642726983623678505179907627589,
1246 0.099173598721791959332393173484603,
1247 0.100769845523875595044946662617570,
1248 0.101330007014791549017374792767493
1253 double *
result,
double *abserr,
1254 double *resabs,
double *resasc)
1256 double fv1[16], fv2[16];
1258 gsl_integration_qk (16,
xgkC,
wgC,
wgkC, fv1, fv2, f, a, b, result, abserr, resabs, resasc);
1267 0.998859031588277663838315576545863,
1268 0.993128599185094924786122388471320,
1269 0.981507877450250259193342994720217,
1270 0.963971927277913791267666131197277,
1271 0.940822633831754753519982722212443,
1272 0.912234428251325905867752441203298,
1273 0.878276811252281976077442995113078,
1274 0.839116971822218823394529061701521,
1275 0.795041428837551198350638833272788,
1276 0.746331906460150792614305070355642,
1277 0.693237656334751384805490711845932,
1278 0.636053680726515025452836696226286,
1279 0.575140446819710315342946036586425,
1280 0.510867001950827098004364050955251,
1281 0.443593175238725103199992213492640,
1282 0.373706088715419560672548177024927,
1283 0.301627868114913004320555356858592,
1284 0.227785851141645078080496195368575,
1285 0.152605465240922675505220241022678,
1286 0.076526521133497333754640409398838,
1287 0.000000000000000000000000000000000
1295 0.017614007139152118311861962351853,
1296 0.040601429800386941331039952274932,
1297 0.062672048334109063569506535187042,
1298 0.083276741576704748724758143222046,
1299 0.101930119817240435036750135480350,
1300 0.118194531961518417312377377711382,
1301 0.131688638449176626898494499748163,
1302 0.142096109318382051329298325067165,
1303 0.149172986472603746787828737001969,
1304 0.152753387130725850698084331955098
1309 0.003073583718520531501218293246031,
1310 0.008600269855642942198661787950102,
1311 0.014626169256971252983787960308868,
1312 0.020388373461266523598010231432755,
1313 0.025882133604951158834505067096153,
1314 0.031287306777032798958543119323801,
1315 0.036600169758200798030557240707211,
1316 0.041668873327973686263788305936895,
1317 0.046434821867497674720231880926108,
1318 0.050944573923728691932707670050345,
1319 0.055195105348285994744832372419777,
1320 0.059111400880639572374967220648594,
1321 0.062653237554781168025870122174255,
1322 0.065834597133618422111563556969398,
1323 0.068648672928521619345623411885368,
1324 0.071054423553444068305790361723210,
1325 0.073030690332786667495189417658913,
1326 0.074582875400499188986581418362488,
1327 0.075704497684556674659542775376617,
1328 0.076377867672080736705502835038061,
1329 0.076600711917999656445049901530102
1334 double *
result,
double *abserr,
1335 double *resabs,
double *resasc)
1337 double fv1[21], fv2[21];
1339 gsl_integration_qk (21,
xgkD,
wgD,
wgkD, fv1, fv2, f, a, b, result, abserr, resabs, resasc);
1348 0.999262104992609834193457486540341,
1349 0.995556969790498097908784946893902,
1350 0.988035794534077247637331014577406,
1351 0.976663921459517511498315386479594,
1352 0.961614986425842512418130033660167,
1353 0.942974571228974339414011169658471,
1354 0.920747115281701561746346084546331,
1355 0.894991997878275368851042006782805,
1356 0.865847065293275595448996969588340,
1357 0.833442628760834001421021108693570,
1358 0.797873797998500059410410904994307,
1359 0.759259263037357630577282865204361,
1360 0.717766406813084388186654079773298,
1361 0.673566368473468364485120633247622,
1362 0.626810099010317412788122681624518,
1363 0.577662930241222967723689841612654,
1364 0.526325284334719182599623778158010,
1365 0.473002731445714960522182115009192,
1366 0.417885382193037748851814394594572,
1367 0.361172305809387837735821730127641,
1368 0.303089538931107830167478909980339,
1369 0.243866883720988432045190362797452,
1370 0.183718939421048892015969888759528,
1371 0.122864692610710396387359818808037,
1372 0.061544483005685078886546392366797,
1373 0.000000000000000000000000000000000
1381 0.011393798501026287947902964113235,
1382 0.026354986615032137261901815295299,
1383 0.040939156701306312655623487711646,
1384 0.054904695975835191925936891540473,
1385 0.068038333812356917207187185656708,
1386 0.080140700335001018013234959669111,
1387 0.091028261982963649811497220702892,
1388 0.100535949067050644202206890392686,
1389 0.108519624474263653116093957050117,
1390 0.114858259145711648339325545869556,
1391 0.119455763535784772228178126512901,
1392 0.122242442990310041688959518945852,
1393 0.123176053726715451203902873079050
1398 0.001987383892330315926507851882843,
1399 0.005561932135356713758040236901066,
1400 0.009473973386174151607207710523655,
1401 0.013236229195571674813656405846976,
1402 0.016847817709128298231516667536336,
1403 0.020435371145882835456568292235939,
1404 0.024009945606953216220092489164881,
1405 0.027475317587851737802948455517811,
1406 0.030792300167387488891109020215229,
1407 0.034002130274329337836748795229551,
1408 0.037116271483415543560330625367620,
1409 0.040083825504032382074839284467076,
1410 0.042872845020170049476895792439495,
1411 0.045502913049921788909870584752660,
1412 0.047982537138836713906392255756915,
1413 0.050277679080715671963325259433440,
1414 0.052362885806407475864366712137873,
1415 0.054251129888545490144543370459876,
1416 0.055950811220412317308240686382747,
1417 0.057437116361567832853582693939506,
1418 0.058689680022394207961974175856788,
1419 0.059720340324174059979099291932562,
1420 0.060539455376045862945360267517565,
1421 0.061128509717053048305859030416293,
1422 0.061471189871425316661544131965264,
1423 0.061580818067832935078759824240066
1430 double *
result,
double *abserr,
1431 double *resabs,
double *resasc)
1433 double fv1[26], fv2[26];
1435 gsl_integration_qk (26,
xgkE,
wgE,
wgkE, fv1, fv2, f, a, b, result, abserr, resabs, resasc);
1444 0.999484410050490637571325895705811,
1445 0.996893484074649540271630050918695,
1446 0.991630996870404594858628366109486,
1447 0.983668123279747209970032581605663,
1448 0.973116322501126268374693868423707,
1449 0.960021864968307512216871025581798,
1450 0.944374444748559979415831324037439,
1451 0.926200047429274325879324277080474,
1452 0.905573307699907798546522558925958,
1453 0.882560535792052681543116462530226,
1454 0.857205233546061098958658510658944,
1455 0.829565762382768397442898119732502,
1456 0.799727835821839083013668942322683,
1457 0.767777432104826194917977340974503,
1458 0.733790062453226804726171131369528,
1459 0.697850494793315796932292388026640,
1460 0.660061064126626961370053668149271,
1461 0.620526182989242861140477556431189,
1462 0.579345235826361691756024932172540,
1463 0.536624148142019899264169793311073,
1464 0.492480467861778574993693061207709,
1465 0.447033769538089176780609900322854,
1466 0.400401254830394392535476211542661,
1467 0.352704725530878113471037207089374,
1468 0.304073202273625077372677107199257,
1469 0.254636926167889846439805129817805,
1470 0.204525116682309891438957671002025,
1471 0.153869913608583546963794672743256,
1472 0.102806937966737030147096751318001,
1473 0.051471842555317695833025213166723,
1474 0.000000000000000000000000000000000
1482 0.007968192496166605615465883474674,
1483 0.018466468311090959142302131912047,
1484 0.028784707883323369349719179611292,
1485 0.038799192569627049596801936446348,
1486 0.048402672830594052902938140422808,
1487 0.057493156217619066481721689402056,
1488 0.065974229882180495128128515115962,
1489 0.073755974737705206268243850022191,
1490 0.080755895229420215354694938460530,
1491 0.086899787201082979802387530715126,
1492 0.092122522237786128717632707087619,
1493 0.096368737174644259639468626351810,
1494 0.099593420586795267062780282103569,
1495 0.101762389748405504596428952168554,
1496 0.102852652893558840341285636705415
1501 0.001389013698677007624551591226760,
1502 0.003890461127099884051267201844516,
1503 0.006630703915931292173319826369750,
1504 0.009273279659517763428441146892024,
1505 0.011823015253496341742232898853251,
1506 0.014369729507045804812451432443580,
1507 0.016920889189053272627572289420322,
1508 0.019414141193942381173408951050128,
1509 0.021828035821609192297167485738339,
1510 0.024191162078080601365686370725232,
1511 0.026509954882333101610601709335075,
1512 0.028754048765041292843978785354334,
1513 0.030907257562387762472884252943092,
1514 0.032981447057483726031814191016854,
1515 0.034979338028060024137499670731468,
1516 0.036882364651821229223911065617136,
1517 0.038678945624727592950348651532281,
1518 0.040374538951535959111995279752468,
1519 0.041969810215164246147147541285970,
1520 0.043452539701356069316831728117073,
1521 0.044814800133162663192355551616723,
1522 0.046059238271006988116271735559374,
1523 0.047185546569299153945261478181099,
1524 0.048185861757087129140779492298305,
1525 0.049055434555029778887528165367238,
1526 0.049795683427074206357811569379942,
1527 0.050405921402782346840893085653585,
1528 0.050881795898749606492297473049805,
1529 0.051221547849258772170656282604944,
1530 0.051426128537459025933862879215781,
1531 0.051494729429451567558340433647099
1536 double *
result,
double *abserr,
1537 double *resabs,
double *resasc)
1539 double fv1[31], fv2[31];
1541 gsl_integration_qk (31,
xgkF,
wgF,
wgkF, fv1, fv2, f, a, b, result, abserr, resabs, resasc);
1544 gsl_integration_workspace*
1547 gsl_integration_workspace* w ;
1551 GSL_ERROR_VAL (
"workspace length n must be positive integer",
1555 w = (gsl_integration_workspace *)
1556 malloc (
sizeof (gsl_integration_workspace));
1560 GSL_ERROR_VAL (
"failed to allocate space for workspace struct",
1564 w->alist = (
double *)
malloc (n *
sizeof (
double));
1574 w->blist = (
double *)
malloc (n *
sizeof (
double));
1585 w->rlist = (
double *)
malloc (n *
sizeof (
double));
1598 w->elist = (
double *)
malloc (n *
sizeof (
double));
1611 w->order = (
size_t *)
malloc (n *
sizeof (
size_t));
1625 w->level = (
size_t *)
malloc (n *
sizeof (
size_t));
1642 w->maximum_level = 0 ;
1663 reset_nrmax (gsl_integration_workspace * workspace);
1668 workspace->nrmax = 0;
1669 workspace->i = workspace->order[0] ;
1685 int id = workspace->nrmax;
1688 const size_t * level = workspace->level;
1689 const size_t * order = workspace->order;
1691 size_t limit = workspace->limit ;
1692 size_t last = workspace->size - 1 ;
1694 if (last > (1 + limit / 2))
1696 jupbnd = limit + 1 - last;
1703 for (k =
id; k <= jupbnd; k++)
1705 size_t i_max = order[workspace->nrmax];
1707 workspace->i = i_max ;
1709 if (level[i_max] < workspace->maximum_level)
1723 size_t i = workspace->i ;
1724 const size_t * level = workspace->level;
1726 if (level[i] < workspace->maximum_level)
1738 struct extrapolation_table
1763 table->rlist2[0] =
y;
1772 table->rlist2[
n] =
y;
1782 qelg (
struct extrapolation_table *table,
double *
result,
double *abserr);
1785 qelg (
struct extrapolation_table *table,
double *
result,
double *abserr)
1787 double *epstab = table->rlist2;
1788 double *res3la = table->res3la;
1789 const size_t n = table->n - 1;
1791 const double current = epstab[
n];
1796 const size_t newelm = n / 2;
1797 const size_t n_orig =
n;
1801 const size_t nres_orig = table->nres;
1813 epstab[n + 2] = epstab[
n];
1816 for (i = 0; i < newelm; i++)
1818 double res = epstab[n - 2 * i + 2];
1819 double e0 = epstab[n - 2 * i - 2];
1820 double e1 = epstab[n - 2 * i - 1];
1823 double e1abs =
fabs (e1);
1824 double delta2 = e2 - e1;
1825 double err2 =
fabs (delta2);
1827 double delta3 = e1 - e0;
1828 double err3 =
fabs (delta3);
1831 double e3, delta1, err1, tol1, ss;
1833 if (err2 <= tol2 && err3 <= tol3)
1839 absolute = err2 + err3;
1845 e3 = epstab[n - 2 * i];
1846 epstab[n - 2 * i] = e1;
1848 err1 =
fabs (delta1);
1854 if (err1 <= tol1 || err2 <= tol2 || err3 <= tol3)
1860 ss = (1 / delta1 + 1 / delta2) - 1 / delta3;
1866 if (fabs (ss * e1) <= 0.0001)
1876 epstab[n - 2 * i] = res;
1879 const double error = err2 +
fabs (res - e2) + err3;
1881 if (error <= *abserr)
1892 const size_t limexp = 50 - 1;
1894 if (n_final == limexp)
1896 n_final = 2 * (limexp / 2);
1900 if (n_orig % 2 == 1)
1902 for (i = 0; i <= newelm; i++)
1904 epstab[1 + i * 2] = epstab[i * 2 + 3];
1909 for (i = 0; i <= newelm; i++)
1911 epstab[i * 2] = epstab[i * 2 + 2];
1915 if (n_orig != n_final)
1917 for (i = 0; i <= n_final; i++)
1919 epstab[i] = epstab[n_orig - n_final + i];
1923 table->n = n_final + 1;
1927 res3la[nres_orig] = *
result;
1932 *abserr = (
fabs (*result - res3la[2]) +
fabs (*result - res3la[1])
1933 +
fabs (*result - res3la[0]));
1935 res3la[0] = res3la[1];
1936 res3la[1] = res3la[2];
1946 table->nres = nres_orig + 1;
1970 b,
const double epsabs,
const double epsrel,
const size_t limit,
1971 gsl_integration_workspace * workspace,
double *
result,
double *abserr,
1977 double epsabs,
double epsrel,
size_t limit,
1978 gsl_integration_workspace * workspace,
1979 double *
result,
double * abserr)
1981 int status =
qags (f, a, b, epsabs, epsrel, limit,
1995 static double i_transform (
double t,
void *params);
1999 double epsabs,
double epsrel,
size_t limit,
2000 gsl_integration_workspace * workspace,
2001 double *
result,
double *abserr)
2008 f_transform.params =
f;
2010 status =
qags (&f_transform, 0.0, 1.0,
2011 epsabs, epsrel, limit,
2023 double x = (1 - t) / t;
2043 double epsabs,
double epsrel,
size_t limit,
2044 gsl_integration_workspace * workspace,
2045 double *
result,
double *abserr)
2050 struct il_params transform_params ;
2052 transform_params.b = b ;
2053 transform_params.f =
f ;
2056 f_transform.params = &transform_params;
2058 status =
qags (&f_transform, 0.0, 1.0,
2059 epsabs, epsrel, limit,
2070 struct il_params *p = (
struct il_params *) params;
2073 double x = b - (1 - t) / t;
2092 double epsabs,
double epsrel,
size_t limit,
2093 gsl_integration_workspace * workspace,
2094 double *
result,
double *abserr)
2099 struct iu_params transform_params ;
2101 transform_params.a =
a ;
2102 transform_params.f =
f ;
2105 f_transform.params = &transform_params;
2107 status =
qags (&f_transform, 0.0, 1.0,
2108 epsabs, epsrel, limit,
2119 struct iu_params *p = (
struct iu_params *) params;
2122 double x = a + (1 - t) / t;
2131 const double a,
const double b,
2132 const double epsabs,
const double epsrel,
2134 gsl_integration_workspace * workspace,
2135 double *
result,
double *abserr,
2138 double area, errsum;
2139 double res_ext, err_ext;
2140 double result0, abserr0, resabs0, resasc0;
2144 double error_over_large_intervals = 0;
2145 double reseps = 0, abseps = 0, correc = 0;
2147 int roundoff_type1 = 0, roundoff_type2 = 0, roundoff_type3 = 0;
2148 int error_type = 0, error_type2 = 0;
2150 size_t iteration = 0;
2152 int positive_integrand = 0;
2153 int extrapolate = 0;
2154 int disallow_extrapolation = 0;
2156 struct extrapolation_table table;
2165 if (limit > workspace->limit)
2172 if (epsabs <= 0 && (epsrel < 50 *
GSL_DBL_EPSILON || epsrel < 0.5e-28))
2174 GSL_ERROR (
"tolerance cannot be acheived with given epsabs and epsrel",
2180 q (f, a, b, &result0, &abserr0, &resabs0, &resasc0);
2186 if (abserr0 <= 100 * GSL_DBL_EPSILON * resabs0 && abserr0 > tolerance)
2191 GSL_ERROR (
"cannot reach tolerance because of roundoff error"
2194 else if ((abserr0 <= tolerance && abserr0 != resasc0) || abserr0 == 0.0)
2201 else if (limit == 1)
2226 size_t current_level;
2227 double a1, b1, a2, b2;
2228 double a_i, b_i, r_i, e_i;
2229 double area1 = 0, area2 = 0, area12 = 0;
2230 double error1 = 0, error2 = 0, error12 = 0;
2231 double resasc1, resasc2;
2232 double resabs1, resabs2;
2237 retrieve (workspace, &a_i, &b_i, &r_i, &e_i);
2239 current_level = workspace->level[workspace->i] + 1;
2242 b1 = 0.5 * (a_i + b_i);
2248 q (f, a1, b1, &area1, &error1, &resabs1, &resasc1);
2249 q (f, a2, b2, &area2, &error2, &resabs2, &resasc2);
2251 area12 = area1 + area2;
2252 error12 = error1 + error2;
2262 errsum = errsum + error12 - e_i;
2263 area = area + area12 - r_i;
2267 if (resasc1 != error1 && resasc2 != error2)
2269 double delta = r_i - area12;
2271 if (
fabs (delta) <= 1.0e-5 *
fabs (area12) && error12 >= 0.99 * e_i)
2282 if (iteration > 10 && error12 > e_i)
2290 if (roundoff_type1 + roundoff_type2 >= 10 || roundoff_type3 >= 20)
2295 if (roundoff_type2 >= 5)
2310 update (workspace, a1, b1, area1, error1, a2, b2, area2, error2);
2312 if (errsum <= tolerance)
2314 goto compute_result;
2322 if (iteration >= limit - 1)
2330 error_over_large_intervals = errsum;
2336 if (disallow_extrapolation)
2341 error_over_large_intervals += -last_e_i;
2343 if (current_level < workspace->maximum_level)
2345 error_over_large_intervals += error12;
2357 workspace->nrmax = 1;
2360 if (!error_type2 && error_over_large_intervals > ertest)
2370 qelg (&table, &reseps, &abseps);
2374 if (ktmin > 5 && err_ext < 0.001 * errsum)
2379 if (abseps < err_ext)
2384 correc = error_over_large_intervals;
2386 if (err_ext <= ertest)
2394 disallow_extrapolation = 1;
2397 if (error_type == 5)
2406 error_over_large_intervals = errsum;
2409 while (iteration < limit);
2415 goto compute_result;
2417 if (error_type || error_type2)
2427 if (res_ext != 0.0 && area != 0.0)
2429 if (err_ext /
fabs (res_ext) > errsum /
fabs (area))
2430 goto compute_result;
2432 else if (err_ext > errsum)
2434 goto compute_result;
2436 else if (area == 0.0)
2447 if (!positive_integrand && max_area < 0.01 * resabs0)
2452 double ratio = res_ext / area;
2454 if (ratio < 0.01 || ratio > 100.0 || errsum >
fabs (area))
2472 if (error_type == 0)
2476 else if (error_type == 1)
2480 else if (error_type == 2)
2482 GSL_ERROR (
"cannot reach tolerance because of roundoff error",
2485 else if (error_type == 3)
2487 GSL_ERROR (
"bad integrand behavior found in the integration interval",
2490 else if (error_type == 4)
2492 GSL_ERROR (
"roundoff error detected in the extrapolation table",
2495 else if (error_type == 5)
2497 GSL_ERROR (
"integral is divergent, or slowly convergent",
static double sum_results(const gsl_integration_workspace *workspace)
static const double xgkC[16]
static double il_transform(double t, void *params)
double gsl_coerce_double(const double x)
static const double wgF[15]
int gsl_integration_qagiu(gsl_function *f, double a, double epsabs, double epsrel, size_t limit, gsl_integration_workspace *workspace, double *result, double *abserr)
virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE)
Set value by specifying the index code of the desired state.
Double_t _epsAbs
Current coordinate.
double RooAdaptiveGaussKronrodIntegrator1D_GSL_GlueFunction(double x, void *data)
Glue function interacing to GSL code.
static const double wgkB[11]
static const double wgkD[21]
static Int_t isInfinite(Double_t x)
Return true if x is infinite by RooNumBer internal specification.
UInt_t getDimension() const
void gsl_integration_qk51(const gsl_function *f, double a, double b, double *result, double *abserr, double *resabs, double *resasc)
int gsl_integration_qag(const gsl_function *f, double a, double b, double epsabs, double epsrel, size_t limit, int key, gsl_integration_workspace *workspace, double *result, double *abserr)
static void qelg(struct extrapolation_table *table, double *result, double *abserr)
static void retrieve(const gsl_integration_workspace *workspace, double *a, double *b, double *r, double *e)
static void append_table(struct extrapolation_table *table, double y)
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
static const double wgkC[16]
static const double wgkA[8]
Vc_ALWAYS_INLINE void free(T *p)
Frees memory that was allocated with Vc::malloc.
static const double wgA[4]
void gsl_integration_rule(const gsl_function *f, double a, double b, double *result, double *abserr, double *defabs, double *resabs)
int gsl_integration_qags(const gsl_function *f, double a, double b, double epsabs, double epsrel, size_t limit, gsl_integration_workspace *workspace, double *result, double *abserr)
#define GSL_FN_EVAL(F, x)
static int subinterval_too_small(double a1, double a2, double b2)
static int increase_nrmax(gsl_integration_workspace *workspace)
#define GSL_ERROR_VAL(reason, gsl_errno, value)
#define GSL_COERCE_DBL(x)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
void function(const char *name_, T fun, const char *docstring=0)
virtual ~RooAdaptiveGaussKronrodIntegrator1D()
Destructor.
static void reset_nrmax(gsl_integration_workspace *workspace)
static int large_interval(gsl_integration_workspace *workspace)
void gsl_integration_workspace_free(gsl_integration_workspace *w)
Int_t getCatIndex(const char *name, Int_t defVal=0, Bool_t verbose=kFALSE) const
Get index value of a RooAbsCategory stored in set with given name.
void gsl_integration_qcheb(gsl_function *f, double a, double b, double *cheb12, double *cheb24)
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
Double_t * xvec(Double_t &xx)
static void qpsrt(gsl_integration_workspace *workspace)
virtual Bool_t checkLimits() const
Check that our integration range is finite and otherwise return kFALSE.
const RooAbsFunc * _function
static const double wgkE[26]
void gsl_integration_qk(const int n, const double xgk[], const double wg[], const double wgk[], double fv1[], double fv2[], const gsl_function *f, double a, double b, double *result, double *abserr, double *resabs, double *resasc)
virtual Double_t getMinLimit(UInt_t dimension) const =0
Bool_t setLimits(Double_t *xmin, Double_t *xmax)
Change our integration limits.
void gsl_integration_qk41(const gsl_function *f, double a, double b, double *result, double *abserr, double *resabs, double *resasc)
void gsl_integration_qk61(const gsl_function *f, double a, double b, double *result, double *abserr, double *resabs, double *resasc)
static void initialise_table(struct extrapolation_table *table)
Double_t integrand(const Double_t x[]) const
double GSL_MAX_DBL(double a, double b)
static void initialise(gsl_integration_workspace *workspace, double a, double b)
static void set_initial_result(gsl_integration_workspace *workspace, double result, double error)
Bool_t _useIntegrandLimits
static const double wgB[5]
struct gsl_function_struct gsl_function
virtual Double_t getMaxLimit(UInt_t dimension) const =0
virtual const char * GetName() const
Returns name of object.
static double iu_transform(double t, void *params)
static int test_positivity(double result, double resabs)
static int qag(const gsl_function *f, const double a, const double b, const double epsabs, const double epsrel, const size_t limit, gsl_integration_workspace *workspace, double *result, double *abserr, gsl_integration_rule *q)
virtual RooAbsIntegrator * clone(const RooAbsFunc &function, const RooNumIntConfig &config) const
Virtual constructor.
virtual Double_t integral(const Double_t *yvec=0)
Calculate and return integral at at given parameter values.
static const double wgE[13]
int gsl_integration_qagil(gsl_function *f, double b, double epsabs, double epsrel, size_t limit, gsl_integration_workspace *workspace, double *result, double *abserr)
static const double wgC[8]
static const double xgkD[21]
static int qags(const gsl_function *f, const double a, const double b, const double epsabs, const double epsrel, const size_t limit, gsl_integration_workspace *workspace, double *result, double *abserr, gsl_integration_rule *q)
ClassImp(RooAdaptiveGaussKronrodIntegrator1D)
static const double xgkE[26]
const RooAbsFunc * integrand() const
static const double xgkB[11]
void gsl_integration_qk21(const gsl_function *f, double a, double b, double *result, double *abserr, double *resabs, double *resasc)
static void registerIntegrator(RooNumIntFactory &fact)
Register this class with RooNumIntConfig as a possible choice of numeric integrator for one-dimension...
void gsl_integration_qk31(const gsl_function *f, double a, double b, double *result, double *abserr, double *resabs, double *resasc)
friend double RooAdaptiveGaussKronrodIntegrator1D_GSL_GlueFunction(double x, void *data)
Glue function interacing to GSL code.
static const double xgkF[31]
int gsl_integration_qagi(gsl_function *f, double epsabs, double epsrel, size_t limit, gsl_integration_workspace *workspace, double *result, double *abserr)
Bool_t defineType(const char *label)
Define a state with given name, the lowest available positive integer is assigned as index...
static const double xgkA[8]
static double i_transform(double t, void *params)
void gsl_integration_qk15(const gsl_function *f, double a, double b, double *result, double *abserr, double *resabs, double *resasc)
static const double wgD[11]
Vc_ALWAYS_INLINE_L T *Vc_ALWAYS_INLINE_R malloc(size_t n)
Allocates memory on the Heap with alignment and padding suitable for vectorized access.
const RooArgSet & getConfigSection(const char *name) const
Retrieve configuration information specific to integrator with given name.
gsl_integration_workspace * gsl_integration_workspace_alloc(const size_t n)
static const double wgkF[31]
static double rescale_error(double err, const double result_abs, const double result_asc)
Bool_t storeProtoIntegrator(RooAbsIntegrator *proto, const RooArgSet &defConfig, const char *depName="")
Method accepting registration of a prototype numeric integrator along with a RooArgSet of its default...
Double_t _xmax
Lower integration bound.
Double_t getRealValue(const char *name, Double_t defVal=0, Bool_t verbose=kFALSE) const
Get value of a RooAbsReal stored in set with given name.
RooAdaptiveGaussKronrodIntegrator1D()
coverity[UNINIT_CTOR] Default constructor
Bool_t initialize()
Initialize integrator allocate buffers and setup GSL workspace.