26 template <
typename number>
29 const unsigned int n_intervals,
30 const unsigned int interval,
31 const bool spans_next_interval)
32 : polynomial(coefficients_on_interval)
33 , n_intervals(n_intervals)
35 , spans_two_intervals(spans_next_interval)
36 , index(
numbers::invalid_unsigned_int)
44 template <
typename number>
47 const unsigned int index)
48 : n_intervals(
numbers::invalid_unsigned_int)
49 , interval(
numbers::invalid_unsigned_int)
50 , spans_two_intervals(false)
57 for (
unsigned int i = 0; i <
points.size(); ++i)
61 for (
unsigned int i = 0; i <
points.size() - 1; ++i)
68 template <
typename number>
71 std::vector<number> &values)
const
75 value(x, values.size() - 1, values.data());
80 template <
typename number>
83 const unsigned int n_derivatives,
84 number * values)
const
86 if (points.size() > 0)
88 if (x > points[index])
89 values[0] = std::max<number>(0.0,
90 1.0 - (x - points[index]) *
91 one_over_lengths[index]);
92 else if (x < points[index])
93 values[0] = std::max<number>(0.0,
94 0.0 + (x - points[index - 1]) *
95 one_over_lengths[index - 1]);
99 if (n_derivatives >= 1)
101 if ((x > points[index]) && (points[index + 1] >= x))
102 values[1] = -1.0 * one_over_lengths[index];
103 else if ((x < points[index]) && (points[index - 1] <= x))
104 values[1] = +1.0 * one_over_lengths[index - 1];
110 for (
unsigned int i = 2; i <= n_derivatives; ++i)
118 double derivative_change_sign = 1.;
121 const number step = 1. / n_intervals;
123 if (spans_two_intervals)
125 const double offset = step * interval;
126 if (x < offset || x > offset + step + step)
128 for (
unsigned int k = 0; k <= n_derivatives; ++k)
132 else if (x < offset + step)
136 derivative_change_sign = -1.;
137 y = offset + step + step - x;
142 const double offset = step * interval;
143 if (x < offset || x > offset + step)
145 for (
unsigned int k = 0; k <= n_derivatives; ++k)
156 (interval > 0 || derivative_change_sign == -1.)) ||
158 (interval < n_intervals - 1 || derivative_change_sign == -1.)))
160 values[0] = value(x);
161 for (
unsigned int d = 1; d <= n_derivatives; ++d)
167 polynomial.value(y, n_derivatives, values);
170 for (
unsigned int j = 1; j <= n_derivatives; j += 2)
171 values[j] *= derivative_change_sign;
176 template <
typename number>
180 return (polynomial.memory_consumption() +
190 std::vector<PiecewisePolynomial<double>>
192 const unsigned int n_subdivisions,
193 const unsigned int base_degree)
195 std::vector<Polynomial<double>> p_base =
197 for (
auto &polynomial : p_base)
198 polynomial.scale(n_subdivisions);
200 std::vector<PiecewisePolynomial<double>> p;
201 p.reserve(n_subdivisions * base_degree + 1);
203 p.emplace_back(p_base[0], n_subdivisions, 0,
false);
204 for (
unsigned int s = 0; s < n_subdivisions; ++s)
205 for (
unsigned int i = 0; i < base_degree; ++i)
206 p.emplace_back(p_base[i + 1],
209 i == (base_degree - 1) && s < n_subdivisions - 1);
215 std::vector<PiecewisePolynomial<double>>
217 const std::vector<
Point<1>> &points)
219 std::vector<PiecewisePolynomial<double>> p;
220 p.reserve(points.size());
222 for (
unsigned int s = 0; s < points.size(); ++s)
223 p.emplace_back(points, s);
234 template class PiecewisePolynomial<float>;
235 template class PiecewisePolynomial<double>;
236 template class PiecewisePolynomial<long double>;
static std::vector< Polynomial< double > > generate_complete_basis(const unsigned int degree)
PiecewisePolynomial(const Polynomial< number > &coefficients_on_interval, const unsigned int n_intervals, const unsigned int interval, const bool spans_next_interval)
std::vector< number > one_over_lengths
number value(const number x) const
virtual std::size_t memory_consumption() const
std::vector< number > points
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcZero()
#define Assert(cond, exc)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcMessage(std::string arg1)
std::enable_if_t< std::is_fundamental< T >::value, std::size_t > memory_consumption(const T &t)
std::vector< PiecewisePolynomial< double > > generate_complete_linear_basis_on_subdivisions(const std::vector< Point< 1 > > &points)
std::vector< PiecewisePolynomial< double > > generate_complete_Lagrange_basis_on_subdivisions(const unsigned int n_subdivisions, const unsigned int base_degree)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)