18#include <unsupported/Eigen/Splines>
22typedef Eigen::Spline<double, 1, Eigen::Dynamic>
Spline1D;
33 std::string
name()
const override {
return "BSpline"; }
34 const std::string
category()
const override {
return "Background"; }
35 void function1D(
double *out,
const double *xValues,
const size_t nData)
const override;
36 void derivative1D(
double *out,
const double *xValues,
size_t nData,
const size_t order)
const override;
39 void setAttribute(
const std::string &attName,
const Attribute &)
override;
41 std::vector<std::string> getAttributeNames()
const override;
44 void resetParameters();
48 void resetValidators();
50 [[nodiscard]] std::vector<double> calcUniformBreakPoints(
const double startX,
const double endX);
52 void resetKnotVector(
const std::vector<double> &breakPoints);
54 size_t evaluateBasisFunctions(
EigenVector &B,
const double x,
size_t currentBBase)
const;
56 void initialiseSpline(
const std::vector<double> &breakPoints);
58 size_t getSpanIndex(
const double x,
const size_t currentBBase,
const bool clamped =
true)
const;
60 [[nodiscard]]
EigenMatrix evaluateBasisFnDerivatives(
const double x,
const size_t derivOrder)
const;
67 inline int getNKnots()
const {
return getNBreakPoints() + getClampedKnots() * 2 - 2; }
69 inline int getOrder()
const {
return getAttribute(
"Order").asInt(); }
73 inline int getDegree()
const {
return getOrder() - 1; }
Attribute is a non-fitting parameter.
A wrapper around Eigen::Matrix.
A wrapper around Eigen::Vector.
A wrapper around Eigen functions implementing a B-spline.
const std::string category() const override
overwrite IFunction base class methods
std::string name() const override
overwrite IFunction base class methods
int getOrder() const
Get order of the spline, k.
int getNBreakPoints() const
Get number of Break Points.
int getClampedKnots() const
Get number of knots required to clamp the spline closed.
int getDegree() const
Get the degree of constituent polynomial functions.
int getNBSplineCoefficients()
Get number of B-Spline coefficients.
Spline1D m_spline
Member variable for spline.
int getNKnots() const
Get number of Knots.
std::vector< double > m_knots
Eigen::Spline< double, 1, Eigen::Dynamic > Spline1D