54 EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
55 static_assert(Size >= 0,
"Stencil requires a fixed-size point set");
56 static_assert(Derivative >= 0 && Derivative < Size,
"Stencil requires at least `Derivative + 1` points");
59 static constexpr int DerivativeOrder = Derivative;
60 static constexpr int PointCount = Size;
67 template <
typename Derived>
69 static_assert(Derived::IsVectorAtCompileTime,
"Stencil requires a 1D dense expression");
70 static_assert(Derived::SizeAtCompileTime == Size,
"Stencil requires exactly `Size` points");
71 for (Index i = 0; i < Size; ++i) m_points[i] =
points.coeff(i);
79 for (Index i = 0; i < Size; ++i) m_points[i] =
points[i];
92 constexpr const Scalar&
weight(Index i)
const {
return m_weights[i]; }
96 constexpr const Scalar&
point(Index i)
const {
return m_points[i]; }
103 constexpr void computeWeights() {
104 Scalar delta[Size][Derivative + 1]{};
105 delta[0][0] = Scalar(1);
107 for (Index n = 1; n < Size; ++n) {
108 const Index mn = numext::mini(n, Index(Derivative));
109 const Scalar c4 = m_points[n];
113 for (Index nu = 0; nu < n; ++nu) {
114 const Scalar c3 = m_points[n] - m_points[nu];
115 eigen_assert(!(c3 == Scalar(0)) &&
"Stencil points must be pairwise distinct");
118 delta[n][0] = -ratio * (m_points[n - 1] * delta[n - 1][0]);
119 for (Index m = mn; m >= 1; --m)
120 delta[n][m] = ratio * (Scalar(m) * delta[n - 1][m - 1] - m_points[n - 1] * delta[n - 1][m]);
122 ratio *= (m_points[n - 1] - m_points[nu]) / c3;
124 for (Index m = mn; m >= 1; --m) delta[nu][m] = (c4 * delta[nu][m] - Scalar(m) * delta[nu][m - 1]) / c3;
125 delta[nu][0] = c4 * delta[nu][0] / c3;
129 for (Index nu = 0; nu < Size; ++nu) m_weights[nu] = delta[nu][Derivative];
134 Scalar m_points[Size]{};
135 Scalar m_weights[Size]{};