49 const Float_t bmin[3] = {-40.f, -40.f, -200.f};
50 const Float_t bmax[3] = {40.f, 40.f, 200.f};
51 const Int_t np[3] = {7, 7, 7};
52 const Float_t fitPrec = 1.0e-5f;
54 Chebyshev3D cheb(referenceField, 3, bmin, bmax, np, fitPrec);
58 std::mt19937 rng(20260604u);
59 std::uniform_real_distribution<float> ux(bmin[0] + 1.f, bmax[0] - 1.f);
60 std::uniform_real_distribution<float> uy(bmin[1] + 1.f, bmax[1] - 1.f);
61 std::uniform_real_distribution<float> uz(bmin[2] + 1.f, bmax[2] - 1.f);
63 float maxAbsErr = 0.f;
64 float maxDimMismatch = 0.f;
65 float maxDoubleMismatch = 0.f;
67 for (
int i = 0;
i < 20000; ++
i) {
68 float par[3] = {ux(rng), uy(rng), uz(rng)};
70 referenceField(par,
ref);
75 double pard[3] = {par[0], par[1], par[2]};
77 cheb.
Eval(pard, resd);
79 for (
int d = 0; d < 3; ++d) {
80 BOOST_REQUIRE(std::isfinite(
res[d]));
81 maxAbsErr = std::max(maxAbsErr, std::abs(
res[d] -
ref[d]));
83 maxDimMismatch = std::max(maxDimMismatch, std::abs(
res[d] - cheb.
Eval(par, d)));
85 maxDoubleMismatch = std::max(maxDoubleMismatch, std::abs(
static_cast<float>(resd[d]) -
res[d]));
89 BOOST_TEST_MESSAGE(
"Chebyshev3D max |eval - reference| = " << maxAbsErr);
90 BOOST_TEST_MESSAGE(
"Chebyshev3D max vector-vs-perdim = " << maxDimMismatch);
91 BOOST_TEST_MESSAGE(
"Chebyshev3D max float-vs-double = " << maxDoubleMismatch);
96 BOOST_CHECK_SMALL(maxAbsErr, 1.0e-4f);
98 BOOST_CHECK_SMALL(maxDimMismatch, 1.0e-6f);
100 BOOST_CHECK_SMALL(maxDoubleMismatch, 1.0e-3f);