82 const unsigned int n_derivatives,
85 if (points.size() > 0)
87 if (x > points[index])
88 values[0] = std::max<number>(0.0,
89 1.0 - (x - points[index]) *
90 one_over_lengths[index]);
91 else if (x < points[index])
92 values[0] = std::max<number>(0.0,
93 0.0 + (x - points[index - 1]) *
94 one_over_lengths[index - 1]);
98 if (n_derivatives >= 1)
100 if ((x > points[index]) && (points[index + 1] >= x))
101 values[1] = -1.0 * one_over_lengths[index];
102 else if ((x < points[index]) && (points[index - 1] <= x))
103 values[1] = +1.0 * one_over_lengths[index - 1];
109 for (
unsigned int i = 2; i <= n_derivatives; ++i)
117 double derivative_change_sign = 1.;
120 const number step = 1. / n_intervals;
122 if (spans_two_intervals)
124 const double offset = step * interval;
125 if (x < offset || x > offset + step + step)
127 for (
unsigned int k = 0; k <= n_derivatives; ++k)
131 else if (x < offset + step)
135 derivative_change_sign = -1.;
136 y = offset + step + step - x;
141 const double offset = step * interval;
147 for (
unsigned int k = 0; k <= n_derivatives; ++k)
151 else if (x > offset + step)
153 for (
unsigned int k = 0; k <= n_derivatives; ++k)
164 (interval > 0 || derivative_change_sign == -1.)) ||
166 (interval < n_intervals - 1 || derivative_change_sign == -1.)))
168 values[0] = value(x);
169 for (
unsigned int d = 1; d <= n_derivatives; ++d)
175 polynomial.value(y, n_derivatives, values);
178 for (
unsigned int j = 1; j <= n_derivatives; j += 2)
179 values[j] *= derivative_change_sign;
200 const unsigned int n_subdivisions,
201 const unsigned int base_degree)
203 std::vector<Polynomial<double>> p_base =
205 for (
auto &polynomial : p_base)
206 polynomial.scale(n_subdivisions);
208 std::vector<PiecewisePolynomial<double>> p;
209 p.reserve(n_subdivisions * base_degree + 1);
211 p.emplace_back(p_base[0], n_subdivisions, 0,
false);
212 for (
unsigned int s = 0; s < n_subdivisions; ++s)
213 for (
unsigned int i = 0; i < base_degree; ++i)
214 p.emplace_back(p_base[i + 1],
217 i == (base_degree - 1) && s < n_subdivisions - 1);