File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919#include " shamtest/PyScriptHandle.hpp"
2020#include " shamtest/details/TestResult.hpp"
2121#include " shamtest/shamtest.hpp"
22+ #include < cmath>
2223#include < vector>
2324
2425template <class Ker >
@@ -82,13 +83,17 @@ inline void validate_kernel_3d(
8283 // is df = f' ?
8384 Tscal L2_sum = 0 ;
8485 Tscal step = 0.01 ;
85- for (Tscal x = 0 ; x < Ker::Rkern; x += step) {
86- Tscal diff = Ker::df (x) - shammath::derivative_upwind<Tscal>(x, dx, [](Tscal x) {
86+
87+ const int num_steps = static_cast <int >(std::ceil (Ker::Rkern / step));
88+ for (int i = 0 ; i < num_steps; i++) {
89+ const Tscal x = i * step;
90+ Tscal diff = Ker::df (x) - shammath::derivative_upwind<Tscal>(x, dx, [](Tscal x) {
8791 return Ker::f (x);
8892 });
8993 diff *= gen_norm3d;
9094 L2_sum += diff * diff * step;
9195 }
96+
9297 REQUIRE_FLOAT_EQUAL (L2_sum, 0 , tol);
9398}
9499
You can’t perform that action at this time.
0 commit comments