-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved outer_trapezoid to trapezoid.cpp and added test for it
Signed-off-by: Konstantin Läufer <[email protected]>
- Loading branch information
Showing
5 changed files
with
41 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#ifndef F_H_ | ||
#define F_H_ | ||
|
||
|
||
// {{UnoAPI:f-interface:begin}} | ||
#include <sycl/sycl.hpp> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
#include "trapezoid.h" | ||
#include "f.h" | ||
|
||
// {{UnoAPI:trapezoid-implementation:begin}} | ||
double single_trapezoid(const double f1, const double f2, const double half_dx) { | ||
return (f1 + f2) * half_dx; | ||
} | ||
// {{UnoAPI:trapezoid-implementation:end}} | ||
|
||
// {{UnoAPI:main-compute-outer-trapezoid:begin}} | ||
// common function to compute a single outer trapezoid | ||
// from as many inner trapezoids as the grain size | ||
double outer_trapezoid( | ||
const int grain_size, | ||
const double x_pos, | ||
const double dx_inner, | ||
const double half_dx_inner | ||
) { | ||
auto area{0.0}; | ||
auto y_left{f(x_pos)}; | ||
for (auto j{0UL}; j < grain_size; j++) { | ||
auto y_right{f(x_pos + (j + 1) * dx_inner)}; | ||
area += single_trapezoid(y_left, y_right, half_dx_inner); | ||
y_left = y_right; | ||
} | ||
return area; | ||
} | ||
// {{UnoAPI:main-compute-outer-trapezoid:end}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters