1 #ifndef GRAIL_STEP_FUNCTION_H
2 #define GRAIL_STEP_FUNCTION_H
29 template <
typename ContextType>
43 const std::vector<StepData>& data)
44 :
Curve<ContextType>{childEvaluator}, data{data}
47 assert(data.size() >= 1);
48 float previousX = data[0].startPoint;
49 for (
size_t i = 1; i < data.size(); ++i)
51 assert(previousX < data[i].startPoint);
52 previousX = data[i].startPoint;
57 virtual float Sample(
float argument)
const override final
59 for (std::size_t i = data.size() - 1; i > 0; --i)
61 if (argument > data[i].startPoint || (argument == data[i].startPoint && data[i].inclusiveStartPoint))
73 std::vector<StepData>&
GetData() {
return data; }
78 const std::vector<StepData>&
GetData()
const {
return data; }
80 EvaluatorType GetEvaluatorType() const override final {
return EvaluatorType::CURVE_STAIRCASE; }
83 std::vector<StepData> data{};
The Curve class - Defines objects transforming one value into the other.
Definition: Curve.hh:21
The StaircaseFunction class - Function consisting of multiple discrete values.
Definition: StaircaseFunction.hh:35
const std::vector< StepData > & GetData() const
GetData.
Definition: StaircaseFunction.hh:78
std::vector< StepData > & GetData()
GetData.
Definition: StaircaseFunction.hh:73
StaircaseFunction(std::shared_ptr< utility::Evaluator< ContextType >> childEvaluator, const std::vector< StepData > &data)
StaircaseFunction - Constructor.
Definition: StaircaseFunction.hh:42
virtual float Sample(float argument) const override final
Sample - Transforms argument into output value depending on the type of Curve.
Definition: StaircaseFunction.hh:57
The Evaluator class - base class being able to evaluate given context and output the result.
Definition: Evaluator.hh:21
The StepData struct - Helper structure describing discrete values used in Staircase function.
Definition: StaircaseFunction.hh:14
float startPoint
startPoint - Start point of half-line extending to the right and having constant given value.
Definition: StaircaseFunction.hh:22
float value
value - Y-axis value.
Definition: StaircaseFunction.hh:18
bool inclusiveStartPoint
inclusiveStartPoint - Determines whether exact start point also has given value. If not,...
Definition: StaircaseFunction.hh:26