6 int test_integrand (const int *ndim, const double x[],
7 const int *ncomp, double f[], void *userdata)
9 for (int icomp=0; icomp<*ncomp; icomp++) {
11 for (int idim=0; idim<*ndim; idim++)
12 f[icomp] *= exp(-pow(x[idim],2));
18 int test_integrand_c (const int *ndim, const double x[],
19 const int *ncomp, std::complex<double> f[], void *userdata)
21 for (int icomp=0; icomp<*ncomp; icomp++) {
23 for (int idim=0; idim<*ndim; idim++)
24 f[icomp] *= exp(-pow(x[idim],2));
32 int nregions, neval, fail;
33 double error, prob, integral;
35 std::cout << "int_0^1 dx e-x^2: " << std::endl;
36 for (int itype=0; itype<4; itype++) {
37 cubaint::integrate (&test_integrand, cubaint::intmethod(itype),
40 neval, fail, &integral,
42 std::cout << integral << " +- " << error << " (" << itype << ")" << std::endl;
45 std::cout << "int_0^INF dx e-x^2: " << std::endl;
46 for (int itype=0; itype<4; itype++) {
47 cubaint::integrate (&test_integrand, cubaint::intmethod(itype),
48 {{0,cubaint::INF}}, 1,
50 neval, fail, &integral,
52 std::cout << integral << " +- " << error << " (" << itype << ")" << std::endl;
55 std::cout << "int_-INF^0 dx e-x^2: " << std::endl;
56 for (int itype=0; itype<4; itype++) {
57 cubaint::integrate (&test_integrand, cubaint::intmethod(itype),
58 {{cubaint::INF,0}}, 1,
60 neval, fail, &integral,
62 std::cout << integral << " +- " << error << " (" << itype << ")" << std::endl;
65 std::cout << "int_-INF^INF dx e-x^2: " << std::endl;
66 for (int itype=0; itype<4; itype++) {
67 cubaint::integrate (&test_integrand, cubaint::intmethod(itype),
68 {{cubaint::INF,cubaint::INF}}, 1,
70 neval, fail, &integral,
72 std::cout << integral << " +- " << error << " (" << itype << ")" << std::endl;
75 std::cout << "int_1^INF dx e-x^2: " << std::endl;
76 for (int itype=0; itype<4; itype++) {
77 cubaint::integrate (&test_integrand, cubaint::intmethod(itype),
78 {{1,cubaint::INF}}, 1,
80 neval, fail, &integral,
82 std::cout << integral << " +- " << error << " (" << itype << ")" << std::endl;
85 std::cout << "int_-INF^1 dx e-x^2: " << std::endl;
86 for (int itype=0; itype<4; itype++) {
87 cubaint::integrate (&test_integrand, cubaint::intmethod(itype),
88 {{cubaint::INF,1}}, 1,
90 neval, fail, &integral,
92 std::cout << integral << " +- " << error << " (" << itype << ")" << std::endl;
95 std::complex<double> error_c, prob_c, integral_c;
96 std::cout << "int_0^1 dx (e-x^2+i0): " << std::endl;
97 for (int itype=0; itype<4; itype++) {
98 cubaint::integrate (&test_integrand_c, cubaint::intmethod(itype),
101 neval, fail, &integral_c,
102 &error_c, &prob_c, 0);
103 std::cout << integral_c << " +- " << error_c << " (" << itype << ")" << std::endl;