[][src]Struct csaps::GridCubicSmoothingSpline

pub struct GridCubicSmoothingSpline<'a, T, D> where
    T: Real,
    D: Dimension
{ /* fields omitted */ }

N-dimensional grid cubic smoothing spline calculator/evaluator

The struct represents n-dimensional grid smoothing cubic spline and allows you to make and evaluate the splines for given n-dimensional grid data.

GridCubicSmoothingSpline struct is parametrized by data type (f64 or f32) and data dimension.

The methods API of GridCubicSmoothingSpline is implemented as builder-like pattern or in other words as chained API (also as CubicSmoothingSpline struct).

Examples

use ndarray::array;
use csaps::GridCubicSmoothingSpline;

let x0 = array![1.0, 2.0, 3.0, 4.0];
let x1 = array![1.0, 2.0, 3.0, 4.0];
let x = vec![x0.view(), x1.view()];

let y = array![
    [0.5, 1.2, 3.4, 2.5],
    [1.5, 2.2, 4.4, 3.5],
    [2.5, 3.2, 5.4, 4.5],
    [3.5, 4.2, 6.4, 5.5],
];

let ys = GridCubicSmoothingSpline::new(&x, &y)
    .make().unwrap()
    .evaluate(&x).unwrap();

Methods

impl<'a, T, D> GridCubicSmoothingSpline<'a, T, D> where
    T: Real,
    D: Dimension
[src]

pub fn new<Y>(x: &[ArrayView1<'a, T>], y: Y) -> Self where
    Y: AsArray<'a, T, D>, 
[src]

Creates NdGridCubicSmoothingSpline struct from the given X data sites and Y data values

Arguments

  • x -- the slice of X-data sites 1-d array view for each dimension. Each data sites must strictly increasing: x1 < x2 < x3 < ... < xN.
  • y -- The Y-data n-d grid values array-like. ndim can be from 1 to N.

pub fn with_weights(self, weights: &[Option<ArrayView1<'a, T>>]) -> Self[src]

Sets the weights data vectors for each dimension

Arguments

  • weights -- the slice of optional weights arrays (array-like) for each dimension

Notes

weights vectors sizes must be equal to x data site sizes for each dimension.

pub fn with_smooth(self, smooth: &[Option<T>]) -> Self[src]

Sets the smoothing parameters for each dimension

Arguments

  • smooth - the slice of optional smoothing parameters for each dimension

Notes

The smoothing parameters should be in range [0, 1] or None, where bounds are:

  • 0: The smoothing spline is the least-squares straight line fit to the data
  • 1: The cubic spline interpolant with natural boundary condition

If the smoothing parameter value is None, it will be computed automatically.

pub fn with_smooth_fill(self, smooth: T) -> Self[src]

Sets the smoothing parameter for all dimensions

Arguments

  • smooth - the smoothing parameter value that the same for all dimensions

Notes

The smoothing parameter should be in range [0, 1], where bounds are:

  • 0: The smoothing spline is the least-squares straight line fit to the data
  • 1: The cubic spline interpolant with natural boundary condition

pub fn make(self) -> Result<Self>[src]

Makes (computes) the n-dimensional grid spline for given data and parameters

Errors

  • If the data or parameters are invalid

pub fn evaluate(&self, xi: &[ArrayView1<'a, T>]) -> Result<Array<T, D>>[src]

Evaluates the computed n-dimensional grid spline on the given data sites

Errors

  • If the xi data is invalid
  • If the spline yet has not been computed

pub fn smooth(&self) -> &Vec<Option<T>>[src]

Returns the ref to smoothing parameters vector or None

pub fn spline(&self) -> Option<&NdGridSpline<'a, T, D>>[src]

Returns ref to NdGridSpline struct with data of computed spline or None

Auto Trait Implementations

impl<'a, T, D> RefUnwindSafe for GridCubicSmoothingSpline<'a, T, D> where
    D: RefUnwindSafe,
    T: RefUnwindSafe

impl<'a, T, D> Send for GridCubicSmoothingSpline<'a, T, D>

impl<'a, T, D> Sync for GridCubicSmoothingSpline<'a, T, D>

impl<'a, T, D> Unpin for GridCubicSmoothingSpline<'a, T, D> where
    D: Unpin,
    T: Unpin

impl<'a, T, D> UnwindSafe for GridCubicSmoothingSpline<'a, T, D> where
    D: UnwindSafe,
    T: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.