4 #include <UnitTest++.h>
15 ret_val = exp(x) / (x * x + 1.f);
31 &a, &b, &epsabs, &epsrel, &result, &abserr, &neval, &
33 if (0) printf(
"QNG: Result=%.8g abserr=%.8g neval=%ld ier=%ld\n",
34 result,abserr,neval,ier);
37 CHECK_EQUAL( 21, neval );
38 CHECK_EQUAL( 0, ier );
45 ret_val = 2.f / (sin(x * 10.f *
sys_float(PI)) + 2.f);
55 long neval, limit, iwork[100];
65 qag_(
E_fp_fp(qagf), &a, &b, &epsabs, &epsrel, &key, &result, &abserr, &
66 neval, &ier, &limit, &lenw, &last, iwork, work);
67 if (0) printf(
"QAG: Result=%e abserr=%e neval=%ld ier=%ld\n",
68 result,abserr,neval,ier);
70 CHECK( abserr < 0.0008f );
71 CHECK_EQUAL( 183, neval );
72 CHECK_EQUAL( 0, ier );
81 ret_val = 1.f / sqrt(x);
92 long neval, limit, iwork[100];
102 &a, &b, &epsabs, &epsrel, &result, &abserr, &neval, &ier, &
103 limit, &lenw, &last, iwork, work);
104 if (0) printf(
"QAGS: Result=%e abserr=%e neval=%ld ier=%ld\n",
105 result,abserr,neval,ier);
108 CHECK_EQUAL( 231, neval );
109 CHECK_EQUAL( 0, ier );
116 const double c_b13 = -.25;
117 const double c_b14 = -.55;
120 if (x != 1.f/7.f && x != 2.f/3.f) {
121 d__1 = (r__1 = x - 1.f/7.f, fabs(r__1));
122 d__2 = (r__2 = x - 2.f/3.f, fabs(r__2));
123 ret_val = pow(d__1, c_b13) * pow(d__2, c_b14);
135 long neval, leniw, limit, iwork[204];
136 sys_float epsabs, abserr, epsrel, points[4], result;
146 leniw = (limit << 1) + npts2;
147 lenw = (limit << 2) + npts2;
149 &a, &b, &npts2, points, &epsabs, &epsrel, &result, &
150 abserr, &neval, &ier, &leniw, &lenw, &last, iwork, work);
151 if (0) printf(
"QAGP: Result=%e abserr=%e neval=%ld ier=%ld\n",
152 result,abserr,neval,ier);
154 CHECK( abserr < 8.5e-4f );
155 CHECK_EQUAL( neval , 861 );
156 CHECK_EQUAL( ier, 0 );
165 ret_val = sqrt(x) * log(x) / ((x + 1.f) * (x + 2.f));
176 long neval, limit, iwork[100];
177 sys_float epsabs, abserr, epsrel, result;
186 &boun, &inf, &epsabs, &epsrel, &result, &abserr, &
187 neval, &ier, &limit, &lenw, &last, iwork, work);
188 if (0) printf(
"QAGI: Result=%e abserr=%e neval=%ld ier=%ld\n",
189 result,abserr,neval,ier);
191 CHECK( abserr < 9.e-4f );
192 CHECK_EQUAL( 315, neval );
193 CHECK_EQUAL( 0, ier );
202 ret_val = exp(-(x)) * log(x);
210 long ier, last, lenw;
215 long leniw, limit, iwork[200];
229 lenw = (limit << 2) + maxp1 * 25;
231 &a, &b, &omega, &integr, &epsabs, &epsrel, &result, &
232 abserr, &neval, &ier, &leniw, &maxp1, &lenw, &last, iwork, work);
233 if (0) printf(
"QAWO: Result=%e abserr=%e neval=%ld ier=%ld\n",
234 result,abserr,neval,ier);
236 CHECK( abserr < 2.e-7f );
237 CHECK_EQUAL( neval , 255 );
238 CHECK_EQUAL( ier, 0 );
247 ret_val = sin(x * 50.f) / (x * sqrt(x));
260 long neval, leniw, limit, iwork[250];
271 leniw = (limit << 1) + limlst;
273 lenw = (leniw << 1) + maxp1 * 25;
274 qawf_(
E_fp_fp(qawff), &a, &omega, &integr, &epsabs, &result, &abserr, &
275 neval, &ier, &limlst, &lst, &leniw, &maxp1, &lenw, iwork, work);
276 if (0) printf(
"QAWF: Result=%e abserr=%e neval=%ld ier=%ld\n",
277 result,abserr,neval,ier);
279 CHECK( abserr < 8e-4f );
280 CHECK_EQUAL( neval , 7110 );
281 CHECK_EQUAL( ier, 0 );
288 ret_val = sin(x * 10.f);
315 &a, &b, &alfa, &beta, &integr, &epsabs, &epsrel, &
316 result, &abserr, &neval, &ier, &limit, &lenw, &last, iwork, work);
317 if (0) printf(
"QAWS: Result=%e abserr=%e neval=%ld ier=%ld\n",
318 result,abserr,neval,ier);
320 CHECK( abserr < 3e-7f );
321 CHECK_EQUAL( neval , 50 );
322 CHECK_EQUAL( ier, 0 );
329 ret_val = 1.f / (x * x + 1e-4f);
339 long neval, limit, iwork[100];
340 sys_float epsabs, abserr, epsrel, result;
350 &a, &b, &c__, &epsabs, &epsrel, &result, &abserr, &
351 neval, &ier, &limit, &lenw, &last, iwork, work);
352 if (0) printf(
"QAWC: Result=%e abserr=%e neval=%ld ier=%ld\n",
353 result,abserr,neval,ier);
355 CHECK( abserr < 1.7e-1f );
356 CHECK_EQUAL( neval , 225 );
357 CHECK_EQUAL( ier, 0 );
360 double dqngf(
double x)
364 ret_val = exp(x) / (x * x + 1.);
373 double epsabs, abserr, epsrel, result;
380 &a, &b, &epsabs, &epsrel, &result, &abserr, &neval, &ier);
381 if (0) printf(
"DQNG: Result=%.8g abserr=%.8g neval=%ld ier=%ld\n",
382 result,abserr,neval,ier);
385 CHECK_EQUAL( neval , 21 );
386 CHECK_EQUAL( ier, 0 );
389 double dqagf(
double x)
393 ret_val = 2. / (sin(x * 10.0 * PI) + 2.0);
403 long neval, limit, iwork[100];
404 double epsabs, abserr, epsrel, result;
414 &a, &b, &epsabs, &epsrel, &key, &result, &abserr, &
415 neval, &ier, &limit, &lenw, &last, iwork, work);
416 if (0) printf(
"DQAG: Result=%e abserr=%e neval=%ld ier=%ld\n",
417 result,abserr,neval,ier);
420 CHECK_EQUAL( neval , 183 );
421 CHECK_EQUAL( ier, 0 );
424 double dqagsf(
double x)
430 ret_val = 1. / sqrt(x);
441 long neval, limit, iwork[100];
442 double epsabs, abserr, epsrel, result;
451 &a, &b, &epsabs, &epsrel, &result, &abserr, &neval, &ier, &
452 limit, &lenw, &last, iwork, work);
453 if (0) printf(
"DQAGS: Result=%e abserr=%e neval=%ld ier=%ld\n",
454 result,abserr,neval,ier);
456 CHECK( abserr < 6.e-15 );
457 CHECK_EQUAL( 231, neval );
458 CHECK_EQUAL( 0, ier );
461 double dqagpf(
double x)
463 double ret_val, r__1, r__2;
465 const double c_b13 = -.25;
466 const double c_b14 = -.55;
469 if (x != 1./7. && x != 2./3.) {
470 d__1 = (r__1 = x - 1./7., fabs(r__1));
471 d__2 = (r__2 = x - 2./3., fabs(r__2));
472 ret_val = pow(d__1, c_b13) * pow(d__2, c_b14);
484 long neval, leniw, limit, iwork[204];
485 double epsabs, abserr, epsrel, points[4], result;
495 leniw = (limit << 1) + npts2;
496 lenw = (limit << 2) + npts2;
498 &a, &b, &npts2, points, &epsabs, &epsrel, &result, &
499 abserr, &neval, &ier, &leniw, &lenw, &last, iwork, work);
500 if (0) printf(
"DQAGP: Result=%e abserr=%e neval=%ld ier=%ld\n",
501 result,abserr,neval,ier);
504 CHECK_EQUAL( 861, neval );
505 CHECK_EQUAL( 0, ier );
508 double dqagif(
double x)
514 ret_val = sqrt(x) * log(x) / ((x + 1.) * (x + 2.));
525 long neval, limit, iwork[100];
526 double epsabs, abserr, epsrel, result;
535 &boun, &inf, &epsabs, &epsrel, &result, &abserr, &
536 neval, &ier, &limit, &lenw, &last, iwork, work);
537 if (0) printf(
"DQAGI: Result=%e abserr=%e neval=%ld ier=%ld\n",
538 result,abserr,neval,ier);
541 CHECK_EQUAL( 315, neval );
542 CHECK_EQUAL( 0, ier );
545 double dqawof(
double x)
551 ret_val = exp(-(x)) * log(x);
559 long ier, last, lenw;
564 long leniw, limit, iwork[200];
565 double epsabs, abserr;
567 double epsrel, result;
578 lenw = (limit << 2) + maxp1 * 25;
580 &a, &b, &omega, &integr, &epsabs, &epsrel, &result, &
581 abserr, &neval, &ier, &leniw, &maxp1, &lenw, &last, iwork, work);
582 if (0) printf(
"DQAWO: Result=%e abserr=%e neval=%ld ier=%ld\n",
583 result,abserr,neval,ier);
586 CHECK_EQUAL( 255 , neval );
587 CHECK_EQUAL( 0 , ier );
590 double dqawff(
double x)
595 ret_val = sin(x * 50.) / (x * sqrt(x));
608 long neval, leniw, limit, iwork[250];
609 double epsabs, abserr;
619 leniw = (limit << 1) + limlst;
621 lenw = (leniw << 1) + maxp1 * 25;
623 &a, &omega, &integr, &epsabs, &result, &abserr, &
624 neval, &ier, &limlst, &lst, &leniw, &maxp1, &lenw, iwork, work);
625 if (0) printf(
"DQAWF: Result=%e abserr=%e neval=%ld ier=%ld\n",
626 result,abserr,neval,ier);
629 CHECK_EQUAL( 7080, neval );
630 CHECK_EQUAL( 0, ier );
633 double dqawsf(
double x)
637 ret_val = sin(x * 10.);
650 double epsabs, abserr;
652 double epsrel, result;
664 &a, &b, &alfa, &beta, &integr, &epsabs, &epsrel, &
665 result, &abserr, &neval, &ier, &limit, &lenw, &last, iwork, work);
666 if (0) printf(
"DQAWS: Result=%e abserr=%e neval=%ld ier=%ld\n",
667 result,abserr,neval,ier);
670 CHECK_EQUAL( 50, neval );
671 CHECK_EQUAL( 0, ier );
674 double dqawcf(
double x)
678 ret_val = 1. / (x * x + 1e-4);
688 long neval, limit, iwork[100];
689 double epsabs, abserr, epsrel, result;
699 &a, &b, &c__, &epsabs, &epsrel, &result, &abserr, &
700 neval, &ier, &limit, &lenw, &last, iwork, work);
701 if (0) printf(
"DQAWC: Result=%e abserr=%e neval=%ld ier=%ld\n",
702 result,abserr,neval,ier);
705 CHECK( neval <= 255 );
706 CHECK_EQUAL( 0, ier );
void dqag_(const D_fp &f, const double *a, const double *b, const double *epsabs, const double *epsrel, const long *key, double *result, double *abserr, long *neval, long *ier, long *limit, const long *lenw, long *last, long *iwork, double *work)
bool fp_equal_tol(sys_float x, sys_float y, sys_float tol)
void dqagp_(const D_fp &f, const double *a, const double *b, const long *npts2, const double *points, const double *epsabs, const double *epsrel, double *result, double *abserr, long *neval, long *ier, const long *leniw, const long *lenw, long *last, long *iwork, double *work)
void dqawc_(const D_fp &f, const double *a, const double *b, const double *c__, const double *epsabs, const double *epsrel, double *result, double *abserr, long *neval, long *ier, long *limit, const long *lenw, long *last, long *iwork, double *work)
void qaws_(const E_fp &f, const sys_float *a, const sys_float *b, const sys_float *alfa, const sys_float *beta, const long *integr, const sys_float *epsabs, const sys_float *epsrel, sys_float *result, sys_float *abserr, long *neval, long *ier, const long *limit, const long *lenw, long *last, long *iwork, sys_float *work)
void dqawo_(const D_fp &f, const double *a, const double *b, const double *omega, const long *integr, const double *epsabs, const double *epsrel, double *result, double *abserr, long *neval, long *ier, const long *leniw, long *maxp1, const long *lenw, long *last, long *iwork, double *work)
void dqags_(const D_fp &f, const double *a, const double *b, const double *epsabs, const double *epsrel, double *result, double *abserr, long *neval, long *ier, const long *limit, const long *lenw, long *last, long *iwork, double *work)
void dqawf_(const D_fp &f, const double *a, const double *omega, const long *integr, const double *epsabs, double *result, double *abserr, long *neval, long *ier, long *limlst, long *lst, const long *leniw, const long *maxp1, const long *lenw, long *iwork, double *work)
void qawo_(const E_fp &f, const sys_float *a, const sys_float *b, const sys_float *omega, const long *integr, const sys_float *epsabs, const sys_float *epsrel, sys_float *result, sys_float *abserr, long *neval, long *ier, const long *leniw, const long *maxp1, const long *lenw, long *last, long *iwork, sys_float *work)
void dqaws_(const D_fp &f, const double *a, const double *b, const double *alfa, const double *beta, const long *integr, const double *epsabs, const double *epsrel, double *result, double *abserr, long *neval, long *ier, long *limit, const long *lenw, long *last, long *iwork, double *work)
void dqng_(const D_fp &f, const double *a, const double *b, const double *epsabs, const double *epsrel, double *result, double *abserr, long *neval, long *ier)
void qawc_(const E_fp &f, const sys_float *a, const sys_float *b, const sys_float *c__, const sys_float *epsabs, const sys_float *epsrel, sys_float *result, sys_float *abserr, long *neval, long *ier, long *limit, const long *lenw, long *last, long *iwork, sys_float *work)
void qags_(const E_fp &f, const sys_float *a, const sys_float *b, const sys_float *epsabs, const sys_float *epsrel, sys_float *result, sys_float *abserr, long *neval, long *ier, const long *limit, const long *lenw, long *last, long *iwork, sys_float *work)
void qagp_(const E_fp &f, const sys_float *a, const sys_float *b, const long *npts2, const sys_float *points, const sys_float *epsabs, const sys_float *epsrel, sys_float *result, sys_float *abserr, long *neval, long *ier, const long *leniw, const long *lenw, long *last, long *iwork, sys_float *work)
void qawf_(const E_fp &f, const sys_float *a, const sys_float *omega, const long *integr, const sys_float *epsabs, sys_float *result, sys_float *abserr, long *neval, long *ier, const long *limlst, long *lst, const long *leniw, const long *maxp1, const long *lenw, long *iwork, sys_float *work)
void dqagi_(const D_fp &f, const double *bound, const long *inf, const double *epsabs, const double *epsrel, double *result, double *abserr, long *neval, long *ier, long *limit, const long *lenw, long *last, long *iwork, double *work)
void qag_(const E_fp &f, const sys_float *a, const sys_float *b, const sys_float *epsabs, const sys_float *epsrel, const long *key, sys_float *result, sys_float *abserr, long *neval, long *ier, long *limit, const long *lenw, long *last, long *iwork, sys_float *work)
void qagi_(const E_fp &f, const sys_float *bound, const long *inf, const sys_float *epsabs, const sys_float *epsrel, sys_float *result, sys_float *abserr, long *neval, long *ier, const long *limit, const long *lenw, long *last, long *iwork, sys_float *work)
void qng_(const E_fp &f, sys_float *a, sys_float *b, sys_float *epsabs, sys_float *epsrel, sys_float *result, sys_float *abserr, long *neval, long *ier)