4 #include <sll/mapping/barycentric_coordinates.hpp>
5 #include <sll/math_tools.hpp>
6 #include <sll/view.hpp>
20 static constexpr std::size_t rank()
25 static constexpr std::size_t degree() noexcept
30 static constexpr std::size_t nbasis()
32 return (D + 1) * (D + 2) / 2;
35 template <
class DDim,
class MemorySpace>
38 template <
class ODDim,
class OMemorySpace>
48 using discrete_element_type = ddc::DiscreteElement<DDim>;
50 using discrete_domain_type = ddc::DiscreteDomain<DDim>;
52 using discrete_vector_type = ddc::DiscreteVector<DDim>;
59 Corner3Tag>
const& coord_changer)
60 : m_coord_changer(coord_changer)
64 template <
class OriginMemorySpace>
66 : m_coord_changer(impl.m_coord_changer)
76 Impl& operator=(
Impl const& x) =
default;
81 ddc::ChunkSpan<
double, ddc::DiscreteDomain<DDim>> values,
82 ddc::Coordinate<Tag1, Tag2>
const& x)
const;
93 template <
class DDim,
class MemorySpace>
96 ddc::ChunkSpan<
double, ddc::DiscreteDomain<DDim>> values,
97 ddc::Coordinate<Tag1, Tag2>
const& x)
const
99 const ddc::Coordinate<Corner1Tag, Corner2Tag, Corner3Tag> bary_coords = m_coord_changer(x);
100 const double l1 = ddc::get<Corner1Tag>(bary_coords);
101 const double l2 = ddc::get<Corner2Tag>(bary_coords);
102 const double l3 = ddc::get<Corner3Tag>(bary_coords);
103 assert(values.size() == nbasis());
105 ddc::DiscreteElement<DDim> idx(0);
106 for (std::size_t i(0); i < D + 1; ++i) {
107 for (std::size_t j(0); j < D + 1 - i; ++j, ++idx) {
108 const int k = D - i - j;
109 const double multinomial_coefficient
110 = factorial(D) / (factorial(i) * factorial(j) * factorial(k));
111 values(idx) = multinomial_coefficient * ipow(l1, i) * ipow(l2, j) * ipow(l3, k);
Definition: bernstein.hpp:37
Definition: bernstein.hpp:16