29 for (
unsigned int i = 1; i < dim; ++i)
47 std::array<unsigned int, 1>
51 return {{index_map[i]}};
57 std::array<unsigned int, 2>
61 const unsigned int n = index_map[i];
66 const unsigned int n_1d = polynomials.size();
68 for (
unsigned int iy = 0; iy < n_1d; ++iy)
69 if (n < k + n_1d - iy)
83 std::array<unsigned int, 3>
87 const unsigned int n = index_map[i];
95 const unsigned int n_1d = polynomials.size();
97 for (
unsigned int iz = 0; iz < n_1d; ++iz)
98 for (
unsigned int iy = 0; iy < n_1d - iz; ++iy)
99 if (n < k + n_1d - iy - iz)
101 return {{n - k, iy, iz}};
119 for (
unsigned int i = 0; i <
index_map.size(); ++i)
135 for (
unsigned int d = 0;
d < dim; ++
d)
150 for (
unsigned int d = 0;
d < dim; ++
d)
154 std::vector<double> v(2);
155 for (
unsigned int d = 0;
d < dim; ++
d)
159 for (
unsigned int d1 = 0; d1 < dim; ++d1)
175 for (
unsigned int d = 0;
d < dim; ++
d)
176 for (
unsigned int d1 = 0; d1 < dim; ++d1)
181 std::vector<double> v(3);
182 for (
unsigned int d = 0;
d < dim; ++
d)
185 result[
d][
d] *= v[2];
186 for (
unsigned int d1 = 0; d1 < dim; ++d1)
190 result[
d][d1] *= v[1];
191 result[d1][
d] *= v[1];
192 for (
unsigned int d2 = 0; d2 < dim; ++d2)
194 result[d1][d2] *= v[0];
206 std::vector<double> & values,
214 Assert(values.size() == this->n() || values.size() == 0,
216 Assert(grads.size() == this->n() || grads.size() == 0,
218 Assert(grad_grads.size() == this->n() || grad_grads.size() == 0,
220 Assert(third_derivatives.size() == this->n() || third_derivatives.size() == 0,
222 Assert(fourth_derivatives.size() == this->n() ||
223 fourth_derivatives.size() == 0,
226 unsigned int v_size = 0;
227 bool update_values =
false, update_grads =
false, update_grad_grads =
false;
229 if (values.size() == this->n())
234 if (grads.size() == this->n())
239 if (grad_grads.size() == this->n())
241 update_grad_grads =
true;
244 if (third_derivatives.size() == this->n())
249 if (fourth_derivatives.size() == this->n())
251 update_4th_derivatives =
true;
262 for (
unsigned int d = 0;
d < v.
size()[0]; ++
d)
263 for (
unsigned int i = 0; i < v.
size()[1]; ++i)
265 v(
d, i).resize(v_size, 0.);
273 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
274 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
275 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
277 ((dim > 1) ? v[1][iy][0] : 1.) *
278 ((dim > 2) ? v[2][iz][0] : 1.);
285 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
286 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
287 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
290 for (
unsigned int d = 0;
d < dim; ++
d)
291 grads[k2][
d] = v[0][ix][(
d == 0) ? 1 : 0] *
292 ((dim > 1) ? v[1][iy][(
d == 1) ? 1 : 0] : 1.) *
293 ((dim > 2) ? v[2][iz][(
d == 2) ? 1 : 0] : 1.);
297 if (update_grad_grads)
301 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
302 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
303 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
306 for (
unsigned int d1 = 0; d1 < dim; ++d1)
307 for (
unsigned int d2 = 0; d2 < dim; ++d2)
312 const unsigned int j0 =
313 ((d1 == 0) ? 1 : 0) + ((d2 == 0) ? 1 : 0);
314 const unsigned int j1 =
315 ((d1 == 1) ? 1 : 0) + ((d2 == 1) ? 1 : 0);
316 const unsigned int j2 =
317 ((d1 == 2) ? 1 : 0) + ((d2 == 2) ? 1 : 0);
319 grad_grads[k2][d1][d2] = v[0][ix][j0] *
320 ((dim > 1) ? v[1][iy][j1] : 1.) *
321 ((dim > 2) ? v[2][iz][j2] : 1.);
330 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
331 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
332 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
335 for (
unsigned int d1 = 0; d1 < dim; ++d1)
336 for (
unsigned int d2 = 0; d2 < dim; ++d2)
337 for (
unsigned int d3 = 0; d3 < dim; ++d3)
342 std::vector<unsigned int> deriv_order(dim, 0);
343 for (
unsigned int x = 0; x < dim; ++x)
353 third_derivatives[k2][d1][d2][d3] =
354 v[0][ix][deriv_order[0]] *
355 ((dim > 1) ? v[1][iy][deriv_order[1]] : 1.) *
356 ((dim > 2) ? v[2][iz][deriv_order[2]] : 1.);
361 if (update_4th_derivatives)
365 for (
unsigned int iz = 0; iz < ((dim > 2) ? n_1d : 1); ++iz)
366 for (
unsigned int iy = 0; iy < ((dim > 1) ? n_1d - iz : 1); ++iy)
367 for (
unsigned int ix = 0; ix < n_1d - iy - iz; ++ix)
370 for (
unsigned int d1 = 0; d1 < dim; ++d1)
371 for (
unsigned int d2 = 0; d2 < dim; ++d2)
372 for (
unsigned int d3 = 0; d3 < dim; ++d3)
373 for (
unsigned int d4 = 0; d4 < dim; ++d4)
378 std::vector<unsigned int> deriv_order(dim, 0);
379 for (
unsigned int x = 0; x < dim; ++x)
391 fourth_derivatives[k2][d1][d2][d3][d4] =
392 v[0][ix][deriv_order[0]] *
393 ((dim > 1) ? v[1][iy][deriv_order[1]] : 1.) *
394 ((dim > 2) ? v[2][iz][deriv_order[2]] : 1.);
403 std::unique_ptr<ScalarPolynomialsBase<dim>>
406 return std_cxx14::make_unique<PolynomialSpace<dim>>(*this);