MCPcopy Create free account
hub / github.com/ConorWilliams/libfork / integrate

Function integrate

bench/source/integrate/omp.cpp:11–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9namespace {
10
11auto integrate(double x1, double y1, double x2, double y2, double area) -> double {
12
13 double half = (x2 - x1) / 2;
14 double x0 = x1 + half;
15 double y0 = fn(x0);
16
17 double area_x1x0 = (y1 + y0) / 2 * half;
18 double area_x0x2 = (y0 + y2) / 2 * half;
19 double area_x1x2 = area_x1x0 + area_x0x2;
20
21 if (area_x1x2 - area < epsilon && area - area_x1x2 < epsilon) {
22 return area_x1x2;
23 }
24
25#pragma omp task untied default(shared)
26 area_x1x0 = integrate(x1, y1, x0, y0, area_x1x0);
27 area_x0x2 = integrate(x0, y0, x2, y2, area_x0x2);
28#pragma omp taskwait
29
30 return area_x1x0 + area_x0x2;
31}
32
33void integrate_omp(benchmark::State &state) {
34

Callers 1

integrate_ompFunction · 0.70

Calls 1

fnFunction · 0.85

Tested by

no test coverage detected