Struct CubicSpline

Source
pub struct CubicSpline<T, D: Dimension> { /* private fields */ }
Expand description

The CubicSpline 1d interpolation Strategy (Builder)

§Example

From Wikipedia


let y = array![ 0.5, 0.0, 3.0];
let x = array![-1.0, 0.0, 3.0];
let query = Array::linspace(-1.0, 3.0, 10);
let interpolator = Interp1DBuilder::new(y)
    .strategy(CubicSpline::new())
    .x(x)
    .build().unwrap();

let result = interpolator.interp_array(&query).unwrap();
let expect = array![
    0.5,
    0.1851851851851852,
    0.01851851851851853,
    -5.551115123125783e-17,
    0.12962962962962965,
    0.40740740740740755,
    0.8333333333333331,
    1.407407407407407,
    2.1296296296296293, 3.0
];

Implementations§

Source§

impl<T, D> CubicSpline<T, D>

Source

pub fn new() -> Self

create a cubic-spline interpolation stratgy

Source

pub fn extrapolate(self, extrapolate: bool) -> Self

does the strategy extrapolate? Default is false

Source

pub fn boundary(self, boundary: BoundaryCondition<T, D>) -> Self

set the boundary condition. default is BoundaryCondition::Natural

Trait Implementations§

Source§

impl<T: Debug, D: Debug + Dimension> Debug for CubicSpline<T, D>

Source§

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

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

impl<T, D> Default for CubicSpline<T, D>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<Sd, Sx, D> Interp1DStrategyBuilder<Sd, Sx, D> for CubicSpline<Sd::Elem, D>
where Sd: Data, Sd::Elem: SplineNum, Sx: Data<Elem = Sd::Elem>, D: Dimension + RemoveAxis,

Source§

const MINIMUM_DATA_LENGHT: usize = 3usize

Source§

type FinishedStrat = CubicSplineStrategy<Sd, D>

Source§

fn build<Sx2>( self, x: &ArrayBase<Sx2, Ix1>, data: &ArrayBase<Sd, D>, ) -> Result<Self::FinishedStrat, BuilderError>
where Sx2: Data<Elem = Sd::Elem>,

initialize the strategy by validating data and possibly calculating coefficients This method is called in Interp1DBuilder::build Read more

Auto Trait Implementations§

§

impl<T, D> Freeze for CubicSpline<T, D>
where D: Freeze,

§

impl<T, D> RefUnwindSafe for CubicSpline<T, D>

§

impl<T, D> Send for CubicSpline<T, D>
where T: Send,

§

impl<T, D> Sync for CubicSpline<T, D>
where T: Sync,

§

impl<T, D> Unpin for CubicSpline<T, D>
where D: Unpin,

§

impl<T, D> UnwindSafe for CubicSpline<T, D>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.