pub struct GridCubicSmoothingSpline<'a, T, D>{ /* private fields */ }
Expand description
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();
Implementations§
Source§impl<'a, T, D> GridCubicSmoothingSpline<'a, T, D>
impl<'a, T, D> GridCubicSmoothingSpline<'a, T, D>
Sourcepub fn new<Y>(x: &[ArrayView1<'a, T>], y: Y) -> Selfwhere
Y: AsArray<'a, T, D>,
pub fn new<Y>(x: &[ArrayView1<'a, T>], y: Y) -> Selfwhere
Y: AsArray<'a, T, D>,
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.
Sourcepub fn with_weights(self, weights: &[Option<ArrayView1<'a, T>>]) -> Self
pub fn with_weights(self, weights: &[Option<ArrayView1<'a, T>>]) -> Self
Sourcepub fn with_smooth(self, smooth: &[Option<T>]) -> Self
pub fn with_smooth(self, smooth: &[Option<T>]) -> Self
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.
Sourcepub fn with_smooth_fill(self, smooth: T) -> Self
pub fn with_smooth_fill(self, smooth: T) -> Self
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
Sourcepub fn make(self) -> Result<Self>
pub fn make(self) -> Result<Self>
Makes (computes) the n-dimensional grid spline for given data and parameters
§Errors
- If the data or parameters are invalid
Sourcepub fn evaluate(&self, xi: &[ArrayView1<'a, T>]) -> Result<Array<T, D>>
pub fn evaluate(&self, xi: &[ArrayView1<'a, T>]) -> Result<Array<T, D>>
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
Sourcepub fn spline(&self) -> Option<&NdGridSpline<'a, T, D>>
pub fn spline(&self) -> Option<&NdGridSpline<'a, T, D>>
Returns ref to NdGridSpline
struct with data of computed spline or None
Auto Trait Implementations§
impl<'a, T, D> Freeze for GridCubicSmoothingSpline<'a, T, D>where
D: Freeze,
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>
impl<'a, T, D> UnwindSafe for GridCubicSmoothingSpline<'a, T, D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.