235 Assert(third_derivatives.size() == this->n() || third_derivatives.empty(),
237 Assert(fourth_derivatives.size() == this->n() || fourth_derivatives.empty(),
240 unsigned int v_size = 0;
241 bool update_values =
false, update_grads =
false, update_grad_grads =
false;
243 if (values.size() == this->n())
248 if (grads.size() == this->n())
253 if (grad_grads.size() == this->n())
255 update_grad_grads =
true;
258 if (third_derivatives.size() == this->n())
263 if (fourth_derivatives.size() == this->n())
265 update_4th_derivatives =
true;
279 std::array<boost::container::small_vector<std::array<double, 5>, 14>, dim> v;
280 for (
unsigned int d = 0;
d < dim; ++
d)
283 for (
unsigned int i = 0; i < n_1d; ++i)
288 v[d][i].fill(std::numeric_limits<double>::signaling_NaN());
289 polynomials[i].value(p[d], v_size - 1, v[d][i].
data());
297 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
298 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
299 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
300 values[index_map_inverse[k++]] = v[0][ix][0] *
301 ((dim > 1) ? v[1][iy][0] : 1.) *
302 ((dim > 2) ? v[2][iz][0] : 1.);
309 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
310 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
311 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
313 const unsigned int k2 = index_map_inverse[k++];
314 for (
unsigned int d = 0;
d < dim; ++
d)
315 grads[k2][d] = v[0][ix][(d == 0) ? 1 : 0] *
316 ((dim > 1) ? v[1][iy][(d == 1) ? 1 : 0] : 1.) *
317 ((dim > 2) ? v[2][iz][(
d == 2) ? 1 : 0] : 1.);
321 if (update_grad_grads)
325 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
326 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
327 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
329 const unsigned int k2 = index_map_inverse[k++];
330 for (
unsigned int d1 = 0; d1 < dim; ++d1)
331 for (
unsigned int d2 = 0; d2 < dim; ++d2)
336 const unsigned int j0 =
337 ((d1 == 0) ? 1 : 0) + ((d2 == 0) ? 1 : 0);
338 const unsigned int j1 =
339 ((d1 == 1) ? 1 : 0) + ((d2 == 1) ? 1 : 0);
340 const unsigned int j2 =
341 ((d1 == 2) ? 1 : 0) + ((d2 == 2) ? 1 : 0);
343 grad_grads[k2][d1][d2] = v[0][ix][j0] *
344 ((dim > 1) ? v[1][iy][j1] : 1.) *
345 ((dim > 2) ? v[2][iz][j2] : 1.);
354 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
355 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
356 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
358 const unsigned int k2 = index_map_inverse[k++];
359 for (
unsigned int d1 = 0; d1 < dim; ++d1)
360 for (
unsigned int d2 = 0; d2 < dim; ++d2)
361 for (
unsigned int d3 = 0; d3 < dim; ++d3)
366 std::array<unsigned int, dim> deriv_order{};
367 for (
unsigned int x = 0; x < dim; ++x)
377 third_derivatives[k2][d1][d2][d3] =
378 v[0][ix][deriv_order[0]] *
379 ((dim > 1) ? v[1][iy][deriv_order[1]] : 1.) *
380 ((dim > 2) ? v[2][iz][deriv_order[2]] : 1.);
385 if (update_4th_derivatives)
389 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
390 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
391 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
393 const unsigned int k2 = index_map_inverse[k++];
394 for (
unsigned int d1 = 0; d1 < dim; ++d1)
395 for (
unsigned int d2 = 0; d2 < dim; ++d2)
396 for (
unsigned int d3 = 0; d3 < dim; ++d3)
397 for (
unsigned int d4 = 0; d4 < dim; ++d4)
402 std::array<unsigned int, dim> deriv_order{};
403 for (
unsigned int x = 0; x < dim; ++x)
415 fourth_derivatives[k2][d1][d2][d3][d4] =
416 v[0][ix][deriv_order[0]] *
417 ((dim > 1) ? v[1][iy][deriv_order[1]] : 1.) *
418 ((dim > 2) ? v[2][iz][deriv_order[2]] : 1.);
427std::unique_ptr<ScalarPolynomialsBase<dim>>
430 return std::make_unique<PolynomialSpace<dim>>(*this);