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;
142 if (x < offset || x > offset + step)
144 for (
unsigned int k = 0; k <= n_derivatives; ++k)
155 (interval > 0 || derivative_change_sign == -1.)) ||
157 (interval < n_intervals - 1 || derivative_change_sign == -1.)))
159 values[0] = value(x);
160 for (
unsigned int d = 1; d <= n_derivatives; ++d)
166 polynomial.value(y, n_derivatives, values);
169 for (
unsigned int j = 1; j <= n_derivatives; j += 2)
170 values[j] *= derivative_change_sign;
191 const unsigned int n_subdivisions,
192 const unsigned int base_degree)
194 std::vector<Polynomial<double>> p_base =
196 for (
auto &polynomial : p_base)
197 polynomial.scale(n_subdivisions);
199 std::vector<PiecewisePolynomial<double>> p;
200 p.reserve(n_subdivisions * base_degree + 1);
202 p.emplace_back(p_base[0], n_subdivisions, 0,
false);
203 for (
unsigned int s = 0; s < n_subdivisions; ++s)
204 for (
unsigned int i = 0; i < base_degree; ++i)
205 p.emplace_back(p_base[i + 1],
208 i == (base_degree - 1) && s < n_subdivisions - 1);