DynSpline

Type Alias DynSpline 

Source
pub type DynSpline<T> = Spline<DynInterpType<T>, T>;
Expand description

2D Spline with runtime-determined Interpolation Type.

Aliased Type§

pub struct DynSpline<T> {
    pub interp: Box<dyn Interpolation<T> + Sync + Send>,
    pub xa: Box<[T]>,
    pub ya: Box<[T]>,
    /* private fields */
}

Fields§

§interp: Box<dyn Interpolation<T> + Sync + Send>

The lower-level Interpolator.

§xa: Box<[T]>

The owned x data.

§ya: Box<[T]>

The owned y data.

Implementations§

Source§

impl<T> DynSpline<T>

Source

pub fn new_dyn<I>( typ: I, xa: &[T], ya: &[T], ) -> Result<Self, InterpolationError>
where T: Clone, I: InterpType<T> + Send + Sync + 'static, I::Interpolation: Send + Sync + 'static,

Constructs a Spline of a dynamic Interpolation type typ from the data arrays xa and ya.

§Example
let xa = [0.0, 1.0, 2.0, 3.0, 4.0];
let ya = [0.0, 2.0, 4.0, 6.0, 8.0];
let typ = "cubic";

let spline = match typ {
    "cubic" => Spline::new_dyn(Cubic, &xa, &ya)?,
    "akima" => Spline::new_dyn(Akima, &xa, &ya)?,
    // ...
    _ => unreachable!()
};