35 if (m_knots.size() - m_functions.size() != 1) {
37 <<
")-functions(" << m_functions.size() <<
")";
39 auto knotsIter = m_knots.begin();
40 while (++knotsIter != m_knots.end()) {
41 if (*knotsIter <= *(knotsIter-1)) {
57 if (x < *knotsBegin) {
60 if (x == *knotsBegin) {
65 if (findX == knotsEnd) {
94 auto prevKnotIter = knotIter - 1;
95 if (max <= *prevKnotIter) {
98 if (min < *knotIter) {
99 double down = (min > *prevKnotIter) ? min : *prevKnotIter;
100 double up = (max < *knotIter) ? max : *knotIter;
105 return direction * result;
std::unique_ptr< Function > clone() const override
const std::vector< double > & getKnots() const
Returns the knots of the piecewise function.
double operator()(const double) const override
std::vector< double > m_knots
A vector where the knots are kept.
const std::vector< std::shared_ptr< Function > > & getFunctions() const
Returns the functions in the ranges between the knots.
Piecewise(std::vector< double > knots, std::vector< std::shared_ptr< Function >> functions)
ELEMENTS_API double integrate(const Function &function, const double min, const double max, std::unique_ptr< NumericalIntegrationScheme > numericalIntegrationScheme=nullptr)
std::vector< std::shared_ptr< Function > > m_functions
A vector where the sub-functions are kept.
double integrate(const double x1, const double x2) const override