3 #include <fluxionum/Function.h>
27 template <
typename A,
typename B>
79 B
eval(A
const &x)
override{
122 arma::Col<A>
const &
start
124 size_t const m =
start.n_elem-1;
125 for(
size_t i = m ; i > 0 ; --i)
if(x >=
start.at(i))
return i;
Abstract class representing a function.
Definition: Function.h:27
Linear pieces function.
Definition: LinearPiecesFunction.h:28
B getIntercept(size_t const i=0) const
Obtain the -th intercept of the linear function.
Definition: LinearPiecesFunction.h:107
B eval(A const &x) override
Calculate the image of by assuming a linear behavior where is the slope and is the intercept.
Definition: LinearPiecesFunction.h:79
arma::Col< A > const & start
The set of sorted start points.
Definition: LinearPiecesFunction.h:36
static size_t findIndex(A const &x, arma::Col< A > const &start)
Assist the LinearPiecesFunction::findIndex(A const &)
Definition: LinearPiecesFunction.h:120
B getSlope(size_t const i=0) const
Obtain the -th slope of the linear function.
Definition: LinearPiecesFunction.h:100
size_t findIndex(A const &x) const
Obtain the index identifying the interval where belongs to. It is, find such that .
Definition: LinearPiecesFunction.h:115
LinearPiecesFunction(Col< A > const &start, Col< B > const &slope, Col< B > const &intercept)
LinearPiecesFunction default constructor.
Definition: LinearPiecesFunction.h:55
arma::Col< B > const & slope
The slopes for each piece .
Definition: LinearPiecesFunction.h:40
A getStart(size_t const i=0) const
Obtain the -th start point of the linear function.
Definition: LinearPiecesFunction.h:93
arma::Col< B > const & intercept
The intercepts for each piece .
Definition: LinearPiecesFunction.h:44