use crate::DType;
use crate::interpolate::error::InterpolateResult;
use numr::runtime::Runtime;
use numr::tensor::Tensor;
#[derive(Debug, Clone)]
pub struct BSpline<R: Runtime<DType = DType>> {
pub knots: Tensor<R>,
pub coefficients: Tensor<R>,
pub degree: usize,
}
#[derive(Debug, Clone, Default)]
pub enum BSplineBoundary {
#[default]
NotAKnot,
Clamped { left: f64, right: f64 },
Natural,
}
pub trait BSplineAlgorithms<R: Runtime<DType = DType>> {
fn make_interp_spline(
&self,
x: &Tensor<R>,
y: &Tensor<R>,
degree: usize,
boundary: &BSplineBoundary,
) -> InterpolateResult<BSpline<R>>;
fn bspline_evaluate(
&self,
spline: &BSpline<R>,
x_new: &Tensor<R>,
) -> InterpolateResult<Tensor<R>>;
fn bspline_derivative(
&self,
spline: &BSpline<R>,
x_new: &Tensor<R>,
order: usize,
) -> InterpolateResult<Tensor<R>>;
fn bspline_integrate(
&self,
spline: &BSpline<R>,
a: f64,
b: f64,
) -> InterpolateResult<Tensor<R>>;
}