All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
util::SampledFunction< XType, YType > Class Template Reference

Precomputed discrete sampling of a given function. More...

#include <SampledFunction.h>

Classes

struct  Range_t
 Record used during initialization. More...
 

Public Types

using X_t = XType
 Type of value accepted by the function. More...
 
using Y_t = YType
 Type of value returned by the function. More...
 
using Function_t = std::function< Y_t(X_t)>
 Type of sampled function. More...
 
using SubsampleData_t = gsl::span< Y_t const >
 Span of subsample data. Can be forward iterated. More...
 

Public Member Functions

 SampledFunction ()=default
 
template<typename Func >
 SampledFunction (Func const &function, X_t lower, X_t upper, gsl::index nSamples, gsl::index subsamples=1)
 Constructor: samples function in the specified range. More...
 
template<typename Stream >
void dump (Stream &&out, std::string const &indent, std::string const &firstIndent) const
 Dumps the full content of the sampling into out stream. More...
 
template<typename Stream >
void dump (Stream &&out, std::string const &indent="") const
 Dumps the full content of the sampling into out stream. More...
 
template<typename UntilFunc >
auto extendRange (Function_t const &function, X_t lower, X_t min_upper, X_t step, UntilFunc &&until) -> Range_t
 
template<typename Func , typename UntilFunc >
 SampledFunction (Func const &function, X_t lower, X_t step, UntilFunc &&until, gsl::index subsamples, X_t min_upper)
 Constructor: samples function in the specified range. More...
 
template<typename Func , typename UntilFunc >
 SampledFunction (Func const &function, X_t lower, X_t step, UntilFunc &&until, gsl::index subsamples=1)
 
Query
gsl::index size () const
 Returns the number of samples (in each subsample). More...
 
gsl::index nSubsamples () const
 Returns the number of subsamples. More...
 
X_t lower () const
 Returns the lower limit of the covered range. More...
 
X_t upper () const
 Returns the upper limit of the covered range. More...
 
X_t rangeSize () const
 Returns the extension of the covered range. More...
 
X_t stepSize () const
 Returns the extension of a step. More...
 
X_t substepSize () const
 Returns the base offset of the subsamples. More...
 
Access to the sampled data
Y_t value (gsl::index iSample, gsl::index n=0U) const
 Returns the iSample value of the subsample with the specified index n. More...
 
SubsampleData_t subsample (gsl::index const n) const
 Returns the data of the subsample with the specified index n. More...
 
gsl::index stepIndex (X_t const x, gsl::index const iSubsample) const
 Returns the index of the step including x. More...
 
bool isValidStepIndex (gsl::index const index) const
 Returns whether the specified step index is valid. More...
 
gsl::index closestSubsampleIndex (X_t x) const
 Returns the subsample closest to the value x. More...
 

Static Public Attributes

static constexpr auto npos = std::numeric_limits<gsl::index>::max()
 Invalid index of sample, returned in case of error. More...
 

Private Member Functions

 SampledFunction (Function_t const &function, Range_t const &range, gsl::index subsamples)
 Constructor implementation. More...
 
X_t subsampleOffset (gsl::index n) const
 Returns the starting point of the subsample n. More...
 
std::size_t computeTotalSize () const
 Computes the total size of the data. More...
 
void fillSamples (Function_t const &function)
 Samples the function and fills the internal caches. More...
 
Y_t const * subsampleData (gsl::index n) const
 Start of the block of values for subsample n (unchecked). More...
 
Y_tsubsampleData (gsl::index n)
 

Static Private Member Functions

template<typename UntilFunc >
static Range_t extendRange (Function_t const &function, X_t lower, X_t min_upper, X_t step, UntilFunc &&until)
 
template<typename T >
static T wrapUp (T value, T range)
 Returns value made non-negative by adding multiples of range. More...
 

Private Attributes

X_t fLower
 Lower limit of sampled range. More...
 
X_t fUpper
 Upper limit of sampled range. More...
 
gsl::index fNSamples
 Number of samples in the range. More...
 
gsl::index fNSubsamples
 Number of subsamples. More...
 
X_t fStep
 Step size. More...
 
std::vector< Y_tfAllSamples
 All samples, the entire first subsample first. More...
 

Detailed Description

template<typename XType, typename YType>
class util::SampledFunction< XType, YType >

Precomputed discrete sampling of a given function.

Template Parameters
XType(default: double) type of value accepted by the function
YType(default: as XType) type of value returned by the function

This object contains the sampling of a specified function at regular values of its variable.

If the size() of the sampling is requested to be N, there will be a sampling of N values covering the specified range in steps of the same length, last value excluded. The sampling happens at the beginning of each step.

In addition, subsampling can be requested. If M subsamples are requested, the first step is split in M points and from each one a sampling of N steps is started, causing overall M N samples to be computed.

Requirements

The function must be unary.

Technical note

The M subsamples are stored each one contiguously. Therefore a function with M subsamples of size N is different, at least in storage, from a function with a single sampling (no subsamples) of size M N.

Note
Due to the implementation of gsl::span, its iterators are valid only while the span object is valid as well. This means that a construct like: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} for (auto it = sf.subsample(0).begin(); it != sf.subsample(0).end(); ++it) // ... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ will mysteriously fail at run time because it refers to a temporary span that quickly falls out of scope (and the end iterator refers to a different span object, too). The correct pattern is to store the subsample result before iterating through it: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} auto const& subsample = sf.subsample(0); for (auto it = subsample.begin(); it != subsample.end(); ++it) // ... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ or, if appliable, let the range-for loop di that for us: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} for (auto value: sf.subsample(0)) // ... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This will not be the case any more with std::span, which apparently is going to satisfy the borrowed_range requirement.

Definition at line 31 of file SampledFunction.h.

Member Typedef Documentation

template<typename XType, typename YType>
using util::SampledFunction< XType, YType >::Function_t = std::function<Y_t(X_t)>

Type of sampled function.

Definition at line 97 of file SampledFunction.h.

template<typename XType, typename YType>
using util::SampledFunction< XType, YType >::SubsampleData_t = gsl::span<Y_t const>

Span of subsample data. Can be forward iterated.

Definition at line 103 of file SampledFunction.h.

template<typename XType, typename YType>
using util::SampledFunction< XType, YType >::X_t = XType

Type of value accepted by the function.

Definition at line 95 of file SampledFunction.h.

template<typename XType, typename YType>
using util::SampledFunction< XType, YType >::Y_t = YType

Type of value returned by the function.

Definition at line 96 of file SampledFunction.h.

Constructor & Destructor Documentation

template<typename XType, typename YType>
util::SampledFunction< XType, YType >::SampledFunction ( )
default
template<typename XType , typename YType >
template<typename Func >
util::SampledFunction< XType, YType >::SampledFunction ( Func const &  function,
X_t  lower,
X_t  upper,
gsl::index  nSamples,
gsl::index  subsamples = 1 
)

Constructor: samples function in the specified range.

Template Parameters
Functype of a functor (see requirements below)
Parameters
functionthe function to be sampled
lowerthe lower limit of the range to be sampled
upperthe upper limit of the range to be sampled
nSamplesthe number (N) of samples to be computed
subsamples(default: 1) the number (M) of subsamples to be computed

The sampling of function is performed on nSamples points from lower to upper (excluded).

The function parameter type Func need to be a unary functor, i.e. it must support a call of type function(X_t) const returning some value convertible to Y_t. Plain C functions and closures also work.

The function is not copied nor retained in any form, so it can be from a temporary object.

Definition at line 380 of file SampledFunction.h.

386  : SampledFunction(
387  Function_t(function),
388  Range_t{ lower, upper, (upper - lower) / nSamples, nSamples },
389  subsamples
390  )
391 {}
X_t upper() const
Returns the upper limit of the covered range.
X_t lower() const
Returns the lower limit of the covered range.
std::function< Y_t(X_t)> Function_t
Type of sampled function.
template<typename XType , typename YType >
template<typename Func , typename UntilFunc >
util::SampledFunction< XType, YType >::SampledFunction ( Func const &  function,
X_t  lower,
X_t  step,
UntilFunc &&  until,
gsl::index  subsamples,
X_t  min_upper 
)

Constructor: samples function in the specified range.

Template Parameters
UntilFunctype of functor indicating when to stop sampling
Parameters
functionthe function to be sampled
lowerthe lower limit of the range to be sampled
stepthe sampling interval
untilfunctor to indicate when to stop sampling
subsamples(default: 1) the number (M) of subsamples to be computed
min_upper(default: none) minimum value covered by the sampling

The sampling of function is performed from lower, advancing by step at each following sample, until the until functor returns true. If min_upper is specified, regardless of the result of until, samples below min_upper are always covered.

The functor until should be callable as in bool until(X_t x, Y_t y), and should return false if the sample of value y, corresponding to the evaluation point x, needs to be sampled, and true if instead that sample needs to be discarded, and the sampling stopped. For example, to apply a threshold so that sampling stops when the function is 0.1, until can be defined as [](X_t, Y_t s){ return s >= Y_t{0.1}; } (x is ignored).

Subsampling is performed based on the subsamples argument.

Definition at line 397 of file SampledFunction.h.

403  : SampledFunction(
404  Function_t(function),
406  (function, lower, min_upper, step, std::forward<UntilFunc>(until)),
407  subsamples
408  )
409 {}
X_t lower() const
Returns the lower limit of the covered range.
static Range_t extendRange(Function_t const &function, X_t lower, X_t min_upper, X_t step, UntilFunc &&until)
std::function< Y_t(X_t)> Function_t
Type of sampled function.
template<typename XType, typename YType>
template<typename Func , typename UntilFunc >
util::SampledFunction< XType, YType >::SampledFunction ( Func const &  function,
X_t  lower,
X_t  step,
UntilFunc &&  until,
gsl::index  subsamples = 1 
)
template<typename XType , typename YType >
util::SampledFunction< XType, YType >::SampledFunction ( Function_t const &  function,
Range_t const &  range,
gsl::index  subsamples 
)
private

Constructor implementation.

Definition at line 460 of file SampledFunction.h.

465  : fLower(range.lower)
466  , fUpper(range.upper)
467  , fNSamples(range.nSamples)
468  , fNSubsamples(subsamples)
469  , fStep(range.step)
471 {
472  assert(fNSamples > 0);
473  assert(subsamples > 0);
474  fillSamples(function);
475 } // util::SampledFunction<>::SampledFunction(range)
gsl::index fNSamples
Number of samples in the range.
std::vector< Y_t > fAllSamples
All samples, the entire first subsample first.
X_t fLower
Lower limit of sampled range.
gsl::index fNSubsamples
Number of subsamples.
void fillSamples(Function_t const &function)
Samples the function and fills the internal caches.
std::size_t computeTotalSize() const
Computes the total size of the data.
X_t fUpper
Upper limit of sampled range.

Member Function Documentation

template<typename XType , typename YType >
gsl::index util::SampledFunction< XType, YType >::closestSubsampleIndex ( X_t  x) const

Returns the subsample closest to the value x.

Parameters
xvalue to be checked
Returns
the index of the subsample found

The subsample with the bin including x whose lower bound is the closest to x itself is returned.

For example, assuming bins aligned with 0 and a sampling with steps of size 1 and 5 subsamples, there will be 5 bins contaning the value x 3.65: [ 3.0, 4.0 ], [ 3.2, 4.2 ], [ 3.4, 4.4 ], [ 3.6, 4.6 ] and [ 2.8, 3.8 ], one for each subsample: closestSubsampleIndex(3.65) will return the sample with the bin 3.6, 4.6, because its lower bound 3.6 is the closest to 3.65.

The value x does not need to be in the sampling range. In the example above, the range could have been between 0 and 2, and the result would be the same.

Definition at line 425 of file SampledFunction.h.

426 {
427  auto const dx = static_cast<double>(x - lower());
428  auto const step = static_cast<double>(stepSize());
429  auto const substep = static_cast<double>(substepSize());
430  return static_cast<gsl::index>(wrapUp(std::fmod(dx, step), step) / substep);
431 } // gsl::index util::SampledFunction<XType, YType>::stepIndex()
X_t lower() const
Returns the lower limit of the covered range.
process_name opflash particleana ie x
static T wrapUp(T value, T range)
Returns value made non-negative by adding multiples of range.
X_t substepSize() const
Returns the base offset of the subsamples.
X_t stepSize() const
Returns the extension of a step.
template<typename XType, typename YType>
std::size_t util::SampledFunction< XType, YType >::computeTotalSize ( ) const
inlineprivate

Computes the total size of the data.

Definition at line 333 of file SampledFunction.h.

333 { return nSubsamples() * size(); }
gsl::index size() const
Returns the number of samples (in each subsample).
gsl::index nSubsamples() const
Returns the number of subsamples.
template<typename XType , typename YType >
template<typename Stream >
void util::SampledFunction< XType, YType >::dump ( Stream &&  out,
std::string const &  indent,
std::string const &  firstIndent 
) const

Dumps the full content of the sampling into out stream.

Definition at line 438 of file SampledFunction.h.

439 {
440  out << firstIndent << "Function sampled from " << lower() << " to " << upper()
441  << " (extent: " << rangeSize() << ")"
442  << " with " << size() << " samples (" << stepSize() << " long)";
443  if (nSubsamples() > 1) {
444  out << " and " << nSubsamples() << " subsamples (" << substepSize()
445  << " long):";
446  }
447  for (auto const iSub: util::counter(nSubsamples())) {
448  out << "\n" << indent << "<subsample #" << iSub << ">:";
449  // FIXME with C++20's `std::span` temporary won't be needed any more
450  auto const& sub = subsample(iSub);
451  for (auto const [ i, sample ]: util::enumerate(sub))
452  out << " [" << i << "] " << sample;
453  } // for
454  out << "\n";
455 } // util::SampledFunction<>::dump()
gsl::index size() const
Returns the number of samples (in each subsample).
X_t upper() const
Returns the upper limit of the covered range.
X_t lower() const
Returns the lower limit of the covered range.
gsl::index nSubsamples() const
Returns the number of subsamples.
X_t substepSize() const
Returns the base offset of the subsamples.
X_t rangeSize() const
Returns the extension of the covered range.
X_t stepSize() const
Returns the extension of a step.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:285
SubsampleData_t subsample(gsl::index const n) const
Returns the data of the subsample with the specified index n.
std::string sub(const std::string &a, const std::string &b)
Definition: TruthText.cxx:100
template<typename XType, typename YType>
template<typename Stream >
void util::SampledFunction< XType, YType >::dump ( Stream &&  out,
std::string const &  indent = "" 
) const
inline

Dumps the full content of the sampling into out stream.

Definition at line 293 of file SampledFunction.h.

294  { dump(std::forward<Stream>(out), indent, indent); }
void dump(Stream &&out, std::string const &indent, std::string const &firstIndent) const
Dumps the full content of the sampling into out stream.
template<typename XType, typename YType>
template<typename UntilFunc >
static Range_t util::SampledFunction< XType, YType >::extendRange ( Function_t const &  function,
X_t  lower,
X_t  min_upper,
X_t  step,
UntilFunc &&  until 
)
staticprivate

Returns a range including at least from lower to min_upper, extended enough that until(upper, f(upper)) is true, and with an integral number of steps.

template<typename XType, typename YType>
template<typename UntilFunc >
auto util::SampledFunction< XType, YType >::extendRange ( Function_t const &  function,
X_t  lower,
X_t  min_upper,
X_t  step,
UntilFunc &&  until 
) -> Range_t

Definition at line 481 of file SampledFunction.h.

485 {
486  assert(min_upper >= lower);
487  auto const startSamples
488  = static_cast<gsl::index>(std::ceil((min_upper - lower) / step));
489 
490  auto const endStep
491  = [lower, step](gsl::index iStep){ return lower + step * iStep; };
492 
493  Range_t r { lower, endStep(startSamples), step, startSamples };
494 
495  while (!until(r.upper + r.step, function(r.upper + r.step))) {
496  // upper + step is not too much: extend to there
497  ++r.nSamples;
498  r.upper = endStep(r.nSamples);
499  } // while
500 
501  return r;
502 } // util::SampledFunction<>::extendRange()
X_t lower() const
Returns the lower limit of the covered range.
esac echo uname r
template<typename XType , typename YType >
void util::SampledFunction< XType, YType >::fillSamples ( Function_t const &  function)
private

Samples the function and fills the internal caches.

Definition at line 508 of file SampledFunction.h.

509 {
510 
511  /*
512  * Plan:
513  * 0. rely on the currently stored size specifications (range and samples)
514  * 1. resize the data structure to the required size
515  * 2. fill all the subsamples, in sequence
516  *
517  */
518 
519  //
520  // 0. rely on the currently stored size specifications (range and samples)
521  //
522  std::size_t const dataSize = computeTotalSize();
523  assert(dataSize > 0U);
524  assert(fLower <= fUpper);
525  assert(fStep > X_t{0});
526 
527  //
528  // 1. resize the data structure to the required size
529  //
530  fAllSamples.resize(dataSize);
531 
532  //
533  // 2. fill all the subsamples, in sequence
534  //
535  auto iValue = fAllSamples.begin();
536  for (gsl::index const iSubsample: util::counter(nSubsamples())) {
537  X_t const offset = subsampleOffset(iSubsample);
538  for (gsl::index const iStep: util::counter(size())) {
539  X_t const x = offset + iStep * stepSize();
540  Y_t const y = function(x);
541  *iValue++ = y;
542  } // for steps
543  } // for subsamples
544 
545 } // util::SampledFunction<>::fillSamples()
gsl::index size() const
Returns the number of samples (in each subsample).
std::vector< Y_t > fAllSamples
All samples, the entire first subsample first.
BEGIN_PROLOG TPC Trig offset(g4 rise time) ProjectToHeight
Definition: CORSIKAGen.fcl:7
X_t subsampleOffset(gsl::index n) const
Returns the starting point of the subsample n.
X_t fLower
Lower limit of sampled range.
process_name opflash particleana ie x
gsl::index nSubsamples() const
Returns the number of subsamples.
XType X_t
Type of value accepted by the function.
X_t stepSize() const
Returns the extension of a step.
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:285
process_name opflash particleana ie ie y
std::size_t computeTotalSize() const
Computes the total size of the data.
YType Y_t
Type of value returned by the function.
X_t fUpper
Upper limit of sampled range.
template<typename XType, typename YType>
bool util::SampledFunction< XType, YType >::isValidStepIndex ( gsl::index const  index) const
inline

Returns whether the specified step index is valid.

Definition at line 255 of file SampledFunction.h.

256  { return (index >= 0) && (index < size()); }
gsl::index size() const
Returns the number of samples (in each subsample).
template<typename XType, typename YType>
X_t util::SampledFunction< XType, YType >::lower ( ) const
inline

Returns the lower limit of the covered range.

Definition at line 193 of file SampledFunction.h.

193 { return fLower; }
X_t fLower
Lower limit of sampled range.
template<typename XType, typename YType>
gsl::index util::SampledFunction< XType, YType >::nSubsamples ( ) const
inline

Returns the number of subsamples.

Definition at line 188 of file SampledFunction.h.

188 { return fNSubsamples; }
gsl::index fNSubsamples
Number of subsamples.
template<typename XType, typename YType>
X_t util::SampledFunction< XType, YType >::rangeSize ( ) const
inline

Returns the extension of the covered range.

Definition at line 203 of file SampledFunction.h.

203 { return upper() - lower(); }
X_t upper() const
Returns the upper limit of the covered range.
X_t lower() const
Returns the lower limit of the covered range.
template<typename XType, typename YType>
gsl::index util::SampledFunction< XType, YType >::size ( ) const
inline

Returns the number of samples (in each subsample).

Definition at line 183 of file SampledFunction.h.

183 { return fNSamples; }
gsl::index fNSamples
Number of samples in the range.
template<typename XType , typename YType >
gsl::index util::SampledFunction< XType, YType >::stepIndex ( X_t const  x,
gsl::index const  iSubsample 
) const

Returns the index of the step including x.

Parameters
xthe argument to the function
iSubsamplethe index of the subsample
Returns
the index of step including x, or npos if none does

This function returns the index of the sample whose step includes x. A step includes its lower limit but not its upper limit, which usually belongs to the next step (or it does not belong to any valid step). If there is no step including x, the index of the would-be step is returned (it can be checked e.g. with isValidStepIndex()).

Definition at line 415 of file SampledFunction.h.

416 {
417  auto const dx = static_cast<double>(x - subsampleOffset(iSubsample));
418  return static_cast<gsl::index>(std::floor(dx / stepSize()));
419 } // gsl::index util::SampledFunction<XType, YType>::stepIndex()
X_t subsampleOffset(gsl::index n) const
Returns the starting point of the subsample n.
process_name opflash particleana ie x
X_t stepSize() const
Returns the extension of a step.
template<typename XType, typename YType>
X_t util::SampledFunction< XType, YType >::stepSize ( ) const
inline

Returns the extension of a step.

Definition at line 208 of file SampledFunction.h.

208 { return fStep; }
template<typename XType, typename YType>
SubsampleData_t util::SampledFunction< XType, YType >::subsample ( gsl::index const  n) const
inline

Returns the data of the subsample with the specified index n.

Definition at line 233 of file SampledFunction.h.

234  { return { subsampleData(n), static_cast<std::size_t>(fNSamples) }; }
gsl::index fNSamples
Number of samples in the range.
Y_t const * subsampleData(gsl::index n) const
Start of the block of values for subsample n (unchecked).
template<typename XType, typename YType>
Y_t const* util::SampledFunction< XType, YType >::subsampleData ( gsl::index  n) const
inlineprivate

Start of the block of values for subsample n (unchecked).

Definition at line 327 of file SampledFunction.h.

328  { return fAllSamples.data() + fNSamples * n; }
gsl::index fNSamples
Number of samples in the range.
std::vector< Y_t > fAllSamples
All samples, the entire first subsample first.
template<typename XType, typename YType>
Y_t* util::SampledFunction< XType, YType >::subsampleData ( gsl::index  n)
inlineprivate

Definition at line 329 of file SampledFunction.h.

329 { return fAllSamples.data() + fNSamples * n; }
gsl::index fNSamples
Number of samples in the range.
std::vector< Y_t > fAllSamples
All samples, the entire first subsample first.
template<typename XType, typename YType>
X_t util::SampledFunction< XType, YType >::subsampleOffset ( gsl::index  n) const
inlineprivate

Returns the starting point of the subsample n.

Definition at line 321 of file SampledFunction.h.

322  { return lower() + substepSize() * n; }
X_t lower() const
Returns the lower limit of the covered range.
X_t substepSize() const
Returns the base offset of the subsamples.
template<typename XType, typename YType>
X_t util::SampledFunction< XType, YType >::substepSize ( ) const
inline

Returns the base offset of the subsamples.

Definition at line 213 of file SampledFunction.h.

213 { return stepSize() / nSubsamples(); }
gsl::index nSubsamples() const
Returns the number of subsamples.
X_t stepSize() const
Returns the extension of a step.
template<typename XType, typename YType>
X_t util::SampledFunction< XType, YType >::upper ( ) const
inline

Returns the upper limit of the covered range.

Definition at line 198 of file SampledFunction.h.

198 { return fUpper; }
X_t fUpper
Upper limit of sampled range.
template<typename XType, typename YType>
Y_t util::SampledFunction< XType, YType >::value ( gsl::index  iSample,
gsl::index  n = 0U 
) const
inline

Returns the iSample value of the subsample with the specified index n.

Definition at line 226 of file SampledFunction.h.

227  { return subsampleData(n)[iSample]; }
Y_t const * subsampleData(gsl::index n) const
Start of the block of values for subsample n (unchecked).
template<typename XType , typename YType >
template<typename T >
T util::SampledFunction< XType, YType >::wrapUp ( value,
range 
)
staticprivate

Returns value made non-negative by adding multiples of range.

Definition at line 551 of file SampledFunction.h.

551  {
552  while (value < T{ 0 }) value += range;
553  return value;
554 } // util::SampledFunction<>::wrapUp()
Y_t value(gsl::index iSample, gsl::index n=0U) const
Returns the iSample value of the subsample with the specified index n.

Member Data Documentation

template<typename XType, typename YType>
std::vector<Y_t> util::SampledFunction< XType, YType >::fAllSamples
private

All samples, the entire first subsample first.

Definition at line 314 of file SampledFunction.h.

template<typename XType, typename YType>
X_t util::SampledFunction< XType, YType >::fLower
private

Lower limit of sampled range.

Definition at line 306 of file SampledFunction.h.

template<typename XType, typename YType>
gsl::index util::SampledFunction< XType, YType >::fNSamples
private

Number of samples in the range.

Definition at line 308 of file SampledFunction.h.

template<typename XType, typename YType>
gsl::index util::SampledFunction< XType, YType >::fNSubsamples
private

Number of subsamples.

Definition at line 309 of file SampledFunction.h.

template<typename XType, typename YType>
X_t util::SampledFunction< XType, YType >::fStep
private

Step size.

Definition at line 311 of file SampledFunction.h.

template<typename XType, typename YType>
X_t util::SampledFunction< XType, YType >::fUpper
private

Upper limit of sampled range.

Definition at line 307 of file SampledFunction.h.

template<typename XType, typename YType>
constexpr auto util::SampledFunction< XType, YType >::npos = std::numeric_limits<gsl::index>::max()
static

Invalid index of sample, returned in case of error.

Definition at line 100 of file SampledFunction.h.


The documentation for this class was generated from the following file: