143 auto identity = [](
double x){
return x; };
148 constexpr gsl::index nSubsamples = 4;
149 constexpr
double min = -2.0;
150 constexpr
double atLeast = +1.0;
151 constexpr
double stopBefore = +8.2;
152 constexpr
double step = 0.5;
153 constexpr
double substep = step / nSubsamples;
158 constexpr
double stopValue = identity(stopBefore);
160 = [](double,
double y){
return (
y < 0) || (
y >= stopValue); };
164 { identity, min, step, stopIf, nSubsamples, atLeast };
166 constexpr gsl::index expected_nSamples
167 = constexpr_floor<gsl::index>((stopBefore - min) / step);
168 constexpr gsl::index expected_max = min + step * expected_nSamples;
169 constexpr gsl::index expected_range = expected_max - min;
174 BOOST_TEST(sampled.nSubsamples() == nSubsamples);
175 BOOST_TEST(sampled.lower() == min);
176 BOOST_TEST(sampled.stepSize() == step,
close);
177 BOOST_TEST(sampled.substepSize() == substep,
close);
179 BOOST_TEST(sampled.upper() == expected_max,
close);
180 BOOST_TEST_REQUIRE(sampled.size() == expected_nSamples);
181 BOOST_TEST(sampled.rangeSize() == expected_range,
close);
184 auto const nSamples = sampled.size();
186 for (
auto const iSub:
util::counter(nSubsamples)) BOOST_TEST_CONTEXT(
"Subsample: " << iSub)
189 double const subsampleStart = min + iSub * substep;
191 auto const& subSample = sampled.subsample(iSub);
193 (
"Subsample #" << iSub <<
": " << subSample.size() <<
" samples");
194 auto itSample = subSample.begin();
196 for (
auto const iSample:
util::counter(-nSamples, 2*nSamples+1)) BOOST_TEST_CONTEXT(
"Sample: " << iSample)
198 bool const bInRange = (iSample >= 0) && (iSample < nSamples);
200 double const expected_x
201 =
static_cast<double>(subsampleStart + iSample * step);
202 double const expected_value = identity(expected_x);
205 BOOST_TEST(sampled.value(iSample, iSub) == expected_value);
206 BOOST_TEST(*itSample == expected_value);
207 BOOST_TEST_MESSAGE(
"[" << iSample <<
"] " << *itSample);
213 BOOST_TEST((itSample == subSample.end()),
"itSample != subSample.end()");
215 BOOST_TEST(!sampled.isValidStepIndex
216 (sampled.stepIndex(subsampleStart + expected_max - min, iSub))
process_name opflash particleana ie x
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
process_name opflash particleana ie ie y
print OUTPUT<< EOF;< setup name="Default"version="1.0">< worldref="volWorld"/></setup ></gdml > EOF close(OUTPUT)
Precomputed discrete sampling of a given function.