238 if (grad_grads.size() == this->n())
240 update_grad_grads =
true;
243 if (third_derivatives.size() == this->n())
248 if (fourth_derivatives.size() == this->n())
250 update_4th_derivatives =
true;
261 for (
unsigned int d = 0;
d < v.size()[0]; ++
d)
262 for (
unsigned int i = 0; i < v.size()[1]; ++i)
264 v(d, i).resize(v_size, 0.);
265 polynomials[i].value(p[d], v(d, i));
272 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
273 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
274 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
275 values[index_map_inverse[k++]] = v[0][ix][0] *
276 ((dim > 1) ? v[1][iy][0] : 1.) *
277 ((dim > 2) ? v[2][iz][0] : 1.);
284 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
285 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
286 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
288 const unsigned int k2 = index_map_inverse[k++];
289 for (
unsigned int d = 0;
d < dim; ++
d)
290 grads[k2][d] = v[0][ix][(d == 0) ? 1 : 0] *
291 ((dim > 1) ? v[1][iy][(d == 1) ? 1 : 0] : 1.) *
292 ((dim > 2) ? v[2][iz][(
d == 2) ? 1 : 0] : 1.);
296 if (update_grad_grads)
300 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
301 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
302 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
304 const unsigned int k2 = index_map_inverse[k++];
305 for (
unsigned int d1 = 0; d1 < dim; ++d1)
306 for (
unsigned int d2 = 0; d2 < dim; ++d2)
311 const unsigned int j0 =
312 ((d1 == 0) ? 1 : 0) + ((d2 == 0) ? 1 : 0);
313 const unsigned int j1 =
314 ((d1 == 1) ? 1 : 0) + ((d2 == 1) ? 1 : 0);
315 const unsigned int j2 =
316 ((d1 == 2) ? 1 : 0) + ((d2 == 2) ? 1 : 0);
318 grad_grads[k2][d1][d2] = v[0][ix][j0] *
319 ((dim > 1) ? v[1][iy][j1] : 1.) *
320 ((dim > 2) ? v[2][iz][j2] : 1.);
329 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
330 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
331 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
333 const unsigned int k2 = index_map_inverse[k++];
334 for (
unsigned int d1 = 0; d1 < dim; ++d1)
335 for (
unsigned int d2 = 0; d2 < dim; ++d2)
336 for (
unsigned int d3 = 0; d3 < dim; ++d3)
341 std::vector<unsigned int> deriv_order(dim, 0);
342 for (
unsigned int x = 0; x < dim; ++x)
352 third_derivatives[k2][d1][d2][d3] =
353 v[0][ix][deriv_order[0]] *
354 ((dim > 1) ? v[1][iy][deriv_order[1]] : 1.) *
355 ((dim > 2) ? v[2][iz][deriv_order[2]] : 1.);
360 if (update_4th_derivatives)
364 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
365 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
366 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
368 const unsigned int k2 = index_map_inverse[k++];
369 for (
unsigned int d1 = 0; d1 < dim; ++d1)
370 for (
unsigned int d2 = 0; d2 < dim; ++d2)
371 for (
unsigned int d3 = 0; d3 < dim; ++d3)
372 for (
unsigned int d4 = 0; d4 < dim; ++d4)
377 std::vector<unsigned int> deriv_order(dim, 0);
378 for (
unsigned int x = 0; x < dim; ++x)
390 fourth_derivatives[k2][d1][d2][d3][d4] =
391 v[0][ix][deriv_order[0]] *
392 ((dim > 1) ? v[1][iy][deriv_order[1]] : 1.) *
393 ((dim > 2) ? v[2][iz][deriv_order[2]] : 1.);
402std::unique_ptr<ScalarPolynomialsBase<dim>>
405 return std::make_unique<PolynomialSpace<dim>>(*this);