pub struct Interp1D<C, Z> { /* private fields */ }Expand description
C: Coordinate type.Z: Value type.
Implementations§
Source§impl<C, Z> Interp1D<C, Z>
impl<C, Z> Interp1D<C, Z>
Sourcepub fn new(x: Vec<C>, z: Vec<Z>) -> Selfwhere
C: PartialOrd,
pub fn new(x: Vec<C>, z: Vec<Z>) -> Selfwhere
C: PartialOrd,
Create a new interpolation engine.
Interpolates values which are sampled on a rectangular grid.
§Parameters
x: The x-coordinates. Must be monotonic.z: The valuesz(x)for each grid point defined by thexcoordinates.
§Panics
Panics when
- dimensions of the indices and z-values don’t match.
- one axis is empty.
- x values are not monotonic.
Sourcepub fn bounds(&self) -> (C, C)where
C: Copy,
pub fn bounds(&self) -> (C, C)where
C: Copy,
Get the boundaries of the sample range
as (x0, x1) tuple.
Sourcepub fn is_within_bounds(&self, x: C) -> boolwhere
C: PartialOrd + Copy,
pub fn is_within_bounds(&self, x: C) -> boolwhere
C: PartialOrd + Copy,
Check if the x coordinate lies within the defined sample range.
Sourcepub fn map_values<Z2>(&self, f: impl Fn(&Z) -> Z2) -> Interp1D<C, Z2>where
C: PartialOrd + Clone,
pub fn map_values<Z2>(&self, f: impl Fn(&Z) -> Z2) -> Interp1D<C, Z2>where
C: PartialOrd + Clone,
Create a new interpolated table by applying a function elementwise to the values.
Sourcepub fn map_axis<Xnew>(self, f: impl Fn(C) -> Xnew) -> Interp1D<Xnew, Z>where
Xnew: PartialOrd,
pub fn map_axis<Xnew>(self, f: impl Fn(C) -> Xnew) -> Interp1D<Xnew, Z>where
Xnew: PartialOrd,
Apply a function to the coordinates values of the axis. Panics if the new coordinates are not monotonically increasing.
Source§impl<C, Z> Interp1D<C, Z>
impl<C, Z> Interp1D<C, Z>
Sourcepub fn eval(&self, x: C) -> Z
pub fn eval(&self, x: C) -> Z
Evaluate the sampled function by interpolation at x.
If x lies out of the sampled range then the function is silently extrapolated.
The boundaries of the sample range can be queried with bounds().
Sourcepub fn eval_no_extrapolation(&self, x: C) -> Option<Z>
pub fn eval_no_extrapolation(&self, x: C) -> Option<Z>
Returns the same value as eval() as long as x is within the
range of the samples. Otherwise None is returned instead of an extrapolation.