Skip to main content

BSpline

Struct BSpline 

Source
pub struct BSpline {
    pub t: Vec<f64>,
    pub c: Vec<f64>,
    pub k: usize,
    pub extrapolate: Extrapolate,
}
Expand description

A spline s(x) = Σ cⱼ Bⱼ,ₖ(x) of degree k in the B-spline basis (SciPy’s BSpline).

Fields§

§t: Vec<f64>

The knots, non-decreasing; n + k + 1 of them for n coefficients.

§c: Vec<f64>

The coefficients.

§k: usize

The degree.

§extrapolate: Extrapolate

Behaviour outside [t[k], t[n]].

Implementations§

Source§

impl BSpline

Source

pub fn new(t: Vec<f64>, c: Vec<f64>, k: usize) -> Result<Self, ErrorsJSL>

A spline from knots, coefficients and degree; extrapolates by default.

Source

pub fn len(&self) -> usize

The number of coefficients n.

Source

pub fn is_empty(&self) -> bool

true when the spline has no coefficients (never, for a valid spline).

Source

pub fn evaluate(&self, x: f64) -> f64

The value s(x) (SciPy’s BSpline.__call__).

Source

pub fn evaluate_derivative(&self, x: f64, nu: usize) -> f64

The nu-th derivative s⁽ⁿᵘ⁾(x), zero when nu > k.

Source

pub fn evaluate_many(&self, x: &[f64]) -> Vec<f64>

The values at many points.

Source

pub fn derivative(&self, nu: usize) -> Result<BSpline, ErrorsJSL>

The derivative of order nu as a spline of degree k − nu on the knots with nu removed from each end (SciPy’s BSpline.derivative): c'ⱼ = k (cⱼ₊₁ − cⱼ) / (tⱼ₊ₖ₊₁ − tⱼ₊₁).

Source

pub fn antiderivative(&self, nu: usize) -> BSpline

The antiderivative of order nu, a spline of degree k + nu that vanishes at t[0] (SciPy’s BSpline.antiderivative): one end knot is added at each end and Cⱼ₊₁ = Σᵢ≤ⱼ cᵢ (tᵢ₊ₖ₊₁ − tᵢ) / (k + 1).

Source

pub fn integrate(&self, a: f64, b: f64) -> f64

∫ₐᵇ s(x) dx (SciPy’s BSpline.integrate). With Extrapolate::No the integrand is zero outside the base interval; with Extrapolate::Periodic whole periods are counted.

Source

pub fn design_matrix( x: &[f64], t: &[f64], k: usize, ) -> Result<Array2<f64>, ErrorsJSL>

The B-spline design matrix Mᵢⱼ = Bⱼ,ₖ(xᵢ) for points in the base interval (SciPy’s BSpline.design_matrix, as a dense array).

Trait Implementations§

Source§

impl Clone for BSpline

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BSpline

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for BSpline

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BSpline

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSerialize for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.