11 #ifndef BEMBEL_SRC_SPLINE_LOCALIZE_HPP_
12 #define BEMBEL_SRC_SPLINE_LOCALIZE_HPP_
25 constexpr
inline double Rescale(
double x,
double a,
double b) noexcept {
26 return (a == 0 && b == 1) ? x : (x - a) / (b - a);
31 inline std::vector<double> MakeInterpolationMask(
32 int polynomial_degree) noexcept {
33 std::vector<double> out(polynomial_degree);
34 const double h = 1. / (polynomial_degree + 1);
35 for (
int i = 0; i < polynomial_degree; i++) {
36 out[i] = ((i + 1) * h);
48 const std::vector<T> &uniq,
const std::vector<T> &mask) noexcept {
49 const int size = uniq.size();
52 out.reserve((size - 1) * mask.size());
54 for (
int i = 0; i < size - 1; i++) {
56 out.push_back(uniq[i] + m * (uniq[i + 1] - uniq[i]));
68 int polynomial_degree,
const std::vector<double> &mask) {
69 Eigen::Matrix<double, -1, -1> interpolationMatrix(polynomial_degree + 1,
70 polynomial_degree + 1);
72 double val[Constants::MaxP + 1];
73 for (
int j = 0; j < polynomial_degree + 1; j++) {
74 Bembel::Basis::ShapeFunctionHandler::evalBasis(polynomial_degree, val,
76 for (
int i = 0; i < polynomial_degree + 1; i++)
77 interpolationMatrix(j, i) = val[i];
80 return interpolationMatrix.inverse();
89 const std::vector<T> &values, T *coefs) {
90 int polynomial_degree = mask.size() - 1;
92 Eigen::Matrix<double, -1, -1> im =
95 Eigen::Matrix<T, -1, 1> rhs(polynomial_degree + 1);
97 for (
int i = 0; i < incr; i++) {
98 for (
int j = 0; j < polynomial_degree + 1; j++) {
99 rhs[j] = values[i * (polynomial_degree + 1) + j];
101 Eigen::Matrix<T, -1, 1> tmp(polynomial_degree + 1);
104 for (
int j = 0; j < polynomial_degree + 1; j++) {
105 coefs[i * (polynomial_degree + 1) + j] = tmp(j);
116 template <
typename T>
118 const std::vector<double> &mask,
119 const std::vector<T> &values) {
120 std::vector<double> out(increments * (mask.size()));
121 GetCoefficients<T>(increments, mask, values, out.data());
Eigen::Matrix< double, -1, -1 > GetInterpolationMatrix(int polynomial_degree, const std::vector< double > &mask)
returns the coefficients to represent a function in the Bernstein basis on [0,1].
std::vector< T > MakeInterpolationPoints(const std::vector< T > &uniq, const std::vector< T > &mask) noexcept
Creates a T-vector of equidistant itnerpolation points for a given knot vector without any repetition...
void GetCoefficients(const int incr, const std::vector< double > &mask, const std::vector< T > &values, T *coefs)
this solves a generic interpolation problem.
Routines for the evalutation of pointwise errors.