sablib
Loading...
Searching...
No Matches
sablib::BSpline< Scalar > Class Template Referencefinal

A class for B-Spline operations including basis function calculation and interpolation. More...

#include <bspline.h>

Public Member Functions

 BSpline (const int degree, const Eigen::VectorX< Scalar > &knots)
 Constructor that initializes a B-Spline with a given degree and knot vector.
 BSpline (const int degree, const Eigen::VectorX< Scalar > &knots, const Eigen::VectorX< Scalar > &x, const Eigen::VectorX< Scalar > &y)
 Constructor that initializes a B-Spline and fits it to the given data points.
 BSpline (const int degree, const Eigen::VectorX< Scalar > &knots, const Eigen::VectorX< Scalar > &coefficients)
 Constructor that initializes a B-Spline with a given degree, knot vector, and coefficients.
int BasisSize () const
 Gets the number of basis functions.
const Eigen::VectorX< Scalar > Knots () const
 Returns the knot vector.
const Eigen::VectorX< Scalar > Coefficients () const
 Returns the internal B-Spline coefficients.
const Eigen::SparseMatrix< Scalar > DesignMatrix (const Eigen::VectorX< Scalar > &x) const
 Constructs the design matrix (collocation matrix) for a given set of x-coordinates.
void Fit (const Eigen::VectorX< Scalar > &x, const Eigen::VectorX< Scalar > &y)
 Fits the B-Spline to the given data points by calculating the coefficients.
const Scalar Interpolate (const Scalar x, const Eigen::VectorX< Scalar > &coefficients) const
 Interpolates the value at a given x-coordinate using provided B-Spline coefficients.
const Scalar Interpolate (const Scalar x) const
 Interpolates the value at a given x-coordinate using the internal coefficients.

Detailed Description

template<typename Scalar>
class sablib::BSpline< Scalar >

A class for B-Spline operations including basis function calculation and interpolation.

Template Parameters
ScalarThe scalar type for the spline (e.g., double, float).

Definition at line 23 of file bspline.h.

Constructor & Destructor Documentation

◆ BSpline() [1/3]

template<typename Scalar>
sablib::BSpline< Scalar >::BSpline ( const int degree,
const Eigen::VectorX< Scalar > & knots )

Constructor that initializes a B-Spline with a given degree and knot vector.

Parameters
degreeThe degree of the B-Spline.
knotsThe knot vector.

Definition at line 144 of file bspline.h.

◆ BSpline() [2/3]

template<typename Scalar>
sablib::BSpline< Scalar >::BSpline ( const int degree,
const Eigen::VectorX< Scalar > & knots,
const Eigen::VectorX< Scalar > & x,
const Eigen::VectorX< Scalar > & y )

Constructor that initializes a B-Spline and fits it to the given data points.

Parameters
degreeThe degree of the B-Spline.
knotsThe knot vector.
xThe x-coordinates of the data points.
yThe y-coordinates of the data points.

Definition at line 154 of file bspline.h.

References Fit().

◆ BSpline() [3/3]

template<typename Scalar>
sablib::BSpline< Scalar >::BSpline ( const int degree,
const Eigen::VectorX< Scalar > & knots,
const Eigen::VectorX< Scalar > & coefficients )

Constructor that initializes a B-Spline with a given degree, knot vector, and coefficients.

Parameters
degreeThe degree of the B-Spline.
knotsThe knot vector.
coefficientsThe B-Spline coefficients.

Definition at line 166 of file bspline.h.

Member Function Documentation

◆ BasisSize()

template<typename Scalar>
int sablib::BSpline< Scalar >::BasisSize ( ) const

Gets the number of basis functions.

Returns
The number of basis functions.

Definition at line 176 of file bspline.h.

◆ Coefficients()

template<typename Scalar>
const Eigen::VectorX< Scalar > sablib::BSpline< Scalar >::Coefficients ( ) const

Returns the internal B-Spline coefficients.

Returns
The B-Spline coefficients.

Definition at line 194 of file bspline.h.

◆ DesignMatrix()

template<typename Scalar>
const Eigen::SparseMatrix< Scalar > sablib::BSpline< Scalar >::DesignMatrix ( const Eigen::VectorX< Scalar > & x) const

Constructs the design matrix (collocation matrix) for a given set of x-coordinates.

Parameters
xThe x-coordinates of the data points.
Returns
The sparse design matrix.

Definition at line 267 of file bspline.h.

Referenced by Fit(), and sablib::PSpline().

◆ Fit()

template<typename Scalar>
void sablib::BSpline< Scalar >::Fit ( const Eigen::VectorX< Scalar > & x,
const Eigen::VectorX< Scalar > & y )

Fits the B-Spline to the given data points by calculating the coefficients.

Parameters
xThe x-coordinates of the data points.
yThe y-coordinates of the data points.

Definition at line 296 of file bspline.h.

References DesignMatrix().

Referenced by BSpline().

◆ Interpolate() [1/2]

template<typename Scalar>
const Scalar sablib::BSpline< Scalar >::Interpolate ( const Scalar x) const
inline

Interpolates the value at a given x-coordinate using the internal coefficients.

Parameters
xThe x-coordinate to interpolate.
Returns
The interpolated value at x.

Definition at line 337 of file bspline.h.

References Interpolate().

◆ Interpolate() [2/2]

template<typename Scalar>
const Scalar sablib::BSpline< Scalar >::Interpolate ( const Scalar x,
const Eigen::VectorX< Scalar > & coefficients ) const

Interpolates the value at a given x-coordinate using provided B-Spline coefficients.

Parameters
xThe x-coordinate to interpolate.
coefficientsThe B-Spline coefficients.
Returns
The interpolated value at x.

Definition at line 315 of file bspline.h.

Referenced by Interpolate(), and sablib::PSpline().

◆ Knots()

template<typename Scalar>
const Eigen::VectorX< Scalar > sablib::BSpline< Scalar >::Knots ( ) const

Returns the knot vector.

Returns
The knot vector.

Definition at line 185 of file bspline.h.


The documentation for this class was generated from the following file: