40 const auto& p1 =
dynamic_cast<const Polynomial&
>(f1);
41 const auto& p2 =
dynamic_cast<const Polynomial&
>(f2);
45 for (
size_t i = 0; i < c1.
size(); ++i)
46 for (
size_t j = 0; j < c2.
size(); ++j)
47 resultCoef[i + j] += c1[i] * c2[j];
54 const auto& piecewise =
dynamic_cast<const Piecewise&
>(f1);
55 const auto& interval_functions = piecewise.
getFunctions();
63template <
typename Iter>
65 for (
auto i1 = start1, i2 = start2; i1 != end1 && i2 != end2;) {
68 if (i1 != end1 && *i1 > *i2) {
73 if (i2 != end2 && *i1 < *i2) {
84 std::vector<double>::const_iterator p1Iter;
85 std::vector<double>::const_iterator p2Iter;
88 while (p1Iter != knots1.
end() && p2Iter != knots2.
end()) {
89 if (*p1Iter < *p2Iter) {
90 knotSet.insert(*p1Iter);
93 knotSet.insert(*p2Iter);
102 const auto& p1 =
dynamic_cast<const Piecewise&
>(f1);
103 const auto& p2 =
dynamic_cast<const Piecewise&
>(f2);
112 auto& p1func = p1.getFunctions();
113 auto& p2func = p2.getFunctions();
116 for (
double knot : knots) {
117 if (knot == knots.back()) {
120 while (p1.getKnots()[i1 + 1] <= knot) {
123 while (p2.getKnots()[i2 + 1] <= knot) {
Interface class representing a function with an arbitrary number of parameters.
Represents a piecewise function.
const std::vector< std::unique_ptr< Function > > & getFunctions() const
Returns the functions in the ranges between the knots.
Represents a polynomial function.
std::vector< double > overlappingKnots(const std::vector< double > &knots1, const std::vector< double > &knots2)
Returns a vector of the overlapping knots from the given vectors.
ELEMENTS_API std::map< std::pair< std::type_index, std::type_index >, MultiplyFunction > multiplySpecificSpecificMap
std::unique_ptr< Function >(* MultiplyFunction)(const Function &, const Function &)
Alias of a function which multiplies Function objects.
ELEMENTS_API std::map< std::type_index, MultiplyFunction > multiplySpecificGenericMap
static std::pair< Iter, Iter > overlappingStart(Iter start1, Iter end1, Iter start2, Iter end2)
std::unique_ptr< Function > multiplyPolynomials(const Function &f1, const Function &f2)
Function for multiplying two Polynomials. It multiplies their coefficients.
std::unique_ptr< Function > multiplyPiecewiseWithGeneric(const Function &f1, const Function &f2)
std::unique_ptr< Function > multiplyPiecewises(const Function &f1, const Function &f2)
ELEMENTS_API std::unique_ptr< Function > multiply(const Function &f1, const Function &f2)
std::unique_ptr< T > make_unique(Args &&... args)
Constructs an object of type T and wraps it in a std::unique_ptr using args as the parameter list for...