240 if (grad_grads.size() == this->n())
242 update_grad_grads =
true;
245 if (third_derivatives.size() == this->n())
250 if (fourth_derivatives.size() == this->n())
252 update_4th_derivatives =
true;
263 for (
unsigned int d = 0;
d < v.size()[0]; ++
d)
264 for (
unsigned int i = 0; i < v.size()[1]; ++i)
266 v(d, i).resize(v_size, 0.);
267 polynomials[i].value(p(d), v(d, i));
274 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
275 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
276 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
277 values[index_map_inverse[k++]] = v[0][ix][0] *
278 ((dim > 1) ? v[1][iy][0] : 1.) *
279 ((dim > 2) ? v[2][iz][0] : 1.);
286 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
287 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
288 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
290 const unsigned int k2 = index_map_inverse[k++];
291 for (
unsigned int d = 0;
d < dim; ++
d)
292 grads[k2][d] = v[0][ix][(d == 0) ? 1 : 0] *
293 ((dim > 1) ? v[1][iy][(d == 1) ? 1 : 0] : 1.) *
294 ((dim > 2) ? v[2][iz][(
d == 2) ? 1 : 0] : 1.);
298 if (update_grad_grads)
302 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
303 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
304 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
306 const unsigned int k2 = index_map_inverse[k++];
307 for (
unsigned int d1 = 0; d1 < dim; ++d1)
308 for (
unsigned int d2 = 0; d2 < dim; ++d2)
313 const unsigned int j0 =
314 ((d1 == 0) ? 1 : 0) + ((d2 == 0) ? 1 : 0);
315 const unsigned int j1 =
316 ((d1 == 1) ? 1 : 0) + ((d2 == 1) ? 1 : 0);
317 const unsigned int j2 =
318 ((d1 == 2) ? 1 : 0) + ((d2 == 2) ? 1 : 0);
320 grad_grads[k2][d1][d2] = v[0][ix][j0] *
321 ((dim > 1) ? v[1][iy][j1] : 1.) *
322 ((dim > 2) ? v[2][iz][j2] : 1.);
331 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
332 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
333 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
335 const unsigned int k2 = index_map_inverse[k++];
336 for (
unsigned int d1 = 0; d1 < dim; ++d1)
337 for (
unsigned int d2 = 0; d2 < dim; ++d2)
338 for (
unsigned int d3 = 0; d3 < dim; ++d3)
343 std::vector<unsigned int> deriv_order(dim, 0);
344 for (
unsigned int x = 0; x < dim; ++x)
354 third_derivatives[k2][d1][d2][d3] =
355 v[0][ix][deriv_order[0]] *
356 ((dim > 1) ? v[1][iy][deriv_order[1]] : 1.) *
357 ((dim > 2) ? v[2][iz][deriv_order[2]] : 1.);
362 if (update_4th_derivatives)
366 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
367 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
368 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
370 const unsigned int k2 = index_map_inverse[k++];
371 for (
unsigned int d1 = 0; d1 < dim; ++d1)
372 for (
unsigned int d2 = 0; d2 < dim; ++d2)
373 for (
unsigned int d3 = 0; d3 < dim; ++d3)
374 for (
unsigned int d4 = 0; d4 < dim; ++d4)
379 std::vector<unsigned int> deriv_order(dim, 0);
380 for (
unsigned int x = 0; x < dim; ++x)
392 fourth_derivatives[k2][d1][d2][d3][d4] =
393 v[0][ix][deriv_order[0]] *
394 ((dim > 1) ? v[1][iy][deriv_order[1]] : 1.) *
395 ((dim > 2) ? v[2][iz][deriv_order[2]] : 1.);
404std::unique_ptr<ScalarPolynomialsBase<dim>>
407 return std::make_unique<PolynomialSpace<dim>>(*this);