34 if (m_knots.size() - functions.size() != 1) {
35 throw Elements::Exception() <<
"Invalid number of knots(" << m_knots.size() <<
")-functions(" << m_functions.size() <<
")";
38 m_functions.reserve(functions.size());
42 auto knotsIter = m_knots.begin();
43 while (++knotsIter != m_knots.end()) {
44 if (*knotsIter <= *(knotsIter - 1)) {
52 if (m_knots.size() - m_functions.size() != 1) {
53 throw Elements::Exception() <<
"Invalid number of knots(" << m_knots.size() <<
")-functions(" << m_functions.size() <<
")";
55 auto knotsIter = m_knots.begin();
56 while (++knotsIter != m_knots.end()) {
57 if (*knotsIter <= *(knotsIter - 1)) {
73 if (x < *knotsBegin) {
76 if (x == *knotsBegin) {
81 if (findX == knotsEnd) {
115 auto prevKnotIter = knotIter - 1;
116 if (max <= *prevKnotIter) {
119 if (min < *knotIter) {
120 double down = (min > *prevKnotIter) ? min : *prevKnotIter;
121 double up = (max < *knotIter) ? max : *knotIter;
126 return direction * result;
const std::vector< std::unique_ptr< Function > > & getFunctions() const
Returns the functions in the ranges between the knots.
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.
Piecewise(std::vector< double > knots, std::vector< std::shared_ptr< Function >> functions)
std::vector< std::unique_ptr< Function > > m_functions
A vector where the sub-functions are kept.
ELEMENTS_API double integrate(const Function &function, const double min, const double max, std::unique_ptr< NumericalIntegrationScheme > numericalIntegrationScheme=nullptr)
T back_inserter(T...args)
double integrate(const double x1, const double x2) const override