1 #ifndef HAVE_INTEGRATE_HPP 2 #define HAVE_INTEGRATE_HPP 16 return TMBad::Value(x);
18 double value(
double x);
19 template <
class S,
class T>
21 return (x < y) ? x : y;
23 template <
class S,
class T>
24 double fmin2(S x, T y) {
27 template <
class S,
class T>
28 double fmax2(S x, T y) {
31 template <
class Float,
class integr_fn>
32 static void rdqagie(integr_fn f,
void *ex, Float *,
int *, Float *, Float *,
33 int *, Float *, Float *,
int *,
int *, Float *, Float *,
34 Float *, Float *,
int *,
int *);
36 template <
class Float,
class integr_fn>
37 static void rdqk15i(integr_fn f,
void *ex, Float *,
int *, Float *, Float *,
38 Float *, Float *, Float *, Float *);
40 template <
class Float,
class integr_fn>
41 static void rdqagse(integr_fn f,
void *ex, Float *, Float *, Float *, Float *,
42 int *, Float *, Float *,
int *,
int *, Float *, Float *,
43 Float *, Float *,
int *,
int *);
45 template <
class Float,
class integr_fn>
46 static void rdqk21(integr_fn f,
void *ex, Float *, Float *, Float *, Float *,
49 template <
class Float>
50 static void rdqpsrt(
int *,
int *,
int *, Float *, Float *,
int *,
int *);
52 template <
class Float>
53 static void rdqelg(
int *, Float *, Float *, Float *, Float *,
int *);
55 template <
class Float,
class integr_fn>
56 void Rdqagi(integr_fn f,
void *ex, Float *bound,
int *inf, Float *epsabs,
57 Float *epsrel, Float *result, Float *abserr,
int *neval,
int *ier,
58 int *limit,
int *lenw,
int *last,
int *iwork, Float *work) {
65 if (*limit < 1 || *lenw < *limit << 2)
return;
71 rdqagie(f, ex, bound, inf, epsabs, epsrel, limit, result, abserr, neval, ier,
72 work, &work[l1], &work[l2], &work[l3], iwork, last);
77 template <
class Float,
class integr_fn>
78 static void rdqagie(integr_fn f,
void *ex, Float *bound,
int *inf,
79 Float *epsabs, Float *epsrel,
int *limit, Float *result,
80 Float *abserr,
int *neval,
int *ier, Float *alist,
81 Float *blist, Float *rlist, Float *elist,
int *iord,
87 Float area1, area2, area12;
89 Float small = 0.0, erro12;
91 Float a1, a2, b1, b2, defab1, defab2, oflow;
95 int iroff1, iroff2, iroff3;
96 Float res3la[3], error1, error2;
100 Float defabs, epmach, erlarg = 0.0, abseps, correc = 0.0, errbnd, resabs;
102 Float erlast, errmax;
106 Float ertest = 0.0, errsum;
113 epmach = DBL_EPSILON;
125 if (*epsabs <= 0. && (*epsrel < fmax2(epmach * 50., 5e-29))) *ier = 6;
126 if (*ier == 6)
return;
132 static Float c_b6 = 0.;
133 static Float c_b7 = 1.;
135 rdqk15i(f, ex, &boun, inf, &c_b6, &c_b7, result, abserr, &defabs, &resabs);
141 dres = fabs(*result);
142 errbnd = fmax2(*epsabs, *epsrel * dres);
143 if (*abserr <= epmach * 100. * defabs && *abserr > errbnd) *ier = 2;
144 if (*limit == 1) *ier = 1;
145 if (*ier != 0 || (*abserr <= errbnd && *abserr != resabs) || *abserr == 0.)
167 if (dres >= (1. - epmach * 50.) * defabs) {
171 for (*last = 2; *last <= *limit; ++(*last)) {
173 b1 = (alist[maxerr] + blist[maxerr]) * .5;
177 rdqk15i(f, ex, &boun, inf, &a1, &b1, &area1, &error1, &resabs, &defab1);
178 rdqk15i(f, ex, &boun, inf, &a2, &b2, &area2, &error2, &resabs, &defab2);
180 area12 = area1 + area2;
181 erro12 = error1 + error2;
182 errsum = errsum + erro12 - errmax;
183 area = area + area12 - rlist[maxerr];
184 if (!(defab1 == error1 || defab2 == error2)) {
185 if (fabs(rlist[maxerr] - area12) <= fabs(area12) * 1e-5 &&
186 erro12 >= errmax * .99) {
192 if (*last > 10 && erro12 > errmax) ++iroff3;
195 rlist[maxerr] = area1;
196 rlist[*last] = area2;
197 errbnd = fmax2(*epsabs, *epsrel * fabs(area));
199 if (iroff1 + iroff2 >= 10 || iroff3 >= 20) *ier = 2;
200 if (iroff2 >= 5) ierro = 3;
202 if (*last == *limit) *ier = 1;
204 if (fmax2(fabs(a1), fabs(b2)) <=
205 (epmach * 100. + 1.) * (fabs(a2) + uflow * 1e3)) {
209 if (error2 <= error1) {
213 elist[maxerr] = error1;
214 elist[*last] = error2;
219 rlist[maxerr] = area2;
220 rlist[*last] = area1;
221 elist[maxerr] = error2;
222 elist[*last] = error1;
225 rdqpsrt(limit, last, &maxerr, &errmax, &elist[1], &iord[1], &nrmax);
226 if (errsum <= errbnd) {
229 if (*ier != 0)
break;
240 if (fabs(b1 - a1) > small) {
244 if (fabs(blist[maxerr] - alist[maxerr]) > small) {
251 if (ierro != 3 && erlarg > ertest) {
254 if (*last > *limit / 2 + 2) {
255 jupbnd = *limit + 3 - *last;
257 for (k =
id; k <= jupbnd; ++k) {
258 maxerr = iord[nrmax];
259 errmax = elist[maxerr];
260 if (fabs(blist[maxerr] - alist[maxerr]) > small) {
268 rlist2[numrl2 - 1] = area;
269 rdqelg(&numrl2, rlist2, &reseps, &abseps, res3la, &nres);
271 if (ktmin > 5 && *abserr < errsum * .001) {
274 if (abseps >= *abserr) {
281 ertest = fmax2(*epsabs, *epsrel * fabs(reseps));
282 if (*abserr <= ertest) {
294 errmax = elist[maxerr];
302 if (*abserr == oflow) {
305 if (*ier + ierro == 0) {
314 if (*result == 0. || area == 0.) {
315 if (*abserr > errsum)
goto L115;
317 if (area == 0.)
goto L130;
319 if (*abserr / fabs(*result) > errsum / fabs(area)) {
325 if (ksgn == -1 && fmax2(fabs(*result), fabs(area)) <= defabs * .01) {
328 if (.01 > *result / area || *result / area > 100. || errsum > fabs(area)) {
335 for (k = 1; k <= *last; ++k) *result += rlist[k];
339 *neval = *last * 30 - 15;
349 template <
class Float,
class integr_fn>
350 void Rdqags(integr_fn f,
void *ex, Float *a, Float *b, Float *epsabs,
351 Float *epsrel, Float *result, Float *abserr,
int *neval,
int *ier,
352 int *limit,
int *lenw,
int *last,
int *iwork, Float *work) {
359 if (*limit < 1 || *lenw < *limit * 4)
return;
365 rdqagse(f, ex, a, b, epsabs, epsrel, limit, result, abserr, neval, ier, work,
366 &work[l1], &work[l2], &work[l3], iwork, last);
371 template <
class Float,
class integr_fn>
372 static void rdqagse(integr_fn f,
void *ex, Float *a, Float *b, Float *epsabs,
373 Float *epsrel,
int *limit, Float *result, Float *abserr,
374 int *neval,
int *ier, Float *alist, Float *blist,
375 Float *rlist, Float *elist,
int *iord,
int *last) {
380 int iroff1, iroff2, iroff3;
387 Float abseps, area, area1, area2, area12, dres, epmach;
388 Float a1, a2, b1, b2, defabs, defab1, defab2, oflow, uflow, resabs, reseps;
389 Float error1, error2, erro12, errbnd, erlast, errmax, errsum;
391 Float correc = 0.0, erlarg = 0.0, ertest = 0.0, small = 0.0;
398 epmach = DBL_EPSILON;
409 if (*epsabs <= 0. && *epsrel < fmax2(epmach * 50., 5e-29)) {
417 rdqk21(f, ex, a, b, result, abserr, &defabs, &resabs);
419 dres = fabs(*result);
420 errbnd = fmax2(*epsabs, *epsrel * dres);
425 if (*abserr <= epmach * 100. * defabs && *abserr > errbnd) *ier = 2;
426 if (*limit == 1) *ier = 1;
427 if (*ier != 0 || (*abserr <= errbnd && *abserr != resabs) || *abserr == 0.)
446 if (dres >= (1. - epmach * 50.) * defabs) {
450 for (*last = 2; *last <= *limit; ++(*last)) {
452 b1 = (alist[maxerr] + blist[maxerr]) * .5;
456 rdqk21(f, ex, &a1, &b1, &area1, &error1, &resabs, &defab1);
457 rdqk21(f, ex, &a2, &b2, &area2, &error2, &resabs, &defab2);
459 area12 = area1 + area2;
460 erro12 = error1 + error2;
461 errsum = errsum + erro12 - errmax;
462 area = area + area12 - rlist[maxerr];
463 if (!(defab1 == error1 || defab2 == error2)) {
464 if (fabs(rlist[maxerr] - area12) <= fabs(area12) * 1e-5 &&
465 erro12 >= errmax * .99) {
471 if (*last > 10 && erro12 > errmax) ++iroff3;
473 rlist[maxerr] = area1;
474 rlist[*last] = area2;
475 errbnd = fmax2(*epsabs, *epsrel * fabs(area));
477 if (iroff1 + iroff2 >= 10 || iroff3 >= 20) *ier = 2;
478 if (iroff2 >= 5) ierro = 3;
480 if (*last == *limit) *ier = 1;
482 if (fmax2(fabs(a1), fabs(b2)) <=
483 (epmach * 100. + 1.) * (fabs(a2) + uflow * 1e3)) {
487 if (error2 > error1) {
491 rlist[maxerr] = area2;
492 rlist[*last] = area1;
493 elist[maxerr] = error2;
494 elist[*last] = error1;
499 elist[maxerr] = error1;
500 elist[*last] = error2;
503 rdqpsrt(limit, last, &maxerr, &errmax, &elist[1], &iord[1], &nrmax);
505 if (errsum <= errbnd)
goto L115;
506 if (*ier != 0)
break;
508 small = fabs(*b - *a) * .375;
517 if (fabs(b1 - a1) > small) {
521 if (fabs(blist[maxerr] - alist[maxerr]) > small) {
528 if (ierro != 3 && erlarg > ertest) {
531 if (*last > *limit / 2 + 2) {
532 jupbnd = *limit + 3 - *last;
534 for (k =
id; k <= jupbnd; ++k) {
535 maxerr = iord[nrmax];
536 errmax = elist[maxerr];
537 if (fabs(blist[maxerr] - alist[maxerr]) > small) {
545 rlist2[numrl2 - 1] = area;
546 rdqelg(&numrl2, rlist2, &reseps, &abseps, res3la, &nres);
548 if (ktmin > 5 && *abserr < errsum * .001) {
551 if (abseps < *abserr) {
556 ertest = fmax2(*epsabs, *epsrel * fabs(reseps));
557 if (*abserr <= ertest) {
569 errmax = elist[maxerr];
577 if (*abserr == oflow)
goto L115;
578 if (*ier + ierro == 0)
goto L110;
579 if (ierro == 3) *abserr += correc;
580 if (*ier == 0) *ier = 3;
581 if (*result == 0. || area == 0.) {
582 if (*abserr > errsum)
goto L115;
583 if (area == 0.)
goto L130;
585 if (*abserr / fabs(*result) > errsum / fabs(area))
goto L115;
589 if (ksgn == -1 && fmax2(fabs(*result), fabs(area)) <= defabs * .01) {
592 if (.01 > *result / area || *result / area > 100. || errsum > fabs(area)) {
599 for (k = 1; k <= *last; ++k) *result += rlist[k];
604 *neval = *last * 42 - 21;
608 template <
class Float,
class integr_fn>
609 static void rdqk15i(integr_fn f,
void *ex, Float *boun,
int *inf, Float *a,
610 Float *b, Float *result, Float *abserr, Float *resabs,
612 static double wg[8] = {0., .129484966168869693270611432679082,
613 0., .27970539148927666790146777142378,
614 0., .381830050505118944950369775488975,
615 0., .417959183673469387755102040816327};
616 static double xgk[8] = {
617 .991455371120812639206854697526329, .949107912342758524526189684047851,
618 .864864423359769072789712788640926, .741531185599394439863864773280788,
619 .58608723546769113029414483825873, .405845151377397166906606412076961,
620 .207784955007898467600689403773245, 0.};
621 static double wgk[8] = {
622 .02293532201052922496373200805897, .063092092629978553290700663189204,
623 .104790010322250183839876322541518, .140653259715525918745189590510238,
624 .16900472663926790282658342659855, .190350578064785409913256402421014,
625 .204432940075298892414161999234649, .209482141084727828012999174891714};
627 Float absc, dinf, resg, resk, fsum, absc1, absc2, fval1, fval2;
629 Float hlgth, centr, reskh, uflow;
630 Float tabsc1, tabsc2, fc, epmach;
631 Float fv1[7], fv2[7], vec[15], vec2[15];
632 epmach = DBL_EPSILON;
634 dinf = (double)imin2(1, *inf);
636 centr = (*a + *b) * .5;
637 hlgth = (*b - *a) * .5;
638 tabsc1 = *boun + dinf * (1. - centr) / centr;
643 for (j = 1; j <= 7; ++j) {
644 absc = hlgth * xgk[j - 1];
645 absc1 = centr - absc;
646 absc2 = centr + absc;
647 tabsc1 = *boun + dinf * (1. - absc1) / absc1;
648 tabsc2 = *boun + dinf * (1. - absc2) / absc2;
649 vec[(j << 1) - 1] = tabsc1;
652 vec2[(j << 1) - 1] = -tabsc1;
653 vec2[j * 2] = -tabsc2;
657 if (*inf == 2) f(vec2, 15, ex);
659 if (*inf == 2) fval1 += vec2[0];
660 fc = fval1 / centr / centr;
664 *resabs = fabs(resk);
665 for (j = 1; j <= 7; ++j) {
666 absc = hlgth * xgk[j - 1];
667 absc1 = centr - absc;
668 absc2 = centr + absc;
669 tabsc1 = *boun + dinf * (1. - absc1) / absc1;
670 tabsc2 = *boun + dinf * (1. - absc2) / absc2;
671 fval1 = vec[(j << 1) - 1];
674 fval1 += vec2[(j << 1) - 1];
677 fval2 += vec2[j * 2];
679 fval1 = fval1 / absc1 / absc1;
680 fval2 = fval2 / absc2 / absc2;
683 fsum = fval1 + fval2;
684 resg += wg[j - 1] * fsum;
685 resk += wgk[j - 1] * fsum;
686 *resabs += wgk[j - 1] * (fabs(fval1) + fabs(fval2));
689 *resasc = wgk[7] * fabs(fc - reskh);
690 for (j = 1; j <= 7; ++j) {
692 wgk[j - 1] * (fabs(fv1[j - 1] - reskh) + fabs(fv2[j - 1] - reskh));
694 *result = resk * hlgth;
697 *abserr = fabs((resk - resg) * hlgth);
698 if (*resasc != 0. && *abserr != 0.) {
699 *abserr = *resasc * fmin2(1., pow(*abserr * 200. / *resasc, 1.5));
701 if (*resabs > uflow / (epmach * 50.)) {
702 *abserr = fmax2(epmach * 50. * *resabs, *abserr);
707 template <
class Float>
708 static void rdqelg(
int *n, Float *epstab, Float *result, Float *abserr,
709 Float *res3la,
int *nres) {
710 int i__, indx, ib, ib2, ie, k1, k2, k3, num, newelm, limexp;
711 Float delta1, delta2, delta3, e0, e1, e1abs, e2, e3, epmach, epsinf;
712 Float oflow, ss, res;
713 Float errA, err1, err2, err3, tol1, tol2, tol3;
717 epmach = DBL_EPSILON;
721 *result = epstab[*n];
726 epstab[*n + 2] = epstab[*n];
727 newelm = (*n - 1) / 2;
731 for (i__ = 1; i__ <= newelm; ++i__) {
734 res = epstab[k1 + 2];
741 tol2 = fmax2(fabs(e2), e1abs) * epmach;
744 tol3 = fmax2(e1abs, fabs(e0)) * epmach;
745 if (err2 <= tol2 && err3 <= tol3) {
747 *abserr = err2 + err3;
756 tol1 = fmax2(e1abs, fabs(e3)) * epmach;
758 if (err1 > tol1 && err2 > tol2 && err3 > tol3) {
759 ss = 1. / delta1 + 1. / delta2 - 1. / delta3;
760 epsinf = fabs(ss * e1);
775 errA = err2 + fabs(res - e2) + err3;
776 if (errA <= *abserr) {
784 *n = (limexp / 2 << 1) - 1;
787 if (num / 2 << 1 == num)
792 for (i__ = 1; i__ <= ie; ++i__) {
794 epstab[ib] = epstab[ib2];
799 for (i__ = 1; i__ <= *n; ++i__) {
800 epstab[i__] = epstab[indx];
806 *abserr = fabs(*result - res3la[3]) + fabs(*result - res3la[2]) +
807 fabs(*result - res3la[1]);
808 res3la[1] = res3la[2];
809 res3la[2] = res3la[3];
812 res3la[*nres] = *result;
817 *abserr = fmax2(*abserr, epmach * 5. * fabs(*result));
821 template <
class Float,
class integr_fn>
822 static void rdqk21(integr_fn f,
void *ex, Float *a, Float *b, Float *result,
823 Float *abserr, Float *resabs, Float *resasc) {
824 static double wg[5] = {
825 .066671344308688137593568809893332, .149451349150580593145776339657697,
826 .219086362515982043995534934228163, .269266719309996355091226921569469,
827 .295524224714752870173892994651338};
828 static double xgk[11] = {.995657163025808080735527280689003,
829 .973906528517171720077964012084452,
830 .930157491355708226001207180059508,
831 .865063366688984510732096688423493,
832 .780817726586416897063717578345042,
833 .679409568299024406234327365114874,
834 .562757134668604683339000099272694,
835 .433395394129247190799265943165784,
836 .294392862701460198131126603103866,
837 .14887433898163121088482600112972,
839 static double wgk[11] = {
840 .011694638867371874278064396062192, .03255816230796472747881897245939,
841 .05475589657435199603138130024458, .07503967481091995276704314091619,
842 .093125454583697605535065465083366, .109387158802297641899210590325805,
843 .123491976262065851077958109831074, .134709217311473325928054001771707,
844 .142775938577060080797094273138717, .147739104901338491374841515972068,
845 .149445554002916905664936468389821};
847 Float fv1[10], fv2[10], vec[21];
848 Float absc, resg, resk, fsum, fval1, fval2;
849 Float hlgth, centr, reskh, uflow;
850 Float fc, epmach, dhlgth;
852 epmach = DBL_EPSILON;
855 centr = (*a + *b) * .5;
856 hlgth = (*b - *a) * .5;
857 dhlgth = fabs(hlgth);
861 for (j = 1; j <= 5; ++j) {
863 absc = hlgth * xgk[jtw - 1];
864 vec[(j << 1) - 1] = centr - absc;
866 vec[j * 2] = centr + absc;
868 for (j = 1; j <= 5; ++j) {
869 jtwm1 = (j << 1) - 1;
870 absc = hlgth * xgk[jtwm1 - 1];
871 vec[(j << 1) + 9] = centr - absc;
872 vec[(j << 1) + 10] = centr + absc;
877 *resabs = fabs(resk);
878 for (j = 1; j <= 5; ++j) {
880 absc = hlgth * xgk[jtw - 1];
881 fval1 = vec[(j << 1) - 1];
883 fv1[jtw - 1] = fval1;
884 fv2[jtw - 1] = fval2;
885 fsum = fval1 + fval2;
886 resg += wg[j - 1] * fsum;
887 resk += wgk[jtw - 1] * fsum;
888 *resabs += wgk[jtw - 1] * (fabs(fval1) + fabs(fval2));
890 for (j = 1; j <= 5; ++j) {
891 jtwm1 = (j << 1) - 1;
892 absc = hlgth * xgk[jtwm1 - 1];
893 fval1 = vec[(j << 1) + 9];
894 fval2 = vec[(j << 1) + 10];
895 fv1[jtwm1 - 1] = fval1;
896 fv2[jtwm1 - 1] = fval2;
897 fsum = fval1 + fval2;
898 resk += wgk[jtwm1 - 1] * fsum;
899 *resabs += wgk[jtwm1 - 1] * (fabs(fval1) + fabs(fval2));
902 *resasc = wgk[10] * fabs(fc - reskh);
903 for (j = 1; j <= 10; ++j) {
905 wgk[j - 1] * (fabs(fv1[j - 1] - reskh) + fabs(fv2[j - 1] - reskh));
907 *result = resk * hlgth;
910 *abserr = fabs((resk - resg) * hlgth);
911 if (*resasc != 0. && *abserr != 0.) {
912 *abserr = *resasc * fmin2(1., pow(*abserr * 200. / *resasc, 1.5));
914 if (*resabs > uflow / (epmach * 50.)) {
915 *abserr = fmax2(epmach * 50. * *resabs, *abserr);
920 template <
class Float>
921 static void rdqpsrt(
int *limit,
int *last,
int *maxerr, Float *ermax,
922 Float *elist,
int *iord,
int *nrmax) {
923 int i, j, k, ido, jbnd, isucc, jupbn;
924 Float errmin, errmax;
934 errmax = elist[*maxerr];
937 for (i = 1; i <= ido; ++i) {
938 isucc = iord[*nrmax - 1];
939 if (errmax <= elist[isucc])
break;
940 iord[*nrmax] = isucc;
945 if (*last > *limit / 2 + 2)
946 jupbn = *limit + 3 - *last;
950 errmin = elist[*last];
953 for (i = *nrmax + 1; i <= jbnd; ++i) {
955 if (errmax >= elist[isucc]) {
956 iord[i - 1] = *maxerr;
957 for (j = i, k = jbnd; j <= jbnd; j++, k--) {
959 if (errmin < elist[isucc]) {
971 iord[jbnd] = *maxerr;
976 *maxerr = iord[*nrmax];
977 *ermax = elist[*maxerr];
992 control(
int subdivisions_ = 100,
double reltol_ = 1e-4,
993 double abstol_ = 1e-4);
1010 template <
class Integrand>
1012 typedef typename Integrand::Scalar Type;
1014 struct vectorized_integrand {
1016 vectorized_integrand(Integrand f_) : f(f_) {}
1017 void operator()(Type *x,
int n,
void *ex) {
1018 for (
int i = 0; i < n; i++) x[i] = f(x[i]);
1024 Type epsabs, epsrel, result, abserr;
1025 int neval, ier, limit, lenw, last;
1026 std::vector<int> iwork;
1027 std::vector<Type> work;
1028 void setAccuracy(
double epsrel_ = 1e-4,
double epsabs_ = 1e-4) {
1037 void setWorkspace(
int subdivisions = 100) {
1038 limit = subdivisions;
1040 iwork.resize(limit);
1045 void setBounds(Type a_, Type b_) {
1046 int a_finite = (a_ != -INFINITY) && (a_ != INFINITY);
1047 int b_finite = (b_ != -INFINITY) && (b_ != INFINITY);
1048 if (a_finite && b_finite) {
1052 }
else if (a_finite && !b_finite) {
1055 }
else if (!a_finite && b_finite) {
1069 setAccuracy(c.reltol, c.abstol);
1070 setWorkspace(c.subdivisions);
1075 Rdqagi(fn, NULL, &bound, &inf, &epsabs, &epsrel, &result, &abserr, &neval,
1076 &ier, &limit, &lenw, &last, &iwork[0], &work[0]);
1078 Rdqags(fn, NULL, &a, &b, &epsabs, &epsrel, &result, &abserr, &neval, &ier,
1079 &limit, &lenw, &last, &iwork[0], &work[0]);
1110 template <
class Integrand>
1112 typename Integrand::Scalar a = -INFINITY,
1113 typename Integrand::Scalar b = INFINITY,
1133 template <
class Integrand>
1135 typedef typename Integrand::Scalar Scalar;
1137 typedef typename Integrand::Scalar Scalar;
1140 evaluator(Integrand &f_, Scalar &x_) : f(f_), x(x_) {}
1141 Scalar operator()(
const Scalar &x_) {
1148 mvIntegral(Integrand &f_, Scalar &x_, Scalar a = -INFINITY,
1150 : ev(f_, x_), c(c_), I(ev, a, b, c_) {}
1151 Scalar operator()() {
return I(); }
1154 Scalar b = INFINITY) {
1159 template <
class Integrand>
1160 struct mvIntegral0 {
1161 typedef typename Integrand::Scalar Scalar;
1164 mvIntegral0(Integrand &f_,
control c_) : f(f_), c(c_) {}
1167 Scalar b = INFINITY) {
1198 template <
class Integrand>
1200 return mvIntegral0<Integrand>(f, c);
1204 #endif // HAVE_INTEGRATE_HPP Automatic differentiation library designed for TMB.
mvIntegral< mvIntegral > wrt(Scalar &x, Scalar a=-INFINITY, Scalar b=INFINITY)
With respect to.
Integral(Integrand f_, Type a_, Type b_, control c=control())
Constructor.
Integrand & integrand()
Return reference to integrand so the user can change parameters.
Integrand::Scalar integrate(Integrand f, typename Integrand::Scalar a=-INFINITY, typename Integrand::Scalar b=INFINITY, control c=control())
Integrate function over finite or infinite interval.
Interface to R's adaptive integrate routine.
double value(T x)
Namespace with utility functions for adaptive numerical integration.
mvIntegral0< Integrand > mvIntegrate(Integrand &f, control c=control())
Multivariate integration.
Multivariate integral class.
User control parameters for R's integrate.