83 const unsigned int n_derivatives,
84 number * values)
const
86 if (points.size() > 0)
88 if (x > points[index])
89 values[0] = std::max<number>(0.0,
90 1.0 - (x - points[index]) *
91 one_over_lengths[index]);
92 else if (x < points[index])
93 values[0] = std::max<number>(0.0,
94 0.0 + (x - points[index - 1]) *
95 one_over_lengths[index - 1]);
99 if (n_derivatives >= 1)
101 if ((x > points[index]) && (points[index + 1] >= x))
102 values[1] = -1.0 * one_over_lengths[index];
103 else if ((x < points[index]) && (points[index - 1] <= x))
104 values[1] = +1.0 * one_over_lengths[index - 1];
110 for (
unsigned int i = 2; i <= n_derivatives; ++i)
118 double derivative_change_sign = 1.;
121 const number step = 1. / n_intervals;
123 if (spans_two_intervals)
125 const double offset = step * interval;
126 if (x < offset || x > offset + step + step)
128 for (
unsigned int k = 0; k <= n_derivatives; ++k)
132 else if (x < offset + step)
136 derivative_change_sign = -1.;
137 y = offset + step + step - x;
142 const double offset = step * interval;
143 if (x < offset || x > offset + step)
145 for (
unsigned int k = 0; k <= n_derivatives; ++k)
156 (interval > 0 || derivative_change_sign == -1.)) ||
158 (interval < n_intervals - 1 || derivative_change_sign == -1.)))
160 values[0] = value(x);
161 for (
unsigned int d = 1; d <= n_derivatives; ++d)
167 polynomial.value(y, n_derivatives, values);
170 for (
unsigned int j = 1; j <= n_derivatives; j += 2)
171 values[j] *= derivative_change_sign;
192 const unsigned int n_subdivisions,
193 const unsigned int base_degree)
195 std::vector<Polynomial<double>> p_base =
197 for (
auto &polynomial : p_base)
198 polynomial.scale(n_subdivisions);
200 std::vector<PiecewisePolynomial<double>> p;
201 p.reserve(n_subdivisions * base_degree + 1);
203 p.emplace_back(p_base[0], n_subdivisions, 0,
false);
204 for (
unsigned int s = 0; s < n_subdivisions; ++s)
205 for (
unsigned int i = 0; i < base_degree; ++i)
206 p.emplace_back(p_base[i + 1],
209 i == (base_degree - 1) && s < n_subdivisions - 1);